void loop()
{
// input = analogRead(0); < ------------------------ commented
// -- doLoop should be called as frequently as possible.
iotWebConf.doLoop();
// -- Initializing the configuration.
iotWebConf.init();
// -- Set up required URL handlers on the web server.
server.enableCORS(1);
server.on("/", handleRoot);
server.on("/a", handleFetch);
server.on("/config", []{ iotWebConf.handleConfig(); });
server.onNotFound([](){ iotWebConf.handleNotFound(); });
Serial.println("Ready.");
}
int arr_index = 0;
int input = 0;
String res;
String temp;
void loop()
{
// input = analogRead(0);
// -- doLoop should be called as frequently as possible.
iotWebConf.doLoop();
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=\"ru\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>";
s += "IotWebConf 01 Minimal";
s += "";
s += "
This code works great.
`int
arr_index = 0; int input = 0; String res; String temp;void loop() { // input = analogRead(0); < ------------------------ commented // -- doLoop should be called as frequently as possible. iotWebConf.doLoop();
if (arr_index == 50){ arr_index = 0; res = temp + "]}"; temp = "{\"uid\":[" + String(input); } else{ arr_index++; temp += "," + String(input); } }`
But if I uncomment the analogRead() function, everything collapses, after each request the WiFi breaks and the connection is re-connected.
All code
`/**
/**
include
include
// -- Initial name of the Thing. Used e.g. as SSID of the own Access Point. const char thingName[] = "thing";
// -- Initial password to connect to the Thing, when it creates an own Access Point. const char wifiInitialApPassword[] = "smrtTHNG8266";
// -- Method declarations. void handleRoot(); void handleFetch();
DNSServer dnsServer; WebServer server(80);
IotWebConf iotWebConf(thingName, &dnsServer, &server, wifiInitialApPassword);
void setup() { Serial.begin(115200); Serial.println(); Serial.println("Starting up...");
// -- Initializing the configuration. iotWebConf.init();
// -- Set up required URL handlers on the web server. server.enableCORS(1); server.on("/", handleRoot); server.on("/a", handleFetch); server.on("/config", []{ iotWebConf.handleConfig(); }); server.onNotFound([](){ iotWebConf.handleNotFound(); });
Serial.println("Ready."); }
int arr_index = 0; int input = 0; String res; String temp;
void loop() { // input = analogRead(0); // -- doLoop should be called as frequently as possible. iotWebConf.doLoop();
if (arr_index == 50){ arr_index = 0; res = temp + "]}"; temp = "{\"uid\":[" + String(input); } else{ arr_index++; temp += "," + String(input); } }
/**
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=\"ru\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>"; s += "