Hey!
I've been having some problems while connecting two ESP8266's. Both of them create an own AP but I want one of them to get information (requesting) from a sensor that is connected to the other plaque.
The requesting plaque has got the IP (192.168.4.1) and I created a menu onto that IP, and when I click to "Flama" I get a specific text that is on void flama declaration. What I pretend to do is to get information about the sensor connected to the other motherboard when I click to Flama on my menu (While connected to the first module, I go to 192.168.4.1 and in the menu I click Flama but I don't know how to get the information of the sensor connected to the other one.
How do I get the information?
This is the code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <String.h>
const char *ssid = "ModulPrincipal"; // wifi que crea
const char *password = "TRAS1819";
const char *host = "192.168.4.1";
IPAddress local_IP(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);
ESP8266WebServer server(80);
String estat = String(13);
void handleRoot() {
String menu = "
Benvingut
";
"Refresh: 2\r\n";
menu += "
Fes click per a controlar:
";
menu += "RGB
";
menu += "Cubell
";
menu += "PIR
";
menu += "Flama
";
menu += "STH
";
server.send(200, "text/html", menu);
}
void flama() {
WiFi.begin("Flama","TRAS1819");//Es connecta al AP Flama
server.send(200, "text/html", "Connectat a flama");
Serial.println();
String estat = server.arg("flama");
Serial.println(estat);
}
void setup() {
Serial.begin(115200);
Serial.println();
delay(10);
Serial.print("Configuring access point..."); //Es crea un AP
WiFi.softAP(ssid, password); //Contrasenya i ssid de la AP
WiFi.softAPConfig(local_IP, gateway, subnet);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
delay(1);
server.on ( "/flama", flama );
server.on ( "/", handleRoot );
}
void loop() {
server.handleClient();
}
I'm using ESP8266 on D1 Mini (115200) and 1.8.7 Arduino IDE version
Looking forward to some help as fast as you can! Thank you!