What’s your average time to connect to a Wifi in station mode with your esp8266?
I have been profiling my DHT22-based sensor node. Most of the time (~2s) is spent on connecting to the AP. Data acquisition itself takes around 275ms. Publishing the data (including the timing metrics) takes about 200ms as well.
What are your figures here? I already got it down from 4s to 2s by using a static IP.
Other things I have tried, which helped only marginally at best:
I suspect the AP is causing the delay. I use ESP-01s and the AT command set. Mine connect in a second or less. I haven’t measured it, though. From a terminal at 9600 baud, the connected response is almost immediate.
The spikes around 7:30 are caused by me moving the node to the office for experimentation… I will be able to see if I actually made it worse this evening
@Michael_Haas No. Once you receive the “connected” string, it’s really connected to the AP. Then, in my case, I have to send more commands to put it into the mode I want so I can send and receive UDP packets.
I have read about this before, when you wake from deep sleep you do not need to reinitialise all of the wifi settings, if you do so you suffer a couple of seconds delay. One of the setup/status functions lets you know you can skip a load of the rest of it. sorry, i dont remember the detail beyond that, but hopefully it will help you find it.
@Justin_Mitchell It stores settings in NVM if you use the AT command to set it. My design cuts power completely to peripherals. Only the PIC remains powered. Using the presets speeds things up a lot. In fact, I set my esp-01’s to connect automatically on powerup and it happens very fast.
Thanks everyone for their input! I believe I am doing everything right - I use a static IP and the ESP is set to auto-connect on boot. I have disabled the explicit channel setting on start as I’m afraid that might slow things down (perhaps reset the connection?). Other than that, I have bumped up the sleep interval… it could be possible that the AP does not like repeated quick reconnects from the same source.
Anyways, with today’s settings (before the changes I just indicated), I am averaging 2s per cycle.
I am not talking about the AT command firmware, but about writing for the bare hardware using the sdk or arduino environments. imho the using the AT firmware is a waste of an otherwise pretty powerful microcontroller, but anyway, found a bit more reference on the reconnect time after deep-sleep, it seems you should carefully check the results of WiFi.status() BEFORE doing a WiFiClient.connect() as doing that connect on an already connected device will give you a second or two penalty and may not be necessary