The use of the ESP8266 in the world of IoT

User avatar
By btidey
#92711 I ran the following test on my dev set up just to see what the start up time could be. I didn't add in deep sleep or anything else at this stage.

The test was done using the feature fast_connect WifiManager library
https://github.com/tzapu/WiFiManager/tr ... astconnect

and my basic app shell library BaseSupport which I use in all my applictions
https://github.com/roberttidey/BaseSupport

This requires a BaseConfig.h in the app to configure the options in the support library. The #define FASTCONNECT must be uncommented to enable this feature.

I then used a minimal sketch to measure timings. To keep things simple I used a GPIO input to determine whether wifi was on or off. The sketch uses this to control the variable setupWifi to determine whether Wifi is on or off. So I can perform resets in a controlled fashion with wifi on or off.

Code: Select all//test
#include "BaseConfig.h"

void setupStart() {
   pinMode(13,INPUT_PULLUP);
   if(digitalRead(13) == 0) {
      setupWifi = 0;
   } else {
      setupWifi = 1;
   }
   Serial.println("Start ms: " + String(millis()));
}
void setupEnd() {
   Serial.println("End ms: " + String(millis()));
}
void loop() {
}


The sketch measure the time when it first gets going and when the setup is complete and normal loop processing can start. Obviously the ESP8266 is boot time is not included and would typically be about 300mS.

When the wifi is enabled I see a start-end elapsed time of 200mS. When I disable wifi I see a start-end elapsed time of about 1mS or less. I can perform multiple no wifi start ups and then follow up with a wifi and still get elapsed time of 200mS.

This indicates that it is possible to mix the wifi on and off without affecting the fast connect time. In overall timing adding in the typical boot these would give a 500mS start up with wifi and 300mS with no wifi.

Now it is possible that the deep sleep operation is behaving differently somehow. I'll try some further experiments if I get a chance.
User avatar
By ArjenV
#95282 Today I picked up this project again (summer is over...) I am still puzzled. When I do a deepsleep cycle, read a sensor and then connect to my modem I get a quick connection (some 1200msec). When I do a deepsleep cycle, just read the sensor and skip the modem the first time to cycle a 2nd deepsleep and then try to connect to my modem it will not quick connect. It then takes some 9000msec to connect.

I hope someone can help me with this issue. I am running out of ideas..... :(
User avatar
By zenor
#95366
ArjenV wrote:Today I picked up this project again (summer is over...) I am still puzzled. When I do a deepsleep cycle, read a sensor and then connect to my modem I get a quick connection (some 1200msec). When I do a deepsleep cycle, just read the sensor and skip the modem the first time to cycle a 2nd deepsleep and then try to connect to my modem it will not quick connect. It then takes some 9000msec to connect.

I hope someone can help me with this issue. I am running out of ideas..... :(

Hi, I was able to reproduce described issue (thanks for the code btw, this is exactly what I need). I solved this by invoking WiFi.forceSleepWake() just before I call deepSleep, regardless whether you connecting to wifi or not. i.e. something like this

Code: Select all  if(wakupCounter == 0){
    Serial.println("Going to connect and send data");
  }else{
    Serial.println("Skip connect, going back to sleep");

    WiFi.forceSleepWake();
    delay( 1 );   
 
    ESP.deepSleep(SLEEPTIME, WAKE_RF_DISABLED);
    return;
  }


Without WiFi.forceSleepWake() I get the same long connect you described, if I skip one round
User avatar
By ArjenV
#95380 Interesting. But I wonder whether the WIFI is not triggered ON in that case (and off again with the deepsleep, wasting a few joules every time.
I managed to solve it with another RF-form in the deepsleep command: WAKE_RF_DEFAULT

I collect 12 measures during one hour i.e. every 5 minutes. When the count is 11 I change the deepsleep command. A (byte) variable rtcData.wakeup in the structure keeps track of the command:

(so if wakeup=1, the next cycle will send data through WIFI, if wakeup=0 it will only collect data the next cycle)

Code: Select all    if (rtcData.wakeup) {
      Serial.println("deepsleep with default");
      ESP.deepSleep( SLEEPTIME, WAKE_RF_DEFAULT);
    }
    else {
      Serial.println("deepsleep with disabled");
      ESP.deepSleep( SLEEPTIME, WAKE_RF_DISABLED);
    }