Works perfectly … Great work on the lib!
khoih,
We are currently converting our project from wired to wifi functionality and further link it to blynk (and removing node-red dependency).
FYI: We noticed your lib has a EEPROM.h lib dependency what can be a challenge for projects using the much more functional EEPROMex.h lib as if you include both libs in your project there will be a conflict because the simple one defines “static EEPROMClass EEPROM” and the extended lib defines “external EEPROMClassEx EEPROM” so the compiler sees 2 classes with the same EEPROM name.
(Ugly) solution is to rename one of them in the lib and code will compile fine with both libraries used.
The easiest solution, if you insist of using the EEPROMex library, is to change the file
Esp8266_AT_WM_Lite.h of Esp8266_AT_WM_Lite library , assuming you’re using Mega, from
#include <EEPROM.h>
into
#include <EEPROMex.h>
Just recheck / retest the code to see if changing the lib breaking anything.
Also remember that some EEPROM locations have been reserved for the WM + dynamicParams purposes and use different location to store your params.
I also suggest to move this discussion to the correct topic from now on
BTW, I’ll add in next release v1.0.3
- Option to use EEPROMex library, by just specifying from sketch,
- Add support to nRF52-based boards, , such as Adafruit’s NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, etc. The Credentials and Dynamic Parameters’ data will be stored in LittleFS/InternalFS .
Anything you’d like to suggest to add into that new release?
Sounds great. Think your library is already very complete. We noted using some of the setConfigPortal call some weird behavior on iPhones with WEP2 and security but we are still debugging to see what is causing it, apart from that great library.
Update June 25th 2020
Releases v1.0.16
- Fix bug and logic of USE_DEFAULT_CONFIG_DATA.
- Auto format SPIFFS / LittleFS for first time usage.
Dear @khoih. Congratulations on your work, it has helped me a lot. I would like to know how to prevent a failure / oscillation in the power supply causing the DoubleResetDetector to be involuntarily triggered? I have faced this problem and I do not know how to solve it. My devices after 2 consecutive power outages they enter the Config Portal, that is, the devices understand this power failure as triggering the DoubleResetDetector and do not leave the Config Portal until the information is filled, this is not good because the devices will be disconnected from the server while in the Config Portal in an undesired manner. is this possible to fix? thanks
It’s nice to know the library can somehow help you.
The power failure issue can be hopefully solved by
- Using battery
- Using big electrolytic capacitor
- Using UPS (Uninterrupted Power Supply)
- You can also try to shorten the DRD time (default at 10s to something like 1s). But not sure can totally solve your power failure issue.
// Number of seconds after reset during which a
// subsequent reset will be considered a double reset.
#define DRD_TIMEOUT 10
- You can also use the SW, instead of DRD, to force the Config Portal.
Compare the examples ConfigOnSwitch and ConfigOnDoubleReset and see how to change.
Good Luck,
It sounds like there should be a timeout added to the double reset config so that it will not hangup for too long.
The DRD is a different and independent library and you certainly can configure its features to whatever way you’d like.
For example, in the ConfigOnDoubleReset example, the time spent in Config Portal (CP) is forced to be indefinite by disable time-out, as this is considered as intentional to do some change to the Credentials. So the CP will stay until valid / new data are entered and saved.
Have a look at ConfigOnDoubleReset.ino Line 666-673 for a way to change the time-out
1. No timeout
if (drd->detectDoubleReset())
{
// DRD, disable timeout.
ESP_wifiManager.setConfigPortalTimeout(0);
Serial.println("Open Config Portal without Timeout: Double Reset Detected");
initialConfig = true;
}
2. Timeout
If you don’t like to disable time-out, just specify the time-out different from 0.
if (drd->detectDoubleReset())
{
// DRD, using timeout 180s
ESP_wifiManager.setConfigPortalTimeout(180);
Serial.println("Open Config Portal with 180s Timeout: Double Reset Detected");
initialConfig = true;
}
Looks like a reasonable way to handle the problem.
Updated Jan 1st 2021
Major Releases v1.1.0
- Add support to LittleFS for ESP32 using LittleFS_esp32 Library
- Add support to MultiDetectDetector. MultiDetectDetector feature to force Config Portal when configurable multi-reset is detected within predetermined time.
- Clean-up all compiler warnings possible.
- Add Table of Contents
- Add Version String
- Add MRD-related examples.
Bạn là người Việt Nam phải không?
Updated Feb 24th 2021
Major Releases v1.2.0
- Configurable Customs HTML Headers, including Customs Style, Customs Head Elements, CORS Header.
- Add support to ESP32-S2 (ESP32-S2 Saola and AI-Thinker ESP-12K). Currently using EEPROM only. To add support to LittleFS and SPIFFS in future releases.
- Fix Config Portal Bug.
- Tested with Latest ESP32 Core 1.0.5 for ESP32-based boards.
- Update examples
Releases v1.1.3
- To permit autoreset after configurable timeout if DRD/MRD or non-persistent forced-CP. Check Good new feature: Blynk.resetAndEnterConfigPortal() Thanks & question #27
Releases v1.1.2
- Fix rare Config Portal bug not updating Config and dynamic Params data successfully in very noisy or weak WiFi situation
Releases v1.1.1
- Add functions to control Config Portal from software or Virtual Switches. Check How to trigger a Config Portal from code #25
- Add examples to demo the new Virtual ConfigPortal SW feature
- Optimize code
Dear @khoih , congratulations on your work.
I realized that when the wi-fi + internet access are working normally and there is a failure in both due to a power outage or other similar problem that leaves them off for a time greater than or equal to 15 minutes and when they are turned on (wifi + access to internet working) esp8266 reconnects to wifi but cannot connect to the blynk-cloud server. Could you tell me why this is happening? thanks.
Sorry I have no idea what’s happening there as it doesn’t make sense at all.
What if you turn OFF power to the board more than 15 mins
then turn back ON?
It’s possibly something wrong in your program and/or your network settings and only you can find out why. I’m afraid I can’t help you anything.
Good Luck,
15 minutes sounds like the amount of time that the router will hold a routing table entry for a device after it disappears off the network, but why that would prevent it re-connecting to the router later is a mystery to me.
I’d start by turning everything off then on again
Pete.
I think the “auto start” that @Gyromike was asking for back in April '20 was a captive portal. It automatically presents the configuration page when in AP mode. Here’s an example I’ve successfully used with ESP32:
#include <WiFi.h>
#include <DNSServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 1, 1);
DNSServer dnsServer;
WiFiServer server(80);
String responseHTML = ""
"<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>"
"<style>.c{text-align: center;} div,input{padding:5px;font-size:1em;} input{width:95%;} body{text-align: center;font-family:verdana;} button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float: right;width: 64px;text-align: right;} .l{background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==\") no-repeat left center;background-size: 1em;}</style>"
"<h1>Hello World!</h1><p>This is a captive portal example. All requests will "
"be redirected here.</p></body></html>";
void setup() {
Serial.begin(9600);
if(!WiFi.isConnected()){
Serial.println("No saved credentials.");
GetCredentials();
}
else{
Serial.println("Using saved credentials.");
}
}
void loop() {
}
void GetCredentials(){
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Captive Portal Test");
// if DNSServer is started with "*" for domain name, it will reply with
// provided IP to all DNS request
dnsServer.start(DNS_PORT, "*", apIP);
server.begin();
while(1){
dnsServer.processNextRequest();
WiFiClient client = server.available(); // listen for incoming clients
if (client) {
String currentLine = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n') {
if (currentLine.length() == 0) {
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
client.print(responseHTML);
break;
} else {
currentLine = "";
}
} else if (c != '\r') {
currentLine += c;
}
}
}
client.stop();
}
}
}
Updated April 19th 2021
Major Releases v1.3.0
- Add LittleFS and SPIFFS support to new ESP32-S2 boards (Arduino ESP32S2_DEV). Check HOWTO Install esp32 core for ESP32-S2 (Saola, AI-Thinker ESP-12K) and ESP32-C3 boards into Arduino IDE.
- Add EEPROM and SPIFFS support to new ESP32-C3 boards (Arduino ESP32C3_DEV). Check HOWTO Install esp32 core for ESP32-S2 (Saola, AI-Thinker ESP-12K) and ESP32-C3 boards into Arduino IDE.
- Fix SSL issue with Blynk Cloud Server
- Update examples
Debug Terminal Output
ESP8266WM_MRD_ForcedConfig using LITTLEFS with SSL on ESP8266_NODEMCU
The following is the sample terminal output when running example ESP8266WM_MRD_ForcedConfig on ESP8266_NODEMCU. Please note that this fix the SSL issue with Blynk Cloud Server.
Starting ESP8266WM_MRD_ForcedConfig using LittleFS with SSL on ESP8266_NODEMCU
Blynk_WM SSL for ESP8266 v1.3.0
ESP_MultiResetDetector v1.1.1
[267] Set CustomsStyle to : <style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>
[289] Set CustomsHeadElement to : <style>html{filter: invert(10%);}</style>
[296] Set CORS Header to : Your Access-Control-Allow-Origin
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
lowerBytes = 0x0001, upperBytes = 0x0001
No multiResetDetected, number of times = 1
LittleFS Flag read = 0xFFFE0001
Saving config file...
Saving config file OK
[339] Hostname=8266-Master-Controller
[361] LoadCfgFile
[361] OK
[361] ======= Start Stored Config Data =======
[361] Hdr=SSL_ESP8266,BrdName=ESP8266
[361] SSID=HueNet1,PW=12345678
[363] SSID1=HueNet2,PW1=12345678
[366] Server=blynk-cloud.com,Token=token1
[372] Server1=blynk-cloud.com,Token1=token2
[378] Port=9443
[379] ======= End Config Data =======
[383] CCSum=0x2fa3,RCSum=0x2fa3
[390] LoadCredFile
[391] CrR:pdata=default-mqtt-server,len=34
[391] CrR:pdata=1883,len=6
[393] CrR:pdata=default-mqtt-username,len=34
[397] CrR:pdata=default-mqtt-password,len=34
[401] CrR:pdata=default-mqtt-SubTopic,len=34
[405] CrR:pdata=default-mqtt-PubTopic,len=34
[409] OK
[410] CrCCsum=0x29a6,CrRCsum=0x29a6
[413] Valid Stored Dynamic Data
[416] Hdr=SSL_ESP8266,BrdName=ESP8266
[420] SSID=HueNet1,PW=12345678
[423] SSID1=HueNet2,PW1=12345678
[425] Server=blynk-cloud.com,Token=token1
[431] Server1=blynk-cloud.com,Token1=token2
[438] Port=9443
[439] ======= End Config Data =======
[442] Check if isForcedCP
[450] LoadCPFile
[450] OK
[450] bg: noConfigPortal = true
[450] Connecting MultiWifi...
[6667] WiFi connected after time: 1
[6667] SSID: HueNet1, RSSI = -46
[6667] Channel: 2, IP address: 192.168.2.92
[6668] bg: WiFi OK. Try Blynk
[6669]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on NodeMCU
[22695] NTP time: Mon Apr 19 06:36:31 2021
[22695] BlynkArduinoClient.connect: Connecting to blynk-cloud.com:9443
[23153] Ready (ping: 1ms).
[23245] Connected to Blynk Server = blynk-cloud.com, Token = token1
[23245] bg: WiFi+Blynk OK
Blynk ESP8266 using LittleFS connected.
Board Name : ESP8266
Stop multiResetDetecting
Saving config file...
Saving config file OK
B
Your stored Credentials :
MQTT Server = default-mqtt-server
Port = 1883
MQTT UserName = default-mqtt-username
MQTT PWD = default-mqtt-password
Subs Topics = default-mqtt-SubTopic
Pubs Topics = default-mqtt-PubTopic
BBBB
ESP32WM_MRD_Config using LITTLEFS with SSL on ESP32S2_DEV
The following is the sample terminal output when running example ESP32WM_MRD_Config on ESP8266_NODEMCU. Please note that this fix the SSL issue with Blynk Cloud Server and runs on new ESP32-S2 using LittleFS using esp32 core v1.0.6+ (not official release v1.0.6, but master release as of 2021/04/19).
Starting ESP32WM_MRD_Config using LITTLEFS with SSL on ESP32S2_DEV
Blynk_WM SSL for ESP32 v1.3.0
ESP_MultiResetDetector v1.1.1
[134394] Set CustomsStyle to : <style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>
[134417] Set CustomsHeadElement to : <style>html{filter: invert(10%);}</style>
[134424] Set CORS Header to : Your Access-Control-Allow-Origin
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
lowerBytes = 0x0001, upperBytes = 0x0001
No multiResetDetected, number of times = 1
LittleFS Flag read = 0xFFFE0001
Saving config file...
Saving config file OK
[134657] Hostname=ESP32-Master-Controller
[134695] LoadCfgFile
[134700] OK
[134700] ======= Start Stored Config Data =======
[134700] Hdr=SSL_ESP32,BrdName=ESP8266
[134700] SSID=HueNet1,PW=12345678
[134701] SSID1=HueNet2,PW1=12345678
[134704] Server=account.duckdns.org,Token=token1
[134710] Server1=account.duckdns.org,Token1=token2
[134717] Port=9443
[134719] ======= End Config Data =======
[134722] CCSum=0x33eb,RCSum=0x33eb
[134738] LoadCredFile
[134742] CrR:pdata=default-mqtt-server,len=34
[134743] CrR:pdata=1883,len=6
[134743] CrR:pdata=default-mqtt-username,len=34
[134743] CrR:pdata=default-mqtt-password,len=34
[134747] CrR:pdata=default-mqtt-SubTopic,len=34
[134751] CrR:pdata=default-mqtt-PubTopic,len=34
[134755] OK
[134756] CrCCsum=0x29a6,CrRCsum=0x29a6
[134760] Valid Stored Dynamic Data
[134763] Hdr=SSL_ESP32,BrdName=ESP8266
[134766] SSID=HueNet1,PW=12345678
[134769] SSID1=HueNet2,PW1=12345678
[134773] Server=account.duckdns.org,Token=token1
[134779] Server1=account.duckdns.org,Token1=token2
[134786] Port=9443
[134787] ======= End Config Data =======
[134791] Check if isForcedCP
[134806] LoadCPFile
[134811] OK
[134811] bg: noConfigPortal = true
[134811] Connecting MultiWifi...
[144534] WiFi connected after time: 1
[144534] SSID: HueNet1, RSSI = -38
[144534] Channel: 2, IP address: 192.168.2.157
[144535] bg: WiFi OK. Try Blynk
[144536]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on ESP32
[145549] NTP time: Mon Apr 19 07:23:17 2021
[145549] BlynkArduinoClient.connect: Connecting to blynk-cloud.com:9443
[146810] Certificate OK
[146826] Ready (ping: 20ms).
[146895] Connected to Blynk Server = blynk-cloud.com, Token = token1
[146895] bg: WiFi+Blynk OK
Blynk ESP32 using LittleFS connected
Board Name : ESP8266
Stop multiResetDetecting
Saving config file...
Saving config file OK
B
Your stored Credentials :
MQTT Server = default-mqtt-server
Port = 1883
MQTT UserName = default-mqtt-username
MQTT PWD = default-mqtt-password
Subs Topics = default-mqtt-SubTopic
Pubs Topics = default-mqtt-PubTopic