Deepsleep wake only on rising pin?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
BetterAutomations
Posts: 83
Joined: Mon Mar 20, 2017 10:22 pm

Deepsleep wake only on rising pin?

Post by BetterAutomations » Mon Jan 17, 2022 11:07 pm

I have two pins on an ESP32 that are often held high. How do I have them only wake the device when it's rising and not already held? The device won't stay in deep sleep when it's held high.

It's a door sensor. When the door is open I send an alert then deep sleep until the close sensor is detected.

Relevant code:

Code: Select all

    door_open_pin = machine.Pin(DOOR_OPEN_PIN, machine.Pin.IN, machine.Pin.PULL_DOWN)
    door_close_pin = machine.Pin(DOOR_CLOSE_PIN, machine.Pin.IN, machine.Pin.PULL_DOWN)
    esp32.wake_on_ext1(
        pins=(door_open_pin, door_close_pin),
        level=esp32.WAKEUP_ANY_HIGH)

BetterAutomations
Posts: 83
Joined: Mon Mar 20, 2017 10:22 pm

Re: Deepsleep wake only on rising pin?

Post by BetterAutomations » Tue Jan 25, 2022 7:00 pm

Worked around my problem using a combination of AND, OR, and NOT gates with capacitors to create a rising pulse detector circuit, only for waking the device. Once woken it reads the state of the pins. Uses one extra GPIO for the wake, but I can have as many pins waking it as I need by branching into more OR gates.

Falstad:
https://www.falstad.com/circuit/circuit ... CpBgIPhYgA

Post Reply