vladak / shield

code for ESP32 Adafruit Feather to get various sensor readings and publish them to MQTT broker
2 stars 0 forks source link

consider using more precise time in enter_sleep() #22

Closed vladak closed 6 months ago

vladak commented 6 months ago

The enter_sleep() uses the imprecise time.monotonic(). Consider using something like time.monotonic_ns() // 1_000_000_000 instead. This might have contributed to the "internal watchdog timeout" issue seen with CP 9.0.0.

vladak commented 6 months ago

Before this is done, it might be useful to try running the code multiple times and try to measure the time between the initial start and the time of the safe mode entry due to the internal watchdog timer, ideally with higher precision (minutes/seconds).

To do this reliably, the code that shortens the period based on the battery capacity will have to be disabled.

vladak commented 6 months ago

Looks like the time.monotonic() gets reset on deep sleep (changed the code to publish both the time.monotonic() and time.monotonic_ns() to the MQTT topic and made sure to disconnect the board from USB and performed a reset), so this is likely a false trace.