Hackuarium / esp32-c3

0 stars 1 forks source link

Create switch between sleep and "live" modes #5

Open oliemery opened 2 years ago

oliemery commented 2 years ago

Sleep was implemented after sending measurements through MQTT to save battery (measurements every 5min with sleep in between). This also allows to fully charge the NCR18650B (up to 4.12V) with the solar panel/charger (without sleep, the battery could only be charged at a max of 3.8V even in full sun, presumably because the current drawn for WiFi limits the current to charge the battery; Charging using a USB charger did allow to reach 4.12V). However when in sleep, it is not possible to interact with the ESP32-c3 through the serial commands / MQTT requests except if doing it exactly when the ESP32 wakes up briefly to connect and send measurements. Ideally the switch should be in node red, allowing to go to "live" mode (no sleep) at the next wake up, with a maximum period of inactivity set before returning to sleep mode to avoid battery drain by permanent live mode (without charging and full battery, the system lasted 39h42 min).

lpatiny commented 2 years ago

Need to think about the best way to implement sleep because adding it in MQTT task does not seem general enough.

It should only be placed at this level: https://github.com/Hackuarium/esp32-c3/blob/0df1009eef6c07042cc82bab5f73fd8ead57a6f4/src/main.cpp#L34-L37