Is there a way to know if MQTT messages have been sent from the device?

I’m using deep sleep for a battery powered esp32 board. When the device wakes up from sleep, I make sure MQTT is connected, and then I force an update from my sensors. I want to put the device back to sleep as soon as possible, but I also don’t want to lose the sensor updates over MQTT. The only reliable way I have found to do it is to delay a short time before calling the deep sleep enable. If I could know when the MQTT messages were cleared out from the esp32, I wouldn’t have to rely on the short delay.

How about also listening for those mqtt msgs? And then only when they are received again (by the sender) you do deep sleep enable?

Interesting idea, @sj3fk3. I hadn’t been thinking about it in that direction (it could add additional delay, depending on factors outside the device), but it’s probably a pretty good scheme if I can’t find a way to know when the message has drained from the device.


1 Like