cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards
https://cyberman54.github.io/ESP32-Paxcounter/
Other
1.73k stars 405 forks source link

Interrupt on button & internal pullup #691

Closed dragosmacovei closed 3 years ago

dragosmacovei commented 3 years ago

How can I attach to ttgo t-beam a button (with internal pullup (and make it work with an interrupt? e.g count how many times the button was pressed). The problem is that I would like to be able to do this even if the board is sleeping (for example the board is sleeping, you press X times, but it will only use that data - e.g. send it to TTN - only after the board awakes).

cyberman54 commented 3 years ago

If you want to count GPIO changes while in deep sleep, you may use the ULP coprocessor. You could write an ULP routine counting GPIO changes (= button port) while MCU is in deep sleep, and store counter in RTC memory. After wakeup of MCU, read result from RTC memory by MCU and send it to TTN.