Page 1 of 1

ESP-32 Deep Sleep MQTT

Posted: Wed Dec 06, 2023 5:36 pm
by eric84430
Hi everybody,
First, thanks for the lot of contributions which helped me !
Please, I've got (perhaps a stupid) question :

I use ESP to read an DHT22 sensor and publish values onto MQTT topics (standalone mosquitto broquer)
My lan config uses a dhcp.
And I want to use deep sleep to make some tries for a battery supplyed hardware.
I know that after "awaking", the ESP restart from zero and execute void setup() (which also contains the esp_deep_sleep_start())

My question is : are the endless connectig and deconnecting (to dhcp and MQTT broque) requests dangerous for the mqtt broker or the dhcp of my box (I'm affraid, perhaps of some overflow somewher) ?
And second question : is this method of connecting every minutes for some seconds a "normal" usage of the deep sleep functionnality ?

Many thanks
Eric

Re: ESP-32 Deep Sleep MQTT

Posted: Thu Dec 07, 2023 1:08 am
by MicroController
eric84430 wrote:
Wed Dec 06, 2023 5:36 pm
My question is : are the endless connectig and deconnecting (to dhcp and MQTT broque) requests dangerous for the mqtt broker or the dhcp of my box (I'm affraid, perhaps of some overflow somewher) ?
Not a problem at all.
If you want to be extra nice, you can cleanly disconnect from the MQTT broker before turning off WiFi/going to sleep. Then the broker can immediately release/reuse the resources associated with your connection instad of waiting for a timeout on a keep-alive which never arrives.
And second question : is this method of connecting every minutes for some seconds a "normal" usage of the deep sleep functionnality ?
Yes, that's a common/normal scenario and probably as energy-efficient as it gets if you have to use WiFi. (Depends on the wake-up interval. If you shorten it, at some point it becomes more efficient to stay up in modem-sleep instead of wasting seconds of WiFi power to reconnect to the AP each time.)

Re: ESP-32 Deep Sleep MQTT

Posted: Sat Dec 09, 2023 8:20 am
by eric84430
Thank you very much ...
This answer was verry clear and that helped me a lot !
:P