Close

Fixing the Real-time Clock

A project log for Portable Pi

An easy to build rugged-ish, portable-ish raspberry pi with a 10.1 ins screen and a 40% mechanical keyboard.

jefmerjefmer 02/14/2024 at 10:250 Comments

Out of the box, a Raspberry Pi 4 does not have a real-time clock. When it is booted up, it initially displays the time it was shutdown at - then when it connects to the network, it updates the time via Network Time Protocol (NTP).

I fitted a DS3231 real-time clock module to the Portable Pi as I do use it when there is no network connection and it is confusing if files end up with the wrong date. The DS3231 has internal temperature compensation and has by far the lowest drift of all the RTC modules available for the Raspberry Pi. The module plugs into the GPIO pins and you can just see it in the photo of the back of the display assembly. Because, the Pi usually connects to the network with little delay, I only noticed recently that the clock had stopped working and that the Pi was starting up with the same time it had shutdown at.

My first thought was that I had done something wrong in the setup - I used these excellent instructions* - https://pimylifeup.com/raspberry-pi-rtc/.  However, everything in the software set up checked out, so I removed the clock module as seen in the right of the photo below:

The module has a small long-life battery fitted under the chip - it has some yellow plastic around the rim. This proved to be completely flat - I bought a set of three of these modules some time ago and I think in addition the modules were manufactured some time before that. As can be seen on the left of the photo, I cut out the failed battery and connected a standard CR2032 Lithium battery which should last for quite a long time as, on standby, the DS3231 draws only a few micro-amps.

* ( There are a lot of out of date instructions on the Web -  of course the RPi5 has a built in RTC.)

Discussions