Hello, I'm trying to count incoming pulses with ESP32 and micropython.
The idea is to measure current rainfall and rain quantity. I don't have the hardware for the rain measurement at the moment, but a colleague made some adjustments to simulate it - a button that could be pressed manually. At the moment I'm able to detect when the button is pressed and what I would want to do next is to detect if the button (and how many times) is being pressed while the device has been in deep sleep. I'm not sure if it is possible at all and I would be thankful for some pointers on where and how to search for such a thing.
Please, keep in mind, that the hardware part of this whole project is not my strength and I'm just programming the device and learning about it on the go.
Detecting and counting pulses while in deep sleep
-
- Posts: 1
- Joined: Mon Aug 01, 2022 7:41 am
Re: Detecting and counting pulses while in deep sleep
If you want to count while sleeping, you will need to use the ULP coprocessor.
See e.g. viewtopic.php?f=18&t=7440 for links about the ULP.
See e.g. viewtopic.php?f=18&t=7440 for links about the ULP.
A few hours of debugging might save you from minutes of reading the documentation!
My repositories: https://github.com/karfas
My repositories: https://github.com/karfas
-
- Posts: 169
- Joined: Fri Aug 19, 2016 11:55 am
Re: Detecting and counting pulses while in deep sleep
Also, if you want to wake up the main CPU from the ULP, you will need to use a nightly build of MicroPython, as that ability was added after the current 1.19.1 release.
Re: Detecting and counting pulses while in deep sleep
There is an example of using ULP to count pulses here:
https://github.com/espressif/esp-idf/tr ... lp_fsm/ulp
And it might be nice to know that there exists a Micropython ULP compiler:
https://github.com/micropython/micropython-esp32-ulp
https://github.com/espressif/esp-idf/tr ... lp_fsm/ulp
And it might be nice to know that there exists a Micropython ULP compiler:
https://github.com/micropython/micropython-esp32-ulp
Re: Detecting and counting pulses while in deep sleep
https://gist.github.com/wnienhaus/56c53 ... a43ab7ddf8
Took me a while to figure out the ins & outs of running ulp code inside a .py but the gent behind the idea was very supportive, not a hint of the bruising side serve of opinion that you sometimes get when seeking guidance on some forums.
Took me a while to figure out the ins & outs of running ulp code inside a .py but the gent behind the idea was very supportive, not a hint of the bruising side serve of opinion that you sometimes get when seeking guidance on some forums.