Need some help on running ESP8266 Huzzah on 3 AA batteries (schematic advice?)
Posted: Wed Oct 11, 2023 9:35 pm
I'm working on a "door sensor" project, using an ESP8266 Huzzah breakout. Here's the gist of the setup function:
BASIC SETUP/CHECKS (on every boot):
* set up serial
* read RTC state (5 variables)
* if no state found, try reading config from a JSON "file" (using the old? FS.h)
* if still no state, start a web portal (using WiFiManager) to get the values + wifi credentials. This will cause a reboot
* check if a "sensor" is connected (by checking if GPIO2 is high). If it is low, start web portal ("please connect a sensor"). This will cause a reboot
* if "sensor type" is missing (from state/config), try to detect it by "timing" the RC circuit comprised of C2 and R8 (millis to charge C2 until GPIO2 reads as HIGH)
SENSOR CHECK
* read battery level (ADC, analogRead)
* increase boot counter, and save RTC state
* read "sensor" inputs (i.e. GPIO4 and GPIO5)
* if values (HIGH/LOW) are the same as previous values (from state found above) then DEEP SLEEP 1 second: reboot
REPORT (one/both values different)
* connect to wifi (WiFiManager)
* create one or two POST requests for the changed value(s) and send to API
* save RTC state (new "previous" values)
* DEEP SLEEP 1 second
Deep sleep is used to save battery, as the idea is to try to run this circuit on 3 AA batteries (standard alkaline, household batteries) in series. These should give something within the range of 3 - 4.5V, and the minimum required voltage for the ESP8266 Huzzah seems to be 3.3V. Otherwise, the setup is configured such as to avoid having to connect to WiFi until something actually needs reporting (logging to API) -- again, to save battery, as the ESP draws more current when WiFi is on. In my use case, an "event" (i.e. door opening or closing) might only happen once a day, so not connecting to WiFi saves both time and power.
However, is my design for this circuit good enough? I'm not happy with the battery life of this setup; even with the above mentioned measures (deep sleep, and holding back on the wifi) the VARTA batteries only lasted a couple of weeks. The voltage has now dropped below 3.3V, at which point the Huzzah fails to boot. I've verified that the Huzzah by itself -- taken out of my circuit -- does indeed fail to boot at 3.19V, so this does not appear to be caused by something other than low power.
Please have a look at my schematic, and let me know if something is odd, bad, or just wrong.
BASIC SETUP/CHECKS (on every boot):
* set up serial
* read RTC state (5 variables)
* if no state found, try reading config from a JSON "file" (using the old? FS.h)
* if still no state, start a web portal (using WiFiManager) to get the values + wifi credentials. This will cause a reboot
* check if a "sensor" is connected (by checking if GPIO2 is high). If it is low, start web portal ("please connect a sensor"). This will cause a reboot
* if "sensor type" is missing (from state/config), try to detect it by "timing" the RC circuit comprised of C2 and R8 (millis to charge C2 until GPIO2 reads as HIGH)
SENSOR CHECK
* read battery level (ADC, analogRead)
* increase boot counter, and save RTC state
* read "sensor" inputs (i.e. GPIO4 and GPIO5)
* if values (HIGH/LOW) are the same as previous values (from state found above) then DEEP SLEEP 1 second: reboot
REPORT (one/both values different)
* connect to wifi (WiFiManager)
* create one or two POST requests for the changed value(s) and send to API
* save RTC state (new "previous" values)
* DEEP SLEEP 1 second
Deep sleep is used to save battery, as the idea is to try to run this circuit on 3 AA batteries (standard alkaline, household batteries) in series. These should give something within the range of 3 - 4.5V, and the minimum required voltage for the ESP8266 Huzzah seems to be 3.3V. Otherwise, the setup is configured such as to avoid having to connect to WiFi until something actually needs reporting (logging to API) -- again, to save battery, as the ESP draws more current when WiFi is on. In my use case, an "event" (i.e. door opening or closing) might only happen once a day, so not connecting to WiFi saves both time and power.
However, is my design for this circuit good enough? I'm not happy with the battery life of this setup; even with the above mentioned measures (deep sleep, and holding back on the wifi) the VARTA batteries only lasted a couple of weeks. The voltage has now dropped below 3.3V, at which point the Huzzah fails to boot. I've verified that the Huzzah by itself -- taken out of my circuit -- does indeed fail to boot at 3.19V, so this does not appear to be caused by something other than low power.
Please have a look at my schematic, and let me know if something is odd, bad, or just wrong.