Communication between ESP8266's

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!

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.

one (or both) will need to be in station-mode, connecting to the other AP (or both connect to wifi-lan) Then Or, -on one a 'Client' can connect to the other 's 'Server' , go to the IP address and the extract the information from a page that the other sends,
Or, On one a Client can publish on the others 's page and the information can be extracted from the arguments of the URL.

So what I need to do is to connect both of them to my router and then make one of them go to the other's IP to extract the information and give it back to me?

What would I need to mainly modify on my code?

The second option would be to make one read the URL of the other, but I don't really know how to just because I don't know its IP and how to do it.

Sorry for my English I'm still learning.

Thanks for everything!

Your English is not making things easier for me, but let's try and do it step by step.
first let's connect both to your ESP's to your wifi network and let's use static IP so it will be easy to find.
go to your network connections on your computer and find the gateway. this describes for any system, but there is also way to find it in windows without the command prompt (google is your friend)

ESP8266WebServer server(80);  // a server on port 80

IPAddress ip(192, 168, 0, 105); // where 105 is the desired IP Address
IPAddress gateway(192, 168, 0, 1); // set gateway to match your network
IPAddress subnet(255, 255, 255, 0);

in my case the gateway is 192.168.0.1 but it could be different, for the IP you pick one that is not in use, many times the router start counting from 100 or 50. and you assign a different one for each unit.
then you configure and connect

const char* ssid = "yourwifi";
const char* password = "thepassword";
WiFi.config(ip, gateway, subnet); 
WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.println("WiFi connected");

  server.on("/", handleRoot);
  server.begin();

  Serial.println("Server Started");

This is more or less a rough idea (i haven't tested if it compiles it may have typos) but from the other code you posted i figure you should be able to manage a fair way from here, you can now let the ESP go to the IP of the other. ( i tend to use the webserver only myself since i never needed the client, so i am not familiar with it's use sorry for that..)