Today I did some tinkering with an ESP8266, trying out OTA and writing a webserver. To find an error, I reduced the sketch to just the following lines:
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
void setup() {
Serial.begin(115200);
server.on("/", []() {
Serial.println("Sending response...");
server.send(200, "text/plain", "Hi there!");
});
server.begin();
}
void loop() {
server.handleClient();
}
Notice that there is no code to connect to a Wifi network. However, the chip still connects to my local, WPA2-secured, network on every boot. I can ping the chip, my browser can get the "Hi there!" message via http, the Serial message gets printed.
How is this possible? Does the ESP8266 somehow retain the Wifi information, maybe because of some old OTA data that was not completely overwritten?
I'm using platformio. Here's my entire platformio.ini:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
I posted the compile and upload log here: https://pastebin.com/BtGrFZiu