If you’re looking to incorporate timekeeping capabilities into your Brainy Pi project, you’ll need to utilize its internal Real-Time Clock (RTC). An RTC is an electronic component that keeps track of time and date even when the device is turned off or loses power. In this article, we’ll go over how to use the internal Real Time Clock on Brainy Pi, a versatile single-board computer, to ensure your projects have accurate timekeeping capabilities.
RTC on BrainyPi
Brainy Pi uses the RK808 PMIC, which is a power management IC that includes an RTC module. The RTC module is responsible for keeping track of time, and it
can be accessed using the /dev/rtc0
device node in Rbian. The RTC module on the RK808 PMIC supports seconds, minutes, hours, days, months, and years.
Connecting a RTC battery connector to BrainyPi
To use the RTC function on BrainyPi, you need to connect a RTC battery connector to the board. The RTC battery connector is a 2-pin header that allows you to connect a CR2032 or similar coin cell battery to power the RTC circuit.
Here are the steps to connect the RTC battery connector to BrainyPi:
Buy “CR2032 3V 220mAh Lithium Coin cell battery with 2pin connector”
Amazon India Link – https://www.amazon.in/CR2032-220mAh-Connector-Battery-Motherboard/dp/B09N2MFVSV
Other Site Link – https://sharvielectronics.com/product/cr2032-3v-220mah-lithium-coin-cell-battery-with-2pin-connector/
Amazon Global Link – https://www.amazon.com/Battery-Lenovo-Thinkpad-X220i-X230i/dp/B086KT9KKV?ref_=ast_slp_dp&th=1
Locate the RTC battery connector on BrainyPi. It is a 2-pin header located near the HDMI port.
Connect the Battery Connector as per the image below. Note: +ve terminal is near the HDMI port, connecting the battery terminals incorrectly may cause harm to BrainyPi.
Once the battery is connected, the RTC will start keeping track of time.
Using Real Time Clock on Brainy Pi
Now that you have connected the RTC battery connector to BrainyPi, you can start using the RTC function.
Steps to use RTC on BrainyPi:
We will use a combination of timedatectl
and hwclock
commands in Linux to set time using RTC
1. Read current time from RTC
You can use the following command to read the current time from the RTC module:
sudo hwclock -r
2. Update RTC time to system time
You can use the following command to set the system time to the time stored in the RTC module:
sudo hwclock -w
3. Update system time to the time stored in the RTC
You can use the following command to set the system time to the time stored in the RTC module:
sudo hwclock -s