-
Hi, I would like to have a callback when pressing one of the 2 input buttons on a Lilygo T5-Plus board. I can run the examples from the micropython GPIO documentation, everything seems fine, I can read the button values when pressed/released, but my 'handler' callback is never called!!?
In between the first call to p.value() and the second I am pressing the button, p.value() sees this just fine, but the callback() function is apparently never called?? I feel very stupid.... anyone got an idea of why no callback? thanks |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
Your code runs on a Pyboard (just changing the pin no), with the callback running when I pull the pin down: >>> import machine
>>> p = machine.Pin('X1', mode=machine.Pin.IN, pull=machine.Pin.PULL_UP)
>>> def callback(p):
... print(p)
...
>>> p.irq(trigger=machine.Pin.IRQ_RISING | machine.Pin.IRQ_FALLING, handler=callback)
>>> Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_UP)
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_UP)
Pin(Pin.cpu.A0, mode=Pin.IN, pull=Pin.PULL_UP) I can only think there's an issue with the board or the IDE. |
Beta Was this translation helpful? Give feedback.
-
Hi Peter, is the pyboard a ESP32 or an ESP32S3? The code works fine on an original T5 (ESP32), but not on the T5-Plus (ESP32S3) : tried with IO0, IO21 and IO15 pins.... Maybe there is a fix needed for the S3? |
Beta Was this translation helpful? Give feedback.
-
Appears to be a bug in ESP IDF 4.4: |
Beta Was this translation helpful? Give feedback.
-
The current nightly builds use esp-idf v5.0.2. You can try these, |
Beta Was this translation helpful? Give feedback.
-
This works on an ESP32-S3 with the latest firmware import machine
p = machine.Pin(8, mode=machine.Pin.IN, pull=machine.Pin.PULL_UP)
def callback(p):
print(p)
p.irq(trigger=machine.Pin.IRQ_RISING | machine.Pin.IRQ_FALLING, handler=callback) |
Beta Was this translation helpful? Give feedback.
-
My IRQ callback now works as expected. However, I cannot get it to wake from a lightsleep... I do;
I press the button on IO21, I get the IRQ and it prints 'Pin(21)'. So far so good
ESP32S3 sleeps (@6ma) for 10s. Pressing the button has no effect. When it returns from the sleep after the timeout of 10s, it prints 'Pin(21)'. I see other posts where people have this working, but only with 'normally low' (PULL_DOWN) ios and using WAKE_ANY_HIGH for the level param... IO21 should be an 'RTC' pin so able to wake from light sleep... Anyone able to shed light on this? thanks! |
Beta Was this translation helpful? Give feedback.
-
Testing on a ESP32 shows that the wake_on_ext1() works as expected (with the pain in that 'ALL_LOW' means only detects when all the buttons are pressed simultaneously...)
pressing the button IO21 during the 30s of sleep interrupts and calls the callback on an ESP32, but has no effect on ESP32S3. So, decided to try with the 'gpio wakeup' feature (which is ok as I am using lightsleep() not deepsleep). This works to exit the lightsleep() when any of the gpio list are pressed! PS >(I also implemented a method fo call esp_sleep_get_gpio_wakeup_status(), but for some reason this function is not available (conditionned by requiring that GPIO can wake from DEEP sleep, even though its for light sleep use...) |
Beta Was this translation helpful? Give feedback.
thanks Peter. It was indeed a ESP32-S3 IDF 4.4 issue.