Posts: 89
Joined: Wed Aug 22, 2012 11:25 am
Location: Melbourne, VIC

Using DS3231 RTC alarm reset/wake from halt

Tue Feb 02, 2016 11:46 pm

I am busy looking into how I can use the alarm from a DS3231 to wake/boot a Raspberry Pi, either using Wake from Halt, or the P6 header - using the alarm functionality from the DS3231. My intention is to use the INT (active low) ping from the DS3231 to drive either RUN (P6 header) or pin 5 on the GPIO (GPIO3) low.

The challenges here are that GPIO3 is shared with SCL on the I2C bus, which the DS3231 also uses. That raises the question of whether I can find a way to connect the INT pin from the DS3231 to GPIO3 without conflicting with the I2C bus (SCL). One suggestion I have seen for using a push-button switch to drive GPIO3 low (for wake on halt) when there is an I2C bus as well is to connect a 1k resistor and a diode in series (resistor to GPIO3, anode of diode to resistor) to GPIO3 to protect it when it is set as an output. The question I have is whether this will work when using the RTC to pull GPIO3 low. (Clearly the SCL signal would get messed up if an alarm is activated while the Pi is running.)

Driving the RUN ping (P6 header) low seems like a simpler hardware solution. The problem this has is that if the RPi is running when the alarm occurs, it will be reset, which I don't want. One thought I have had is to find a line which I know will always be high when the RPi is running, and feed that and the INT pin from the DS3231 through an OR gate. The challenge here is to find an appropriate line to use.

Any suggestions?


Posts: 12
Joined: Tue Oct 30, 2018 1:41 am

Re: Using DS3231 RTC alarm reset/wake from halt

Tue Nov 06, 2018 6:53 pm

You can use software I2C using any GPIO pins - that way, there is no conflict with pin3 for wake from halt.

See ... ays/README for more details. Relevant section copy-pasted here:

Name: i2c-gpio
Info: Adds support for software i2c controller on gpio pins
Load: dtoverlay=i2c-gpio,<param>=<val>
Params: i2c_gpio_sda GPIO used for I2C data (default "23")

i2c_gpio_scl GPIO used for I2C clock (default "24")

i2c_gpio_delay_us Clock delay in microseconds
(default "2" = ~100kHz)

bus Set to a unique, non-zero value if wanting
multiple i2c-gpio busses. If set, will be used
as the preferred bus number (/dev/i2c-<n>). If
not set, the default value is 0, but the bus
number will be dynamically assigned - probably


Posts: 3511
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Using DS3231 RTC alarm reset/wake from halt

Wed Nov 07, 2018 1:23 am

I did a post about power up the PI using the RTC

You have the schematic and the code.

It is in french then use google translate.

viewtopic.php?f=65&t=166853&p=1075093&h ... e#p1074313

Return to “Interfacing (DSI, CSI, I2C, etc.)”