Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By ReNNo_BiH
#20149 I started using Arduino IDE and looks good for me but cannot find any solution to setup wireless information.

My device needs to boot in AP mode for first time so I can enter SSID and password and then it should restart, continue in client mode and connect to router. Is there any working example that can help me for this purpose?
User avatar
By reaper7
#20153 I think that this is good option for You:
https://github.com/tzapu/WiFiManager

Code: Select all#include <WiFiClient.h>
#include <EEPROM.h>
#include <ESP8266mDNS.h>
#include <WifiManager.h>

WiFiManager wifi(0);

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println("INIT");
 
  wifi.autoConnect("AP_FOR_CONF");

  Serial.println("DONE");
}

void loop() {
}
User avatar
By ReNNo_BiH
#20156 Thank you. That is exactly what I need.
But it doesn't work as expected.

It starts in AP mode, and I successfully enter SSID and Password. It resets by itself, reads ssid and password from EEPROM and connects to network successfully. But as soon as I reset my ESP-01 manually it reads false data from EEPROM and starts AP again.
Hmmmm...

EDIT:

Here is what I get when I restart module manually:
Code: Select allAutoConnect
Reading EEPROM SSID
SSID:
��?�ntX<script>function
Reading EEPROM Password
Password:
 c(l){document.getElementById('s').value=l.innerText||l.textCont
Waiting for Wifi to connect
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

Could not connect to WiFi
Started Soft Access Point

WiFi connected
0.0.0.0
192.168.4.1
mDNS responder started
Server started


Looks like reading from EEPROM is not good.
User avatar
By ian
#20165 I think you'll find that the EEPROM functionality was broken in a recent release :(
Write a little program to write to the EEPROM (don't forget the EEPROM.commit())
Power down & up
Write another little program to read from the EEPROM.

I think you'll get garbage :(