Hello, may I ask for advice please? I have analog ESPHome sensor, mostly in deep sleep. I need it to wake it from time to time, check value and only if the value is outside certain range, THEN connect to wifi and send mqtt message. I do not waste battery by sending acceptable values. Example is the water level or temperature etc. I think I should use sensor.in_range statement in ESPHome configuration, but how to trigger wifi connection only if that condition is true? In all examples I found the sensor connects to wifi every time after deep sleep wakeup.
Really? When I look at the log, on the ESPHome on boot looks at the sensor and then connects to wifi. Can it look at the sensor and if value is in range then go to deep_sleep immediatly without continuing to wifi?
Can the ESPHome run custom C code as lambda? In that code it could either return value of the sensor and it would then continue to wifi, or in lambda code there would be ESP.deepSleep command. Would that work?
I got the correct syntax, but unfortunately this does not result into ESP going to deep sleep, but reboots immediately (I think due to WiFi loss) and goes into boot loop until secure boot. I would really like ESP to go to deep sleep and reboot after it.
Hello, I have found the solution. You can add a condition with sensor value and based on the condition the ESP can either go to deep sleep immediately, or will continue, connect to wifi and send mqtt message. On first loop the sensor state is already knows, so you can check condition on loop:
Anyone found a solution to this?
It’s really bad that we cannot let the CPU to choose if connect to wifi or not based on the sensor reading. This will help, on some devices like temperature/humidity sensor, to spare A LOT of battery life.
I have a custom temp/humidity sensor that goes in sleep cycles for 30 minutes, then awakens for 20 seconds, connects to wifi and send the reading, but lookin at my data logs, I noticed that, mostly during the day, my temp stays almost the same, or in a range of 0.5*C difference, for 4-5 hours or even more! Just when I switch on my heaters some one is cooking, the temp changes more quickly.
I tried to made an estimate based on my usage, and I found that, if a “conditional” connection would be possible, I could avoid connecting and sending data for about 80 times in a day, saving a lot of battery life!