ESP8266: Communication between 3 ESPs

Hi guys.
My projects involves 3 ESPs.
First one is AP (Host). On certain actions (which can be anything like pressing button or voice command), I change the value of a variable. I post this value on a webpage. (
I want the other two ESPs (Clients) to connect to this AP and read the value of variable. Based on the value, I want to set their certain pins high or low.
I know how to set up AP and how to connect other ESPs to it.
But how do I make the two clients read the value of the variable from the host ESP? Either directly or via a web page.
I also want the host to host another web page (or maybe on the same page from where clients will read value) where I can directly change value of variable after connecting to AP via phone or laptop.

You can’t do this in the way you are thinking. How will the other esp know when to read the web page? They don’t know when the variable has changed, so they will have to continuously read the web page over and over to see if the variable has changed. This will overwhelm the esp hosting the web page, like a Denial Of Service attack.

You should do it the other way around. The esp that knows when the variable has changed must send a message to the other 2 esp when it changes. The esp which controls the variable can be the AP. The other two esp can be web servers. When the first esp sees the variable change, it can send GET/POST messages to the other two esp. it will know their addresses, because it is the AP.

Great, this exactly meets my requirements.
Can you please elaborate on GET and POST requests and how can I send these to the 2 clients via AP?
In general, how should I go about the code.
Thanks a lot.

Have a look at the standard example Arduino sketches for web server and web client. You will see the client code sending GET requests. GET and POST are pretty much equivalent for this purpose.

Let's call your esps x, y & z.

X will be the Access Point (AP). This is it's WiFi mode.

Y & Z's WiFi mode will be Stations (STA).

X will be a web client. When the value of its variable changes, it will sent GET requests to Y & Z.

Y & Z will be web servers. They will receive GET requests from X when the variable changes value.

To allow you to access a page on X so you can change the value, using your phone for example, X can also be a web server. There's no reason an esp can't be both a web server and a web client at the same time. As a server, it can receive a GET request from your phone to change the variable. It can then act as a client and send GET messages on to Y & Z.

I have been using two ESP’s, one configured as an access point and the other configured as a client connected to the access point formerly created. I am able to send the data successfully but not receiving it on the client side. I have used direct AT commands; from respective PCs without intervening microcontroller; for configuration and sending data. Following are the AT commands I sent in order mentioned at the access point:
AT+CIPSTART=,“UDP”,“ID of client”,2222
AT+CIPSEND=,no: of bytes
Every command gets executed properly as I receive “OK” and no errors and finally get a ‘>’ prompt to type in my data (Using RealTerm software). After I give the data, I get the “SEND OK” reply! So, that’s working fine!
On the client side, before I send data from AP, I connect it to the AP and get an IP. Following are the commands I execute in sequence:
AT+CIFSR //to check IP
Both are executing the “AT+PING” command well! Why am I then not getting the sent data on the client side? It should basically start with the “+IPD” string right? I use two ESP’s with versions: and! I hope that it is not a problem as both support the above used AT command set. And using same AT commands, I added my mobile as another client and I am able to send messages back and forth between two clients, here one ESP and Mobile both are connected to another ESP working as AP. And in mobile I used TCP client App to send and receive messages.

I do not know if what I suggested can be done with AT commands. I suggest you upload Arduino sketches into the ESP so that one acts as an AP and other acts as a web server.

In given situation I am constrained to use AT commands to communicate in WiFi mode between two ESPs(one in AP mode and other in Station mode) connected to PCs, with all necessary conversion circuits in place. Already such ESP setup talk to mobile (used TCP client app to connect ESP to mobile using IP address) easily using AT commands.

Previously I had used 2 numbers of ESP-01 (One is in AP mode and Other is in Station/Client mode)
and AT commands used to set mode and establishing connection between AP and client to send and receive data from AP to client and vice versa but it didn't work. Using the AT+CIPSTART=0,"UDP""",2222 command atleast gets connects but AT+CIPSTART=0,"TCP""",2222 command flags error.
Now I used ESP-12E/Node MCU (One is in AP mode and Other is in Station/Client mode)
and AT commands used to set mode and establishing connection between AP and client to send and receive data from AP to client and vice versa but it didn't work. However there is one silver lining of hope that is ESP-12E works well when Arduino sketches are used which ESP-01 didn't even with Arduino sketches Isn't there any way to make ESP-12E atleast work with AT commands (for communication between ESP-12E ap and ESP-12E station/client) using Original AT Firmware factory loaded?

It may be easier to start small.
I had a Uno with a ESP-01 configured in AP mode.
I had a smartphone TCPIP client app that I downloaded from Google Play Store.
I was able to send messages from the smartphone app to the Uno and also send messages from the Serial Monitor to the smartphone app.

I followed the tutorial at
There are some mistakes in the tutorial that I fixed myself.

This may or may not be what you need.

Very important. ESP-01 needs a strong 3.3V power supply. The Arduino Uno's 3.3V is not enough.