Need to improve battery life of my ESP8266 temp hum sensor
Posted: Fri Jul 07, 2023 8:24 am
Continuation of thread previously on esp8266.com
MQTT should be able to report sensor values in 1 second after wifi connection is made after wake up. Normal default wifi connection is about 3 seconds but can be reduced to about 1 second by fast connect methods. There are details of using mqtt in EspHome documentation.
25 seconds to make a connection sounds very bad. I'm not familiar with EspHome to know if that is normal. You first need to know where these delays are. Is it in making wifi connection, or some espHome initialisation?I don't use EspHome myself but looking at documentation it would look like the run_duration in the config means that it will re-enter deep sleep 30 seconds after waking up. As you are waking up to measure and report every 10 minutes this means the esp8266 is awake for 5% of the time. Assuming 80mA current consumption while it is awake this would give an average consumption of 4mA. That will drain your battery in about 550 hours.
To get much better battery life you need to reduce the duty cycle of the wake to sleep time. Does it really need to be awake for 30 seconds to take the measurement and report it? If for example, you can reduce that to 5 seconds then you will reduce your average current by 6 times and get 6 times longer battery life.
Ignoring ESPHome for the moment it is possible to do a fast wifi connect, take a measurement, and report it in under 2 seconds which would give over a year of operation.It takes about 20-25 seconds for home assistant connection. Should i be using mqtt to report in 2 seconds? What is the method?
MQTT should be able to report sensor values in 1 second after wifi connection is made after wake up. Normal default wifi connection is about 3 seconds but can be reduced to about 1 second by fast connect methods. There are details of using mqtt in EspHome documentation.