Use pin_wakeup_sleep with different pins and wakeup reasons
-
I have 2 different pins that must wake up my LoPy4 from deepsleep. One of them is
P14
and it must wake up when value goesLOW
. The other isP23
and it must wake up when value goesHIGH
.I thought I could just do:
machine.pin_sleep_wakeup(['P14'], mode=machine.WAKEUP_ALL_LOW, enable_pull=False) machine.pin_sleep_wakeup(['P23'], mode=machine.WAKEUP_ANY_HIGH, enable_pull=False)
And that would achieve the behaviour I described. Unfortunately, when doing this, it seems the first instruction is overwritten, so only
P23
is able to wake the device up, notP14
.Since each pin wakes up the device with different values (
HIGH
andLOW
), I cannot write this in only 1 instruction... Any ideas?Running
1.20.2.rc6
fw.
-
@d-alvrzx the ESP32 has various sleep modes with various possibilities for wake up sources. The lowest power modes are indeed quite limited by design. IIRC the Pycom firmware uses ext1 wake up. You’ll find details of the different wake up sources of the ESP32 in the ESP IDF docs: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html
-
You can add both pins in the same tuple, but I believe you cannot select both modes at the same time, even if you set it for different pins, as you mentioned, the second command overrides the first, and I think it is not possible on the hardware level.
-
Following up on this, it seems this post confirms mi suspicion that a second call to
pin_sleep_wakeup()
overwrites previous calls: https://forum.pycom.io/topic/5716/how-to-wake-up-the-lopy-with-the-accelerometer/5?_=1626977858609@Gijs do you know if this a HW limitation of the ESP32 or could this functionality be added by modifying the firmware?