The use of the ESP8266 in the world of IoT

User avatar
By sej7278
#45658 you can set a static ip easily in setup(), i've certainly never seen 6secs to associate, so maybe it is a dhcp problem

Code: Select allWiFi.begin("ssid", "password");

// static ip, gateway, netmask
WiFi.config(IPAddress(192, 168, 1, 2), IPAddress(192, 168, 1, 1), IPAddress(255, 255, 255, 0));
User avatar
By UrsEppenberger
#45987
erbedo wrote:Hi, I have a small project in which an ESP-12 wakes up from deep sleep every 30 minutes, polls an hygrometers and reports the data to a local server...
The code is simple, I simply wakeup, connect to the network, and send an HTTP request to the server, then go back to sleep. My guess is that the major consumption is when the ESP is trying to get the IP from the DHCP server, which takes considerable time. I'm wondering if I could put the IP as static, and just associate with the WLAN.

I'm working on the same topic. I use ESP-201 with one 18650 battery, and the arduino IDE for programming.
I measured the time needed for WiFi connection, DHCP, TCP connection. You can't do anything about the WiFi connection time. And yes, I used static IP to circumvent the long DHCP setup time. For this you have to configure the IP address in your router, based on the MAC address of your ESP8266. Currently I'm trying to use UDP to get rid of the TCP setup time. It's not working yet.
User avatar
By tom6870
#46025 Hi,

I have the similar question. According to the document, it should take less than 0.3 to 1 second to connect AP from deep sleep mode:

http://bbs.espressif.com/viewtopic.php?t=133

I don't know it takes 6 seconds to associate in real case. Something must be wrong. Looking for suggestions to reduce the wakeup AP time. This will greatly reduce the power consumption.

Thanks,

Tom
User avatar
By bbx10node
#46027 Perhaps there is something wrong with your AP/WiFi router. Have your tried a different AP/WiFi router?

How are you measuring the 6 second AP connect time? Can you post code showing how the connect time is measured?

I tried printing the value returned by millis() at various points and this is what I get.

    At the start of setup(), millis() returns about 300 ms. This is the time from reset to the start of the setup() function.
    After WiFi.begin(...), millis() returns about 1600 ms so connect time is about 1.3 seconds or 1.6 seconds from reset. This is using DHCP.