Installing hardware RTC (DS3231) to Raspberry Pi
Problem
As we know, Raspberry Pi does not have RTC. We can use
w: ntpd for date and time synchronizing with NTP servers. But what we can do if we do not want to use NTP? What we can do if we want to use our RPi standalone?
Also, Raspbian OS (which based on Debian) uses "fake hwclock" module:
Some machines don't have a working realtime clock (RTC) unit, or no
driver for the hardware that does exist. fake-hwclock is a simple set
of scripts to save the kernel's current clock periodically (including
at shutdown) and restore it at boot so that the system clock keeps at
least close to realtime. This will stop some of the problems that may
be caused by a system believing it has travelled in time back to
1970, such as needing to perform filesystem checks at every boot.
But we need to have real hwdclock and abilities for standalone work! :) Let's do it!
Solution
Looking for hardware
First, we need find and buy hardware. We can use many solutions (based on DS1307, DS3231, NXP PCF2127AT, NXP PCF2127T, NXP PCF2129AT, NXP PCF2129T) but in this case we will use DS3231.
Then, we need buy this RTC. If we will try to search by "Raspberry Pi RTC module buy" request we will found very expensive solutions - 10-15 USD or more. It's very expensive and we can make bargain deal. What we need to do - look for DIY DS3231 modules. We can use modules for Arduino. They have much lower cost. For example, we can buy DS3231 from
aliexpress.com only for 1-2 USD. The main difference - connectors. We must connect all pins from DS3231 to the our Raspberry Pi.
DS3231 DIY module