Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Interfacing (DSI, CSI, I2C, etc.) • Re: MCP7940N RTC - configuring alarms

$
0
0

1. Your RPi 2W does not have a "sleep state"; the RPi5 may have (??) a sleep state b/c it was the first RPi built with a RTC. IOW: No RPI (other than maybe the Pi5) has a "sleep state"; therefore your use of 'rtcwake' is not appropriate.
2. Your line from config.txt looks correct: dtoverlay=i2c-rtc,mcp7940x,wakeup-source
3. This line will cause the following file to be added in your '/sys' folder: '/sys/class/rtc/rtc0/wakealarm'
4. If you write an appropriate time value (some future epoch time) to '/sys/class/rtc/rtc0/wakealarm', the RTC's INTERRUPT line will be "toggled" at that time.
5. You may use this RTC INTERRUPT line to control "external hardware" (e.g. a relay). Here is an example of "external hardware".
6. WRT your 'dmesg' line ( 'request for an IRQ is disabled' )... that is simply telling you that the 'wakeup-source' you specified in your config.txt line was honored (the addition of '/sys/class/rtc/rtc0/wakealarm' ), but there is no IRQ set because your Pi Zero 2W system would not know what to do with such an IRQ. Remember - it has no sleep state!

Hope this isn't too late to help.
Hey, thanks for the response! Yes, I know there isn't a sleep state - I have external hardware which manages the power. However, it needs the RTC to trigger the alarm in order to actually wake up. I've since written it in my own driver code, but would definitely prefer to have it supported from the kernel module if possible.

So, my problem really boils down to point 3 above. After I add

Code:

dtoverlay=i2c-rtc,mcp7940x,wakeup-source
to the config.txt, the file shows up in

Code:

/sys/class/rtc/rtc0/wakealarm
. I wasn't really able to find many resources about this file and how to use it, but I just stumbled across an article which specifies that the following would work:

Code:

echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm
I'll test this later today!

From my understanding, it seems like this all comes down to the issue you are pointing out - there is no low power mode and thus no way it could feasibly "wake up" the processor. Partially, this comes down to my naivety regarding the rtcwake tool. After looking at the docs again, it looks like there is a flag for the mode. The default standby mode wouldn't work, but there is another off mode which would power off the system. I'll also have to give this one a shot later today.

Code:

sudo rtcwake -s 3600 -m off
This is actually good timing because I just received v0.2 of the hardware yesterday :) If you're curious about the project: https://github.com/protolux-electronics/soleil_hardware

Statistics: Posted by gworkman — Thu Feb 20, 2025 8:02 am



Viewing all articles
Browse latest Browse all 8082

Trending Articles