I want to easily send a number from a phone to my esp8266. I have an app that sends the number in the format IP/number. How can I modify the code to give my the number behind the IP address as an integer?
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
MDNSResponder mdns;
// Replace with your network credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
ESP8266WebServer server(80);
String webPage = "";
void setup(void){
delay(1000);
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("MDNS responder started");
}
server.on("/", [](){
Serial.println("device connected");
});
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
So it would do something like this for and should be looking through every i between 0 and 200. :
server.on("/"+String(i), [](){
Serial.println("i");
});