<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[M5Paper: can&#x27;t reconnect to WiFi after &#x27;esp_light_sleep&#x27; (on power)]]></title><description><![CDATA[<p dir="auto">I'm working on an app for M5Paper which will spend most of it's time asleep or shutdown; waking every few hours to check data from the internet (and depending on the results, either update the display or don't).</p>
<p dir="auto">So the loop function attempts to connect to WiFi and load the data, then disconnects; then either updates the display or doesn't; then attempts to shutdown. If the M5paper is on power, then the <code>M5.shutdown</code> command has no effect, so the code then calls <code>esp_light_sleep_start</code>.</p>
<p dir="auto">When it wakes up, if the unit is on battery (so it's a complete start-up) it all works as normal. If it is on power (so it's just resuming after 'light sleep') then it fails to connect to WiFi.</p>
<p dir="auto">If I replace the call to <code>esp_light_sleep_start</code> with a call to <code>delay</code> for the same period,  then it connects repeatedly without issue.</p>
<p dir="auto">A summary of the code (this is using the WiFiMulti (ESP8266WiFiMulti) library by Markus Sattler, dated 16.05.2015, to support working across several locations with different WiFi availability):</p>
<pre><code>WiFiMulti wifiMulti;

boolean connectToWifi()
{
  uint8_t tRes;

  for (int i = 0; i &lt; NUMWIFINETWORKS; i++) {
    wifiMulti.addAP(aWifiNetworks[i], aWifiPasswords[i]);
  }

  Serial.printf("Connecting Wifi... trying %d networks\n", NUMWIFINETWORKS);
  if ((tRes = wifiMulti.run()) == WL_CONNECTED) {
    Serial.print("WiFi connected ");
    Serial.println(WiFi.SSID());
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
    return true;
  } else {
    Serial.printf("Failed to connnect to WiFi: %d.\n", tRes);
  }

  return false;
}

void disconnectFromWifi()
{
  Serial.println("disconnecting from WiFi");
  WiFi.disconnect();
}
</code></pre>
<p dir="auto">Evidently something in the course of <code>esp_light_sleep_start</code> 'breaks' something that the WiFi needs, so I need to reset it. But I don't know what, or how I can reset it!</p>
<p dir="auto">Can anyone shed any light?</p>
]]></description><link>https://community.m5stack.com/topic/5206/m5paper-can-t-reconnect-to-wifi-after-esp_light_sleep-on-power</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 19:36:21 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5206.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Apr 2023 14:55:17 GMT</pubDate><ttl>60</ttl></channel></rss>