Replies: 4 comments 2 replies
-
Just a note: Please enclose the whole code in lines with THREE backticks ```. Otherwise the code is not readable. |
Beta Was this translation helpful? Give feedback.
-
Did you try using interrupts, but from #9759 it seems that missing counts still occur , in #3775 there is some explanation , but maybe using both rising and falling edge could provide some redundancy. there is machine counter implemented in miropython https://micropython-tve.readthedocs.io/en/counter/library/machine.Counter.html but seems not to be available for ESP82 (even on my esp32 ( mpy ver v1.19.1) is not available. but https://github.com/tve/mpy-lib/tree/master/esp32-counter impelents (for esp32) PCNT maybe can be adapted. |
Beta Was this translation helpful? Give feedback.
-
My best guess is that something in the networking code (either wifi management or mqtt) is blocking, preventing your pin checks from running. I'm also curious how you were able to confirm the missing pulses? Another thing to consider would be to move the pin checking into its own dedicated thread. |
Beta Was this translation helpful? Give feedback.
-
@macraj You have told us the pulse frequency, but what is its length? @jimmo Assuming the official MQTT library the |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to make a gas counter. It is a simple code that reads pulses from a GPIO pin ( pulses are 4 seconds min to several hours max ), increments the counter and sends it periodically via MQTT. The problem is that it loses pulses (about 2%) for no reason. I checked the pulse readings on the Arduino, Uno are fine. The connection to the MQTT server is also ok, the wifi does not restart. I am puzzled how this code can not work. Could it be that Micropython or esp is doing something in the background and resetting the memory ? But the counter is preserved except for a few missing pulses. If anyone has any idea what could be the cause please give me a hint.
Beta Was this translation helpful? Give feedback.
All reactions