So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By ezcGman
#88335 So first: Thanks for all the explanation about the EN pin and its functions and how to wire it up! I didn't quote the whole block here now, but thanks!
I finally did some testing with your suggestions and wired a spare ESP I had according to it. My findings:

btidey wrote:Yes. Wifi connection is not maintained in deep sleep. So it has to reconnect when it wakes up. This does take about 3 seconds normally so the overall wake active time is normally about 1 second longer as you perform an action like mqtt. You can reduce the 3 seconds quite a bit if you are prepared to set the ip address locally on the esp8266 instead of using dhcp for auto ip allocation as that does take quite a large slice of this 3 seconds.

Yeah, I can see Wi-Fi taking around 3-4 seconds, even with setting a static IP. It doesn't actually make a (noticeable) difference if I use DHCP or Static IP.
I see you using another Wi-Fi lib than me. I'm using the standard ESP8266WiFi.h. Not sure if it would make a huge difference if I switch to the lib you're using :/
The MQTT though is pretty fast: MQTT connection is definitely below 1s and sending the actual message is really just milliseconds.
So in total I end up at 4-4.5 seconds after somebody rang the doorbell, which is quite a long time, imho... That's more than 50% it usually takes me to go to the door ;)

So if I can't speed up the Wi-Fi connection, I think deep sleep is probably not the solution for me :(

Is it correct that there is no sleep mode that keeps the Wi-Fi connection? Or better: I really didn't understand the modem sleep fully: I understood it in a way, that it always wakes up on the Wi-Fi beacon interval, so every time a beacon is sent by the AP it wakes up.
So it seems to keep the Wi-Fi connection!?? Could I use the same trick with the wake up on EN here, too? It would basically mean, that the ESP wakes up
a) Every beacon interval
b) Poor person in the rain, ringing the doorbell :)

Or is the wake up on EN not possible here?

Thanks again!
User avatar
By btidey
#88358 Deep sleep is the only way you get really low current for extended battery life. EN Wake up is only relevant to deep sleep.

Although the other sleep modes can reduce current, the draw will still be a big drain on the battery.

There are various techniques to reduce wifi connect time.The most significant are avoiding scan to get rf channel, setting the mac address of the router, and using static ip.

See https://pokewithastick.net/esp8266-fast ... nnect-post

This gets the time down to around 500mSec although it will vary a bit dependent on the router.

Getting the time as small as possible is good for your response time but also maximises battery life as the time spent active is lower.
User avatar
By davydnorris
#88360 Agree with btidey - if you are connecting to the same wifi router each time then you can drastically speed up connect time by supplying the channel and MAC address during connect. I don't know if the standard Arduino library does this or not but I do it in the NonOS SDK and it's made a huge difference.

https://www.esp8266.com/viewtopic.php?f=166&t=19436
User avatar
By btidey
#88374 Yes, it can be done in Arduino IDE as well. The example given was in this environment.

The version of WiFi.begin(ssid, password, channel, home_mac, true);

supports the channel and mac address.

I have just started looking at whether this can be automated a bit further and integrated / wrapped with wifimanager. I.e. try quick connect but if that fails fall back to wifimanager and then refresh channel and mac address settings.