In this course we’ll look at how to use an RTC or clock module with the Beaglebone Black.
An RTC module keeps the time when your Beaglebone Black is switched off. It is an essential electronic component in many applications where precise time management is crucial. This small, self-contained device features an internal clock powered by a button cell, enabling it to continue operating even in the absence of a main power supply.
The RTC module chosen for this course is the DS1307. It uses I2C to communicate with the Beaglebone Black.
Here’s the circuit to connect the RTC module to the Beaglebone Black:
How do I check that the real time clock module is properly connected?
To verify that our RTC module, we will check if it is recognized by I2C. To do this, type the command i2cdetect -y -r 2.
In the picture to see 68 appear, which is the address of our RTC module.
RTC module time reading
Once the RTC module is properly connected, we will see the program in order to retrieve and modify the time coming from the RTC module. The first step is to install the smbus library which manages I2C communication:
Here is the program to read the time and date coming from the RTC module:
RTC module time reading
You probably realized in the previous program that the time was not accurate. This is why we are going to see a program to modify it.