Raspberry Pi Pico + DS3231 RTC Digital Clock With 16x2 I2C LCD
by ElectroScope Archive in Circuits > Raspberry Pi
14 Views, 0 Favorites, 0 Comments
Raspberry Pi Pico + DS3231 RTC Digital Clock With 16x2 I2C LCD
In this build, I’m going to show you exactly how I made a simple but very accurate digital clock using a Raspberry Pi Pico, a DS3231 RTC module, and a 16x2 I2C LCD.
The cool part is that the RTC keeps time even when the Pico is powered off, thanks to its coin cell battery. The LCD cycles between time/date and temperature automatically, so we get more info without adding extra buttons.
This is a straightforward project. If you follow the wiring and upload the code properly, you’ll have it running in under an hour.
Supplies
Raspberry Pi Pico
DS3231 RTC module (with CR2032 battery installed)
16x2 LCD with I2C backpack
Breadboard
Jumper wires
USB cable for Pico
Install the Required Libraries
Open Arduino IDE.
Make sure you have support installed for Raspberry Pi Pico boards. If not, add the Pico board package first.
Now install these two libraries from Library Manager:
- RTClib (by Adafruit)
- LiquidCrystal_I2C (by johnrickman)
These handle communication with the DS3231 and the LCD.
That’s it. No extra stuff required.
Wiring Everything
This project uses I2C, which is nice because both the RTC and the LCD share the same two communication wires.
On the Raspberry Pi Pico:
- GP4 → SDA
- GP5 → SCL
- 3.3V → VCC
- GND → GND
Connect DS3231
- VCC → 3.3V
- GND → GND
- SDA → GP4
- SCL → GP5
Connect LCD (I2C backpack)
- VCC → 3.3V
- GND → GND
- SDA → GP4
- SCL → GP5
Both modules share SDA and SCL. That’s how I2C works. Each device has its own address.
The DS3231 default address is 0x68.
The LCD backpack is usually 0x27.
Double check:
- Battery is inserted into DS3231
- No loose wires
- SDA and SCL not swapped
If SDA/SCL are reversed, nothing works.
Upload Basic Test Code First
Before building the full clock, I always test the RTC alone.
Here’s a minimal test:
Upload it. Open Serial Monitor.
If you see time counting properly, your RTC is working.
If it says "RTC not found", check wiring.
Important: Setting the Time Properly
The DS3231 only needs to be set once.
You have two options.
Option 1: Auto set from computer
This line sets the RTC using your computer’s compile time:
Steps:
- Uncomment the line
- Upload immediately
- Then comment it again
- Upload again
If you don’t comment it out, the time resets every time the Pico restarts.
That’s a very common mistake.
Option 2: Set manually
If you want a specific date:
Format:
YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
Again, upload once, then remove the line.
Add the LCD
Now let’s bring the LCD into the project.
Here’s the working clock code that:
- Displays date and time
- Switches to temperature
- Updates every second
That’s the whole thing.
How It Works
- Pico talks to RTC over I2C
- Pico talks to LCD over same I2C bus
- RTC provides time + temperature
- LCD prints formatted values
- Delays switch display modes
The DS3231 temperature sensor has 0.25°C resolution. It’s not lab grade, but it’s pretty decent.
Testing the Backup Battery
Unplug the USB.
Wait 30 seconds.
Plug it back in.
If the time continues correctly, your coin cell is working.
If time resets, check:
- Battery orientation
- Battery voltage
- Battery holder contacts
Common Problems and Fixes
LCD shows blank screen
- Check contrast screw on I2C backpack
- Confirm address is 0x27
- Try I2C scanner sketch if unsure
RTC not detected
- Check SDA and SCL wiring
- Make sure battery is inserted
- Try different jumper wires
Time resets every reboot
You forgot to comment out:
Remove it and upload again.
Making It Cleaner
If you want it permanent:
- Use a small perf board
- Add header pins to Pico
- Use short wires
- Put it inside a small enclosure
You can power it from:
- USB
- 5V adapter
- Power bank
The RTC battery handles timekeeping when main power is gone.
That’s It
This is a solid little clock project. It’s simple, accurate, and easy to expand.
You could add:
- Alarm buzzer
- Buttons to set time
- 20x4 LCD
- OLED display
- Data logging
But as it stands, this is a clean, reliable DS3231 + Pico digital clock that just works.
If you wire it properly and set the time correctly once, you don’t need to touch it again.
This guide is completely based on: Raspberry Pi Pico RTC