ESP-32 Deep Sleep MQTT

eric84430
Posts: 2
Joined: Wed Dec 06, 2023 5:23 pm

ESP-32 Deep Sleep MQTT

Postby eric84430 » Wed Dec 06, 2023 5:36 pm

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

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP-32 Deep Sleep MQTT

Postby MicroController » Thu Dec 07, 2023 1:08 am

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.)

eric84430
Posts: 2
Joined: Wed Dec 06, 2023 5:23 pm

Re: ESP-32 Deep Sleep MQTT

Postby eric84430 » Sat Dec 09, 2023 8:20 am

Thank you very much ...
This answer was verry clear and that helped me a lot !
:P

Who is online

Users browsing this forum: No registered users and 132 guests