Hello blynkers,
So I decided I want to let the Blynk just handle the communication with the server, and such “IOT” stuff, and managing wireless connection entrust to IotWebConfig library. But man, things did not go well…
MCU: ESP8266 as WeMos d1 mini.
The issue is that it looks like the blynk is unable to make stable connection to the server. The issue only appears if the IotWebConf was initialized. If IotWebConf was not initialized, the blynk seems to connect just fine (after the network was set-up of course). Does anyone know what can be causing this behaviour?
Here is the code (Blynk example merged with “minimal” example from IotWebConf library),
The code should be runnable as it is, (The auth token is included on purpose!) if you have an ESP8266, installed libraries, and Internet connection:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <IotWebConf.h>
char auth[] = "G4aJD5mCG-mJ-w-OLlZkTZmns760JwC0";
// -- Initial name of the Thing. Used e.g. as SSID of the own Access Point.
const char thingName[] = "testThing";
// -- Initial password to connect to the Thing, when it creates an own Access Point.
const char wifiInitialApPassword[] = "smrtTHNG8266";
DNSServer dnsServer;
WebServer server(80);
IotWebConf iotWebConf(thingName, &dnsServer, &server, wifiInitialApPassword);
void setup()
{
Serial.begin(74880);
Serial.println();
Serial.println("Starting up...");
// -- Initializing the configuration.
iotWebConf.init(); // Try to comment out this init, and see wether the issues are gone...
// -- Set up required URL handlers on the web server.
server.on("/", handleRoot);
server.on("/config", [] { iotWebConf.handleConfig(); });
server.onNotFound([]() {
iotWebConf.handleNotFound();
});
Blynk.config(auth);
Serial.println("Ready.");
}
int state;
void loop()
{
iotWebConf.setApTimeoutMs(2665);
// -- doLoop should be called as frequently as possible.
iotWebConf.doLoop();
Blynk.run();
}
/**
Handle web requests to "/" path.
*/
void handleRoot()
{
// -- Let IotWebConf test and handle captive portal requests.
if (iotWebConf.handleCaptivePortal())
{
// -- Captive portal request were already served.
return;
}
String s = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>";
s += "<title>IotWebConf 01 Minimal</title></head><body>Hello world!";
s += "Go to <a href='config'>configure page</a> to change settings.";
s += "</body></html>\n";
server.send(200, "text/html", s);
}
Also please see the github issue I opened where it was suggested that it could be Blynk issue.
Thank you all!