Real time clock module

Real time clock module

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 :

alter-text
RTC module install

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 :
timedatectl
alter-text
Set Time Date timedatectl

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
alter-text
Set Time Date

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 :
timedatectl
alter-text
Set Time Date timedatectl
  • Done

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 timedatectl command.

alter-text
RTC DS3231 module on RPi4
comments powered by Disqus

Related Posts

Running Docker in LXC Container

Running Docker in LXC Container

VMs require more resources from the hypervisor and much slower compare to lxc container especially the boot speeds.

Read More
zsh shell

zsh shell

If you work on many projects and always jump from one to another, there are times when you forget which branch you are standing on.

Read More
Laundrowallet

Laundrowallet

It’s build from Wemos D1 mini with esp12F chipset and an ssd1306 OLED display for the status display and RC522 RFID card reader as an input.

Read More