How to use the RTC


1. Purpose[edit source]

This article describes how to use RTC. The RTC overview is described in RTC overview article.

2. How to set a hardware clock thanks to hwclock tool[edit source]

3. How to set an alarm[edit source]

# disable the alarm #
 echo 0 > /sys/class/rtc/rtc0/wakealarm
# calculate alarm with 1 minute later #
 wakeuptime=`date -d "1 minute" +%s`
# set the alarm #
 echo $wakeuptime > /sys/class/rtc/rtc0/wakealarm


4. How to set an alarm and go into a system sleep state with rtcwake tool[edit source]

 t1=$(date -d '+5 minutes' '+%s')
 rtcwake -lt$t1 -m no
 rtcwake: wakeup using /dev/rtc0 at Sat Mar 10 14:53:30 2018
 root@stm32mp1:~# [ 9367.083712] rtc rtc0: Alarm occurred

5. References[edit source]


Template:ArticleMainWriter