A real-time clock (RTC) is an integrated hardware circuit that keeps track of the current time.
This RTCs module have an alternate source of power, so they can continue to keep time while the primary source of power is off or unavailable.
This is an important feature for the server applications which under some circumstances cannot always had a network connection to access the NTP (Network Time Server) from the internet.
The RTC also useful to keep track the system time clock during power outage or intermittent power supply where the time is critical especially for transaction application.
Install the RTC hardware module
It is always best to turn your Raspberry Pi off before plugging anything onto the GPIO pins.
Now plug the board onto your Raspberry Pi GPIO pins on the inside corner with the RTC board pointing inwards, as shown below :
Please do note that this RTC module is only needed for the server machine of this Laundromat Plus system. No need to install this on client machine since that will taken care of by it's software, besides the gpio interface on client machine is already occupied by the lcd.
Set Time Date
After the RTC module installed, the server OS (since version 5.x) will recognize the module and get the time from it during boot. The system time will synced on each boot so it never lost track the current time date.
To set the correct date and time for the RTC is easy :
- Open the terminal (you may ssh into the machine or directly connect it to hdmi display)
- From the command prompt execute this command to check the current date and time of the machine :
The output is self explanatory, it tells you the current system time and the RTC time.
- To set the system time :
sudo date -s "13 jan 2020 09:00:00" sudo hwclock -w
The first command will set the system time to it's desired value and the second command will save it to the RTC module.
- Check again the result with :
Test the result
Shutdown the server machine gracefully, leave it without power for sometime, and powered back on after it. Somehow, make sure you are NOT connect to the internet (or it will automatically sync the system time to NTP) and check again with