I’m trying to set up a ESP32 with four Dallas sensors. I am able to successfully read from all of them, connect the ESP32 to wifi, etc. However, I now want to set it up so that it works well on a battery so I can put it outside in the yard (it’s for a soil temperature monitoring application so I can optimize my garden plantings).
What I really want to do is set up a deep sleep loop. My understanding is that waking up from deep sleep activates the esphome.on_boot trigger, so I could use that in my automation/template. There’s an action (mqtt.publish) that will allow me to post the sensor values to the MQTT broker as well as an action to trigger another round of deep sleep (deep_sleep.enter). However, I cannot find an “action” that let’s me read in each of the temperatures. This is the missing step, then I think I can set up an automation loop that would do:
Wake up from deep sleep
Read in each of the temperature sensor values
Post to MQTT
Check to see if an OTA update is pending
Check the time to determine when the next boot time should be (so that we can poll the temperature sensor at regular intervals)
Enter deep sleep for the calculated time.
Is this feasible? How would I read in the temperature sensor values on my own schedule rather than what’s defined in the sensor library?
So, I found out that I don’t need to do anything fancy. The moment I added the MQTT integration and the sensors, the Dallas sensors gets scanned on boot and updated values are read in. Then, when MQTT launches, it automatically posts the values. Keeping the device on for 1 second seems to be enough for everything to boot up, read in sensors, send the MQTT messages, then it will sleep for 10 minutes. Nice and simple.
I still need to add a flag so that I can prevent deep sleep when I want an OTA update.