This time with WiFi On. Using Arduino IDE rather than lua.
I failed to do the simplest test so far. Using a Wemos D1 Mini.
#include <ESP8266WiFi.h>
#define TIME_PIN 13 // D7=GPIO13
#define SLEEP_MS 500
static void do_stuff()
{
byte status;
Serial.begin(115200);
Serial.println("");
WiFi.begin("ssid", "pass");
byte i = 10; // 5 seconds timeout
while ((status = WiFi.status()) != WL_CONNECTED) {
delay(500);
Serial.print(status);
if (--i <= 0) {
Serial.println(" no WiFi");
return;
}
}
Serial.println(" have WiFi");
}
void setup() {
pinMode(TIME_PIN, OUTPUT);
digitalWrite(TIME_PIN, LOW);
do_stuff();
digitalWrite(TIME_PIN, HIGH);
delay(1);
digitalWrite(TIME_PIN, LOW);
// WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED
ESP.deepSleep(SLEEP_MS*1000, WAKE_RF_DEFAULT);
}
void loop() {
// sleeping so wont get here
}
The TIME_PIN
is used to mark the start and end of the program.
All I get is a repetition of
0000000000 no WiFi
with the occasional crash:
0000000000000
Exception (0):
epc1=0x40217a7f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: sys
sp: 3ffff670 end: 3fffffb0 offset: 01a0
>>>stack>>>
3ffff810: 40104c21 40104c1e 00000000 00000001
3ffff820: 400005e1 92104ba0 00000000 00006a4e
3ffff830: 40217a7f 00000033 0000001b ffffffff
.... many more of this
3fffff70: 3ffec530 3ffe9370 3fffdcc0 3ffe8b00
3fffff80: 00000040 3ffec530 00000000 3fffdcb0
3fffff90: 40203fd7 3fffdab0 00000000 4020274b
3fffffa0: 3ffe8b00 40000f49 3fffdab0 40000f49
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
Adding yield()
in places makes no difference. It happens often but not every time.
Anyway, the 0
status indicates that nothing WiFi happened so far. I expected it to at least to progress to 1
if not further. I will only send a UDP packet so no need to establish a connection.
Looking at the power usage shows that the WiFi engine does start before the program starts.