How to maintain the time even when the power is off using the RTC function of Raspberry Pi 5. The time can be maintained even offline, which is convenient for remote monitoring etc.



Raspberry Pi 5 is equipped with an RTC module, which allows you to keep time without using peripherals such as HAT. Furthermore, by connecting a backup battery for RTC, it is possible to maintain the time even when the power is turned off. It seemed to be useful for remote monitoring applications that do not connect to the Internet, so I have summarized the steps to connect a backup battery to maintain the time and the steps to use a secondary battery as a backup battery.

Raspberry Pi 5 – Raspberry Pi

https://www.raspberrypi.com/products/raspberry-pi-5/

Raspberry Pi Documentation - Raspberry Pi 5
https://www.raspberrypi.com/documentation/computers/raspberry-pi-5.html

·table of contents
◆1: Preface about technical aptitude
◆2: Steps to connect the backup battery
◆3: Verify whether the time can be maintained with a backup battery
◆4: How to charge the secondary battery for backup battery
◆5: How to reduce standby power during shutdown

◆1: Preface about technical aptitude
The Raspberry Pi 5 used this time was sent directly to the GIGAZINE editorial department from the Raspberry Pi Foundation and has not received technical standards compliance certification. Therefore, we have submitted a notification for the ` `special system for experiments, etc. using equipment that has not obtained technical compliance .'' In addition, in Japan, Raspberry Pi 5 is scheduled to be released after the technical compliance application by the agency, so general users do not need to worry about technical compliance.



◆2: Steps to connect the backup battery
This time, we prepared an ML2032 secondary battery as a backup battery, a battery case, and a '

JST type SH 2P connector cable .' A JST type SH connector is required to connect a backup battery to Raspberry Pi 5.



This is what it looks like when you assemble the parts.



Connect the assembled parts to the connector located between the USB-C port and Micro HDMI port of Raspberry Pi 5.



Now the time can be maintained even when the power is off.



◆3: Verify whether the time can be maintained with a backup battery
In order to verify whether the time can be maintained with a backup battery, we will compare the behavior with and without a backup battery.

・Without backup battery
First, when I checked the time on the normally booted Raspberry Pi 5 from the serial console, it showed the same time as the Windows PC.



Next, I cut off Raspberry Pi 5 from the network to prevent it from accessing the NTP server, and also turned off the power. Wait in this state for several minutes.



When I restarted the Raspberry Pi 5 after waiting for a while and checked the time, the time was incorrect because it did not advance while it was disconnected from the power supply.



・With backup battery
Next, check whether the time remains correct with the backup battery connected. First, connect to the network, obtain the time from the NTP server, and set the time.



Then, disconnect it from the network and power it down.



Even after starting up a few minutes later, the time remained the same. The backup battery kept the time moving forward.



In addition, the time can be maintained without a backup battery as long as the power is connected.

◆4: How to charge the secondary battery for backup battery
If you are using a secondary battery as a backup battery, you can charge the secondary battery from Raspberry Pi 5 by adding the line ``dtparam=rtc_bbat_vchg=○○'' to ` `/boot/firmware/config.txt ''. You can specify the target voltage by entering a number from 1300000 to 4400000 in '○○'. The secondary battery I'm using this time is rated at 3V, so I entered 'dtparam=rtc_bbat_vchg=3000000'.



You can check the backup battery voltage with the following command.
[code]cat /sys/devices/platform/soc/soc:rpi_rtc/rtc/rtc0/battery_voltage[/code]



I checked the voltage and found that it was charging to nearly 3V.



◆5: How to reduce standby power during shutdown
By rewriting the EEPROM of Raspberry Pi 5, you can reduce standby power consumption during shutdown. The setting procedure is as follows.

First, execute the following command to display the EEPROM settings change screen.
[code]sudo -E rpi-eeprom-config --edit[/code]



When the settings screen opens, change 'POWER_OFF_ON_HALT=0' to ' POWER_OFF_ON_HALT=1 ' and add the line ' WAKE_ON_GPIO=0 '. After that, restart the system to complete the setting change.



I actually measured the standby power using the USB tester '

WITRN U3 '. Standby power in normal state is approximately 1.3V.



The standby power after changing the settings was approximately 0.02W.



In addition, after changing the settings, voltage will no longer be output from the 3.3V pin of GPIO.



On the other hand, voltage was coming out from the 5V pin.



◆Forum now open
GIGAZINE's official Discord server has a forum related to Raspberry Pi 5. Anyone can write from the link below, so please write something like 'I'm curious about ○○'.

• Discord | 'Raspberry Pi 5 has arrived at the GIGAZINE editorial department, so I'm going to review it, but what do you want to know? ' | GIGAZINE
https://discord.com/channels/1037961069903216680/1166304963497041981



in Review,   Hardware, Posted by log1o_hf