user38469: With my ESP8266, I need to make a simple GET request to a server, and then go to deep sleep (the goal is 1 year battery powered)... until a signal comes on RST and then it starts again.
The following code works, but it takes 6 to 10 seconds on each RST to get connected to my home WiFi using "WPA2 Personal" (when it stops blinking in my code).
Is this 6 to 10 seconds delay normal, do you have the same order of magnitude? Or can we go down to 1 second, after a wake-up from deep sleep?
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266HTTPClient.h>
WiFiClient client;
HTTPClient http;
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    if (WiFi.SSID() != WIFI_SSID) {     // don't do begin if not necessary, see tutorial link after
        WiFi.begin("MySSID", "MyPassword");
        WiFi.persistent(true);
        WiFi.setAutoConnect(true);
        WiFi.setAutoReconnect(true);
    }
    while(WiFi.status() != WL_CONNECTED) {
      digitalWrite(LED_BUILTIN, LOW); delay(10); digitalWrite(LED_BUILTIN, HIGH); delay(200);  // blinking
    }
    http.begin(client, "http://example.com/request.php");
    http.GET();
    http.end();
    digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HIGH); delay(500);    
    ESP.deepSleep(0);
}
void loop() {
}

Note: I have read and carefully respected this useful information about low power / battery-powered ESP8266:
Power Saving tips for the ESP8266  (especially this paragraph):

Do not call WiFi.begin() in setup().
The ESP8266 chip saves the last known wifi settings. Calling WiFi.begin() wipes those out. By calling WiFi.begin() only when it was needed, I shaved more than 2 seconds from the average amount of time it takes to associate with the AP. WiFi.begin() should be called only if the saved SSID does not match the configured SSID. You can check the configured SSID with the WiFi.SSID() call. Also, it is good practice to clear the saved WiFi settings if the timer expires. (See next section "Use watchdog timers")


user40646: It is in general take around 6s for the ESP to scan all the 2.4GHz Wi-Fi channels to find the SSID and the associated BSSID (i.e. Mac Address), you can eliminate the scanning time by connecting using BSSID.
Using a static IP instead of rely on DHCP server to assign an IP would further reduce the WiFi connecting time by another 500ms.
See one of my project (under the "ESP8266 WiFi - How to speed up connection" section) where I cut the connection time from 6s down to about 2s.
Code signature for WiFi.begin with BSSID here:
    const byte WIFI_BSSID[] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC};
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD, 0, WIFI_BSSID);

For calculating IoT battery consultion, use IoT battery life calculator.

38469: <p>With my ESP8266, I need to make a simple GET request to a server, and then go to deep sleep (the goal is 1 year battery powered)... until a signal comes on <code>RST</code> and then it starts again.</p>
<p>The following code works, but <strong>it takes 6 to 10 seconds on each <code>RST</code> to get connected to my home WiFi using &quot;WPA2 Personal&quot;</strong> (when it stops blinking in my code).</p>
<p><strong>Is this 6 to 10 seconds delay normal, do you have the same order of magnitude?</strong> Or can we go down to 1 second, after a wake-up from deep sleep?</p>
<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266HTTPClient.h&gt;
WiFiClient client;
HTTPClient http;
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    if (WiFi.SSID() != WIFI_SSID) {     // don't do begin if not necessary, see tutorial link after
        WiFi.begin(&quot;MySSID&quot;, &quot;MyPassword&quot;);
        WiFi.persistent(true);
        WiFi.setAutoConnect(true);
        WiFi.setAutoReconnect(true);
    }
    while(WiFi.status() != WL_CONNECTED) {
      digitalWrite(LED_BUILTIN, LOW); delay(10); digitalWrite(LED_BUILTIN, HIGH); delay(200);  // blinking
    }
    http.begin(client, &quot;http://example.com/request.php&quot;);
    http.GET();
    http.end();
    digitalWrite(LED_BUILTIN, LOW); delay(500); digitalWrite(LED_BUILTIN, HIGH); delay(500);    
    ESP.deepSleep(0);
}
void loop() {
}
</code></pre>
<p>Note: I have read and carefully respected this useful information about low power / battery-powered ESP8266:<br />
<a href="https://github.com/z2amiller/sensorboard/blob/master/PowerSaving.md" rel="nofollow noreferrer">Power Saving tips for the ESP8266</a>  (especially this <a href="https://github.com/z2amiller/sensorboard/blob/master/PowerSaving.md#do-not-call-wifibegin-in-setup" rel="nofollow noreferrer">paragraph</a>):</p>
<blockquote>
<p>Do not call WiFi.begin() in setup().<br />
The ESP8266 chip saves the last known wifi settings. Calling WiFi.begin() wipes those out. By calling WiFi.begin() only when it was needed, I shaved more than 2 seconds from the average amount of time it takes to associate with the AP. WiFi.begin() should be called only if the saved SSID does not match the configured SSID. You can check the configured SSID with the WiFi.SSID() call. Also, it is good practice to clear the saved WiFi settings if the timer expires. (See next section &quot;Use watchdog timers&quot;)</p>
</blockquote>
 40646: <p>It is in general take around 6s for the ESP to scan all the 2.4GHz Wi-Fi channels to find the SSID and the associated BSSID (i.e. Mac Address), you can eliminate the scanning time by connecting using BSSID.</p>
<p>Using a static IP instead of rely on DHCP server to assign an IP would further reduce the WiFi connecting time by another 500ms.</p>
<p>See one of my <a href="https://www.e-tinkers.com/2022/04/esp8266-ntp-clock-with-ntp-update-and-charlieplexing/" rel="nofollow noreferrer">project</a> (under the &quot;ESP8266 WiFi - How to speed up connection&quot; section) where I cut the connection time from 6s down to about 2s.</p>
<p>Code signature for WiFi.begin with BSSID <a href="https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h#L38-L39" rel="nofollow noreferrer">here</a>:</p>
<pre><code>    const byte WIFI_BSSID[] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC};
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD, 0, WIFI_BSSID);
</code></pre>
<p>For calculating IoT battery consultion, use <a href="https://www.of-things.de/battery-life-calculator.php" rel="nofollow noreferrer">IoT battery life calculator</a>.</p>
