Raspberry Pi DS3231
As you may know, real time clocks have many great benefits. They can keep the current time for a few years if used properly. You can read many articles about how useful they are and why, but right now, I’ll just show you how I got my DS3231 to work with Raspbian Stretch.
So firstly we’ll need to edit the config file.
sudo nano /boot/config.txt
Alright. Now we’re going to add this line to the bottom of the file. This will tell the Raspberry Pi to enable it’s i2c interface and its DS3231 interface
dtoverlay=i2c-rtc,ds3231
Ok. So once we’ve done that, we’ll need to exit the text editor by pressing Control + X, then when prompted to, click Y, then enter.
Alright, so now we’ll need to disable the software RTC. This just keeps the network time. So what we’ll want to do is stop that. So type:
sudo nano /lib/udev/hwclock-set
Ok. Now find the line:
if [-e /run/systemd/system ]; then
exit 0 fi
And replace it with
#if [-e /run/systemd/system ]; then
#exit 0
#fi
Alright. So reboot by typing
sudo reboot
And type
sudo hwclock -r
To see the time If it isn’t correct, type
sudo raspi-config
Go to option 4 (Localization), then go to option I2 and follow the steps. Then type
sudo hwclock -w
And you’re done!
Quick Note About My Sponsor
That concludes this post, but the sponsor of this project is PCBWay who, at the time is celebrating their 5th anniversary. Check them out at: https://www.pcbway.com/ and don't forget their assembly service is now as low as $30.