Everything about Internet of Things and more

Internet of Things project – Communication between ESP8266 modules | ESP8266 Arduino Tutorial

Gearbest  promotion

What people don’t know is the real benefits of making two ESP8266 talk each other. While many of you are trying to find how to connect two ESP8266 modules, you actually don’t have a good image about what applications or projects you can do by making multiple ESP8266 modules communicate between them. In this article you will find everything you need to know about benefits of creating an independent self-sustained Wi-Fi ESP8266 network.

Probably the best books to learn Arduino

How to make two ESP8266 talk each other

Is it hard?

First of all, you don’t know what is an ESP8266 or how to use it you first need to read this complete ESP8266 Arduino tutorial and review and then come back.

Connecting two ESP8266 (or many) and make them communicate each other is not hard at all, you just need to know the ESP8266 working modes, and have a good knowledge about the software libraries.

Before you start, ask yourself this:

How will that really help you and how can you take advantage of having two Wi-Fi modules connected in your application or in your IoT project?

Hooking up two ESP8266 should be a solution to your problem not just a question. I will give you one of the most relevant application example that I found so far:

Powerful example: The Farmer story

A very talented farmer from Europe, who grows vegetables on large, square fields has managed to implement a fully automatic temperature and moisture Wi-Fi monitoring system over a 5 squares km field using the benefits of interconnecting ESP8266 modules without using any wires. Yes, 5km, its a huge area, but it can easily be covered if you have imagination.

How he did it?

So this farmer spliced his 5km field in 4 area parts, and in each part has build a sub-network of 9 ESP8266s. Also in the center of the field he placed a box containing another ESP8266 module, 1 Arduino NANO and a GPRS 3G Arduino compatible module. In each sub-network he arranged ESPs in a custom formation (a sort of combination between mesh and star) in order to use 3 of them as repeaters (the middleman) and the other 6 just for sensor readings (the workers). He choosed this topology in order to be able to cover all the field by using some of the ESPs as signal repeaters.

IoT project - Communication between two ESP8266 - Talk with Each Other

In the next image you can see a join between a mesh formation topology and a star topology into a Star Mesh hybrid.

IoT project - Communication between two ESP8266 - Talk with Each Other

There are many possible arrangements (like the one below) that you can design for your project, but you need to find the real advantage behind it. You can find here a good wireless infrastructure and topologies documentation.

IoT project - Communication between two ESP8266 - Talk with Each Other

Back to our farmer

While the 6 workers modules were most of the time in DEEP_SLEEP, waking up at 1 hour interval to read the sensors, the 3 middlemans were both in AP (Acces point) and ST (Station mode) having a web server started, waiting for workers requests to come.

How he programmed the modules?

Each worker ESP was programmed to wake up from DEEP_SLEEP, read the sensors and connect to the closest AP ESP and send an HTTP request to its server with the data. If the closest AP middleman was not available the workers ESP were programmed to keep up to 10 readings in the internal ESP826 RTC memory during the DEEP_SLEEP, and send them whenever the AP gets back. ESP workers were powered by 4 x Li-Ion 18650B Panasonic  3.3 A, hooked in parallel and 1-Wire sensors were also controlled (cutt-off) using transistors between measurements. Workers were raised 1m above the ground.

The most complete Arduino Starter Kit

Every middleman ESP was programmed to listen and receive the readings from the workers, and then send it further to next middleman up until the ESP from the central box, being configured in both access point and station (AP_ST). Middlemans were continuous powered on by 3 x Li-Ion 18650B Panasonic  3.3 A hooked in parallel, and charged by 15v solar panels, and where 2.5m above the ground.

He configured workers (clients) to use static IP addresses and hard-coded Gateway and Mask, in order to reduce the time spent in connecting to the AP, and managed to send a complete measurement in less than 2.5 seconds.

The central box was configured to be the Main Cluster data manager, in charge with receiving and processing data from the closest middlemans, and send it in an MySQL database via the 3G GPRS Module in an JSON / XML format, once a day. All the data received hourly was stored in CSV format on an SD card module attached to the Arduino NANO module and processed at a specific hour in the night.

Also the central ESP8266, and the middlemans were programmed to behave like a Module Discovery Agent, making PING requests on the nearby AP to check the availability and send status to the database together with the measurements. This is a technique used in Services / Micro-services based software architectures to know which module / services is available.

What he accomplished?

So at the end of the day, our geek farmer was able to monitor the entire field from his cozzy lounge, using a very pretty web interface with maps and reports and make statistics or forecast based on the data gathered in the database.

How much he spent?

The complete solution including the 1-Wire sensors costed about 350 – 400$ using batteries from laptops cells and a simple phone card charged with 5$ / month, which for an industrial large scale monitoring system is extremely cheap. I saw people spending thousands dollars on a commercial Zig-Bee system,  monitoring a small 100 m deposit, having the same results.

This example should be inspiring for those of you who are looking to get the most from two ESP8266 modules, or even many, and not just play with them as little toys. They are pretty powerful modules, cheaper than other radio available solutions on the market, and you also can find plenty resources over the internet.

What I learned from the farmer?

I also did a project in my house using 4 x ESP8266 modules connected between each other after finding about this young farmer. I made a little monitoring system using a central AP web server and 3 clients in charge with sensing temperature, humidity and methane gas.

You can read a complete Arduino Gas sensor tutorial and review or check a comparison between the best Arduino temperature sensors to make an idea.

Off course I could easily use them independently, and make them send data via my router individually but then, few weeks ago, my internet provider cutout the internet service, and suddenly my 3 x ESP8266 clients were absolutely useless. So i made a proxy between them and the internet router using another ESP8266 in both AP and ST mode, hosting a web server too, and all my clients now send data to the proxy ESP, and then the proxy sends data to the thingspeak IoT platform trough my internet router, or keeps in memory until internet is available. I will soon add a video tutorial so that you can see how it works.

The theory – how it works?

IoT project - Communication between two ESP8266 - Talk with Each OtherThe working principle is quite simple. It works almost as with humans. In order to connect two ESP8266, at least one of them must be an configured as Access Point to give the other one possibility to discover it. Once you’ve connected them together you then need a way to make them talk each other.  As humans do, while one is talking, the other one needs to listen. The advantage of ESP8266 is that in the same time, can be both Client and Acces Point / Server.

“The same time” is actually more theoretically because this module has single threaded MCU, so it can only do a certain thing at 1 point, but the fact that when you receive a request while being in AP / Server mode, you can then immediately connect to next AP and make a request as a client is amazing.

Two ESP8266 communication Arduino code examples

Below you can see the code I uploaded in one of my ESP8266 client. It reads temperature and humidity from a DHT22 and sends it to the AP ESP, and then sleeps for 5 minutes. I also used a static network configuration in order to win some time by not waiting for DHCP. For request handling I’ve used ESP8266HTTPClient library which I found being much simpler and logic and I recommend it.

/*
Geekstips.com
IoT project - Communication between two ESP8266 - Talk with Each Other
ESP8266 Arduino code example
*/
#include <DHT.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define DHTPIN 2

// AP Wi-Fi credentials
const char* ssid = "***********";
const char* password = "**********";

// Local ESP web-server address
String serverHost = "http://192.168.4.1/feed";
String data;
// DEEP_SLEEP Timeout interval
int sleepInterval = 5;
// DEEP_SLEEP Timeout interval when connecting to AP fails
int failConnectRetryInterval = 2;
int counter = 0;

float h;
float t;
// Static network configuration
IPAddress ip(192, 168, 4, 4);
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);

DHT dht(DHTPIN, DHT22);
WiFiClient client;

void setup() {
  ESP.eraseConfig();
  WiFi.persistent(false);
  Serial.begin(74880);
  Serial.println();
  Serial.println("**************************");
  Serial.println("**************************");
  Serial.println("******** BEGIN ***********");
  Serial.println("- start DHT sensor");
  dht.begin();
  delay(500);
  Serial.println("- set ESP STA mode");
  WiFi.mode(WIFI_STA);
  Serial.println("- connecting to wifi");
  WiFi.config(ip, gateway, subnet); 
  WiFi.begin(ssid, password);
  Serial.println("");
  while (WiFi.status() != WL_CONNECTED) {
    if(counter > 20){
       Serial.println("- can't connect, going to sleep");    
       hibernate(failConnectRetryInterval);
    }
    delay(500);
    Serial.print(".");
    counter++;
  }
  
  Serial.println("- wifi connected");
  Serial.println("- read DHT sensor");
  readDHTSensor();
  Serial.println("- build DATA stream string");
  buildDataStream();
  Serial.println("- send GET request");
  sendHttpRequest();
  Serial.println();
  Serial.println("- got back to sleep");
  Serial.println("**************************");
  Serial.println("**************************");
  hibernate(sleepInterval);
}

void sendHttpRequest() {
  HTTPClient http;
  http.begin(serverHost);
  http.addHeader("Content-Type", "application/x-www-form-urlencoded");
  http.POST(data);
  http.writeToStream(&Serial);
  http.end();
}

void readDHTSensor() {
  delay(200);
  h = dht.readHumidity();
  t = dht.readTemperature();
  if (isnan(h) || isnan(t)) {
    t = 0.00;
    h = 0.00;
  }
  Serial.println("- temperature read : "+String(t));
  Serial.println("- humidity read : "+String(h));
}

void buildDataStream() {
  data = "temp=";
  data += String(t);
  data += "&hum=";
  data += String(h);
  Serial.println("- data stream: "+data);
}


void hibernate(int pInterval) {
  WiFi.disconnect();
  ESP.deepSleep(10 * 600000 * pInterval, WAKE_RFCAL);
  delay(100);
}

void loop() {}

For the Access Point I used the following code:

/*
Geekstips.com
IoT project - Communication between two ESP8266 - Talk with Each Other
ESP8266 Arduino code example
*/
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
// IoT platform Credentials
String apiKey = "*************";
const char* logServer = "api.thingspeak.com";

// Internet router credentials
const char* ssid = "***********";
const char* password = "***********";

ESP8266WebServer server(80);

void setup() {
  Serial.begin(74880);
  WiFi.mode(WIFI_AP_STA);
  setupAccessPoint();
}
// Handling the / root web page from my server
void handle_index() {
  server.send(200, "text/plain", "Get the f**k out from my server!");
}

// Handling the /feed page from my server
void handle_feed() {
  String t = server.arg("temp");
  String h = server.arg("hum");

  server.send(200, "text/plain", "This is response to client");
  setupStMode(t, h);
}

void setupAccessPoint(){
  Serial.println("** SETUP ACCESS POINT **");
  Serial.println("- disconnect from any other modes");
  WiFi.disconnect();
  Serial.println("- start ap with SID: "+ String(ssid));
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("- AP IP address is :");
  Serial.print(myIP);
  setupServer();
}

void setupServer(){
  Serial.println("** SETUP SERVER **");
  Serial.println("- starting server :");
  server.on("/", handle_index);
  server.on("/feed", handle_feed);
  server.begin();
};

void setupStMode(String t, String v){
  Serial.println("** SETUP STATION MODE **");
  Serial.println("- disconnect from any other modes");
  WiFi.disconnect();
  Serial.println();
  Serial.println("- connecting to Home Router SID: **********");
  WiFi.begin("*********", "*********");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.println("- succesfully connected");
  Serial.println("- starting client");
  
  WiFiClient client;

  Serial.println("- connecting to Database server: " + String(logServer));
  if (client.connect(logServer, 80)) {
    Serial.println("- succesfully connected");
    String postStr = apiKey;
    postStr += "&field1=";
    postStr += String(t);
    postStr += "&field2=";
    postStr += String(v);
    postStr += "\r\n\r\n";
    Serial.println("- sending data...");
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
  }
  client.stop();
  Serial.println("- stopping the client");
  /** If your ESP does not respond you can just
  *** reset after each request sending 
  Serial.println("- trying reset");
  ESP.reset();
  **/
}

void loop() {
  server.handleClient();
}

As you can see, it starts in AP_ST mode and configures the web server and the main event listeners. On the main page listener (“/feed”), the  setupStMode() function is called, which connects to the main Internet router, takes the readings as parameters and send them via http request to the thinkspeak IoT platform. After that it continues to listen for other clients in AP mode. If you encounter problems after doing a complete send, use ESP.reset(); to quickly get back in the AP mode.

Off course, I choosed the simplest way, using simple HTTP requests, but you can find more techniques to do the talking, like websockets (find morrissinger library for websockets server and client) or other UDP advanced protocols.

UPDATE – If you need to need to make ESP modules talk each other but in totally different networks here is a new method to communicate between ESP8266 modules using Blynk Bridge.

Blynk BRIDGE - Another way to Communicate between two ESP8266 modules3

Final thoughts

If you are a hobbyist / geek you definitely need to give ESP8266 a chance before trowing your money on high end monitoring systems. But keep in mind that this kind of devices require thorough testing and patience since they are not coming embedded. First make a little prototype, test it and then if it works scale it to your needs. I’d choose ESP8266 just for the huge coverage area in straight line, and never the less for its price. Making two ESP8266 talk each other is an easy task for this powerful devices and with a bit imagination you can do impressive projects with low budget.

Hoping that this article inspired you, i kindly invite you share this articlesubscribe my YouTube channel and join the communities on social networks. Please feel free to comment or send suggestions / remarks so i can improve the content quality!

Gearbest  promotion

Share on: Facebook Twitter Google+

55 Replies to “Internet of Things project – Communication between ESP8266 modules | ESP8266 Arduino Tutorial”

  1. Moebius says:

    Nice work and great network topology. I just believe that have better options instead of using ESP8266. The main reason I’m saying that is because of the power consumption of a WiFi node. Even using sleep modes ot still consumes a lot of power to join the network and transmitt.

    In the described solution you need to provide some significant amount of energy and have solar panels, which can increase the cost, complexity and maintenance.

    If you pick options like subGhz modules you could probably use standard AA batteries for working nodes and also gett some better range might eliminating the need for intermediate/router nodes.

    Apart from that it’s a great article showing real life useful example instead of “how to turn on lights”. 😉

    • Moebius says:

      Btw I’m have good results with radil RFM69 and the Whispe Node board. I normally use a RPI as gateway to the Internet.

      • GeeksTips says:

        Thank you for the tip, I will take a look for that board and come back !

    • GeeksTips says:

      Yes, I totally agree with you, ESP8266 is so controversial when it comes to power consumption. But seem that some people gave it a chance. If you can reduce the timings and optimize your network, you can then organize a schedule to monitor and change or recharge batteries. An ordinary 200 mA solar panel is under 5$ and its enough to recharge a AA lithium between the 1 hour interval. The highest peek for ESP8266 is somewhere between 180-220 mA but it last only 1.5-3s. Anyway, thank you for your interest, glad that you liked !

      • JS says:

        I’m one of those people. 🙂

        Connecting to the wifi and transmitting data takes about 2 (3 sec. max) in my tests.
        Combined peak current of analog and radio part is about 500mA but should be about 80mA average according to this interesting FAQ : (Page 15)
        http://espressif.com/sites/default/files/documentation/espressif_faq_en.pdf

        DeepSleep current of a simple temp logger I’ve built is about 30µA. Can’t tell how long it will last because I just set it up but I’m expecting about 3 months at a 5min log interval using a 2000mAh lipo battery.

        Also built a prototype which sleeps at under 1µA using a external RTC + MOSFET to turn off the whole system but this is only practical if using longer sleep intervals(like >1 hour) and better batteries like eneloop.

        Anyway I also don’t think the ESP can compete with something like the RFM69.

        • GeeksTips says:

          Hello, I will make a demo video soon, my ESP-01 connects and sends data to the other ESP-01 AP in less than 2 seconds using static ip. about your 500mA, I really think that you’ve gone something wrong, ESP-01 can’t consume that much… even in full TCP using highest TX rates should stay under 300mA, at least the version with no LEDs. And the sensor should be under 50mA. Maybe using a high capacitor just near the ESP pinouts will cut those peaks. I really recommend to watch this video: https://www.youtube.com/watch?v=6SdyImetbp8

  2. JS says:

    Hi! Great article, very inspiring.

    Just a question about your sketch.
    I saw you are calling ESP.eraseConfig() on every boot but also WiFi.persistent(false).
    Aren’t they mutually exclusive?
    As far as I know persistent(false) tries to eliminate unneccassary flash writes while eraseConfig() is doing just that.

    • Anonymous says:

      So while the eraseConfig should clear the static ip/network configurations, the persistance(false) should not allow remembering the connection credentials(ssid, pass, wps, etc.) Or at least this is what i’ve found about them

      • Anonymous says:

        What I mean is that ESP.eraseConfig() explicit writes to the flash while WiFi.persistent(false) tries to prevent flash writes.
        This doesn’t makes sense to me.
        But maybe i misunderstood something.

  3. Excelenta descriere si prezentare, felicitari !

  4. sam says:

    where can the header files downloaded?

    • GeeksTips says:

      Supposing that by header files you mean the included libraries, you can find them all in the library manager (Arduino IDE 1.6.xxx)

      • Anonymous says:

        I cant seem to find the liberary called “ESP8266HTTPClient”. Where should I be looking?

    • GeeksTips says:

      Let me know exactly what do you need.

  5. Sven says:

    Thank you for the great article
    Is it possible to also share the electronics scheme on how you connected everything?

  6. lucas neill says:

    hi

    Thanks for the Tutorial. its really what i want. I think we use esp’s GPIO2 pin to connect DHT data reading right? And my actual question is what kind of modification we can make to make a relay connected to AP side turn on or off according to the certain temperature read by client side? for example when client sends temperature below 20 degrees AP turns on relay otherwise turn it off? if you help me about this i ll appreciate. Thanks in advance

    • GeeksTips says:

      Hello, if you are using ESP 01, you can use GPIO-0, GPIO-2 or GPIO-1 (RX channel PIN) for reading the DHT sensor. You can connect the relay on GPIO0 or GPIO2 and control it by pulling HIGH or LOW depending on the Temperature values using a simple IF statement comparison [IF (temp < 20) {digitalWrite(RELAY_GPIO, HIGH);} ] . If you use ESP12, then you have many GPIOs to use individually for relays and sensors, the job becomes much simpler. Let me know if you need a sketch. Have a good day!

      • lucas neill says:

        thanks i updated my code by getting help from someone else as follows can you check it? this is my AP side code, i connected a relay to GPIO2. so my questions are :

        1-when i connect to thingspeak page it doesnt update data readings unless i reset the client side manually why? or the time interval is too much? i dont know because i m new to this.
        2-the client continuously sends data to both AP and thingspeak? because it needs to do so to control my relay without needing my attention

        this is the code:

        /*
        Geekstips.com
        IoT project – Communication between two ESP8266 – Talk with Each Other
        ESP8266 Arduino code example
        */
        #include
        #include
        // IoT platform Credentials
        String apiKey = “my thingspeak api key”;
        const char* logServer = “api.thingspeak.com”;

        // Internet router credentials
        const char* ssid = “ESP8266”;
        const char* password = “12345678”;

        ESP8266WebServer server(80);

        void setup() {
        Serial.begin(74880);
        WiFi.mode(WIFI_AP_STA);
        setupAccessPoint();
        pinMode(2, OUTPUT); // Make GPIO2 as an OUTPUT to drive Relay MOSFET
        }
        // Handling the / root web page from my server
        void handle_index() {
        server.send(200, “text/plain”, “Get the f**k out from my server!”);
        }

        // Handling the /feed page from my server
        void handle_feed() {
        String t = server.arg(“temp”);
        String h = server.arg(“hum”);

        server.send(200, “text/plain”, “This is response to client”);
        setupStMode(t, h);

        // new code added here for the relay
        long temp = t.toFloat();
        if (temp < 20.0)
        digitalWrite(2, HIGH); // Turn ON Relay on GPIO2
        else
        digitalWrite(2, LOW); // Turn OFF Relay on GPIO2
        }
        void setupAccessPoint(){
        Serial.println("** SETUP ACCESS POINT **");
        Serial.println("- disconnect from any other modes");
        WiFi.disconnect();
        Serial.println("- start ap with SID: "+ String(ssid));
        WiFi.softAP(ssid, password);
        IPAddress myIP = WiFi.softAPIP();
        Serial.print("- AP IP address is :");
        Serial.print(myIP);
        setupServer();
        }

        void setupServer(){
        Serial.println("** SETUP SERVER **");
        Serial.println("- starting server :");
        server.on("/", handle_index);
        server.on("/feed", handle_feed);
        server.begin();
        };

        void setupStMode(String t, String v){
        Serial.println("** SETUP STATION MODE **");
        Serial.println("- disconnect from any other modes");
        WiFi.disconnect();
        Serial.println();
        Serial.println("- connecting to Home Router SID: **********");
        WiFi.begin("my home router ssid", "my password");
        while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
        }
        Serial.println();
        Serial.println("- succesfully connected");
        Serial.println("- starting client");

        WiFiClient client;

        Serial.println("- connecting to Database server: " + String(logServer));
        if (client.connect(logServer, 80)) {
        Serial.println("- succesfully connected");
        String postStr = apiKey;
        postStr += "&field1=";
        postStr += String(t);
        postStr += "&field2=";
        postStr += String(v);
        postStr += "\r\n\r\n";
        Serial.println("- sending data…");
        client.print("POST /update HTTP/1.1\n");
        client.print("Host: api.thingspeak.com\n");
        client.print("Connection: close\n");
        client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
        client.print("Content-Type: application/x-www-form-urlencoded\n");
        client.print("Content-Length: ");
        client.print(postStr.length());
        client.print("\n\n");
        client.print(postStr);
        }
        client.stop();
        Serial.println("- stopping the client");
        /** If your ESP does not respond you can just
        *** reset after each request sending
        Serial.println("- trying reset");
        ESP.reset();
        **/
        }

        void loop() {
        server.handleClient();
        }

        • lucas neill says:

          by the way do i m using esp-01 and i used GPIO2 for dht readings is it wrong ? do i have to use RX? this was my third question. thanks

          • GeeksTips says:

            hi lucas, i didn’t had the time to follow all your code, but at first glance I would recommend you to move your relay added code just below this line: String h = server.arg(“hum”); Anyway, above the setupStMode line. The client sends data only to the AP, and then the AP forward it to ThingSpeak. The interval is default 5 minutes, but you can modify by changing the value of this variable: int sleepInterval = 5;. The best advice that I can give you its to make DEBUG without the CLIENT !! Connect with your smartphone or Notebook to your AP Wifi and then open the server address in your browser and send the URL created with your testing values:
            http://192.168.4.1/feed?temp=555&hum=2222

  7. lucas neill says:

    i applied your suggestions i changed sleepinterval to 3 so is it 3 minutes now?

    by the way i couldnt get what WITHOUT CLIENT means? if that means with client side disconnected i tried to click the link you provided both with the client disconnected and connected and in the page opened i see “This is response to client” reading and on THINGSPEAK i see 555 as temperature and 222 as humidity. so that means it is working?

    my last question is will it send data to both AP and thingspeak in each 3 minutes? now i ll check thingspeak if it updates each 3 minutes and will let you know.

  8. lucas neill says:

    now i tried to change the values in the link after i got what you mean. i changed the temp to 19 and relay turned on so to get it turned off do i have to wait 3 minutes? but as i say i can t see updates on thingspeak in 3 mins intervals

  9. lucas neill says:

    another information for you

    from client’s serial monitor i can just see these below once and nothing else more, what does it mean?

    “ets Jan 8 2013,rst cause:2, boot mode:(3,6)

    load 0x4010f000, len 1384, room 16
    tail 8
    chksum 0x2d
    csum 0x2d
    v09f0c112
    ~ld

    **************************
    **************************
    ******** BEGIN ***********
    – start DHT sensor
    – set ESP STA mode
    – connecting to wifi

    ……- wifi connected
    – read DHT sensor
    – temperature read : 21.10
    – humidity read : 38.90
    – build DATA stream string
    – data stream: temp=21.10&hum=38.90
    – send GET request
    This is response to client
    – got back to sleep
    **************************
    **************************

    ets Jan 8 2013,rst cause:5, boot mode:(3,6)

    ets_main.c “

    • GeeksTips says:

      Ok, now I understand. In the AP code you need to store the received temperature in a global variable called lets say LAST_TEMP, then in the VOID LOOP() function you need to check this variable if its higher than 20 then you close the relay. You can do a function like this and call it in LOOP:

      // call this function in the LOOP
      void validateRelayState(){
      // assign LAST_TEMP when you do the first check above
      if(LAST_TEMP > 20){
      digitalWrite(2, LOW); // Turn OFF Relay on GPIO2
      }
      }

      • lucas neill says:

        how will i assign last temp? like the the global variables section

        int lastTemp=0?

        if not how? and what about this error below? (i actually dont know if its and error) but i searched it and i found there is a problem with deepSleep with esp-01, people say so. So after i got the following the program turns to the beginning and do it again or stuck at the end?

        “ets Jan 8 2013,rst cause:5, boot mode:(3,6)

        ets_main.c “

  10. Lucas Neill says:

    I know I’m disturbing you, do we have a chance to have instant messaging to solve the problem quickly?? Because I m continuously sending you problems here

    • GeeksTips says:

      text me on facebook and we will open a chat there

  11. Lucas Neill says:

    how can I find you on Fb? What’s your username and what is your profile pic?

  12. Lucas Neill says:

    I think I found you and wrote a message to you have you got it

  13. Lucas Neill says:

    This is my link I added you and sent message

    https://www.facebook.com/ali.duskun.9

  14. Tran Son says:

    Hi sir, i am a newbie and i still not understand all the feature. I already have 2 arduino uno and 2 esp8266 module. i try to follow your code but how can i check that they are connected ( i mean talk) ? Are there any visual that i can look at and know that they are talking?

    • GeeksTips says:

      @Tran Son, in order to make them talk, you need a purpose, a scope! Why do you need them to be connected? If your project has a scope, then check if the scope is accomplished.

      • Tran Son says:

        sorry i very new to arduino and programming, so please help me ^^ i see in your code has some code is “Serial.prinln”, so how can you see there string when they are working? use a LCD or serial monitor COM port in arduino? and in addition, where do you compile the code, in the arduino MCU or in the esp8266 MCU?

  15. Jupi says:

    Hi. Is it possible to send eg temperature from one ESP to another ESP without “leaving the house”. Without thingspeak.com.
    Just one ESP as Client sends direct to the others ESP as Accesspoint.
    Thanks.

    • GeeksTips says:

      Yes, you this is exactly what that code does if you cut the sending to Cloud part. Now depending on what do you want to do with the code in the AP you need to modify your code in the end.

      • Anonymous says:

        Many thanks, I’ll try it.

  16. sunil says:

    hi,

    I have a multiple esp8266 connected to sensors and actuator and it comunicates via MQTT server which is running on a Rassberry pi3.

    All mcu and Raspberry pi are coonected via a router.

    Can i use the same setup but without using http webserver.

    I am trying to achieve something similar to above farmers network setup of worker and AP/ST.

    can you pls help ?

  17. sunil sud says:

    HI,

    i even tried the above code to make esp8266 as range extender.

    the code executes i get the ip 192.168.4.1 and it says its connected to the router but

    when i connect to the Ap through my phone i cannot open any page no internet connection on the AP.

    pls help

    regards,
    sunil

  18. riaz ahmed says:

    I used thingspeak apikey of one of my channels in your server code. However the clients do not connect and from the server Serial Monitor output i see it goes up to:
    þ** SETUP ACCESS POINT **
    – disconnect from any other modes
    – start ap with SID: PTCL-140
    – AP IP address is :192.168.4.1** SETUP SERVER **
    – starting server :
    only. Nothing beyond. On the client side i have used the server side ssid as NodeMcU and password and the IP Address there is 192.168.4.4

    where do i go wrong. please help

    • GeeksTips says:

      Riaz, does the client connects to the AP? You should do debugging on AP by getting a laptop connected to the AP HotSpot and then access from the browser 192.168.4.1/whatever. and send the proper parameters and see first if AP works properly and afterwards test the client.

      • Anonymous says:

        I only copy pasted your stuff and replaced the router specs, no other changes. Your code should reproduce directly. What are the ‘proper parameters’. Can you please upload the complete code without bugs?

  19. GeeksTips says:

    This code has no bugs, it worked perfectly on my setup. I pasted here just after uploaded in my hardware and tested. I don’t know your setup, I cannot make code for every user. As a good engineer and programmer, you should keep calm and DEBUG !! this is not a noob project, if you want to make it work, have the patience and test it. I recommended you to TEST the AP directly from a browser (emulating the client). Do that, and we talk after.

  20. GuruBen10 says:

    hi there, iam new with esp and iam doing a project in which iam using 2-ESP8266 one connected to one arduino and another esp connected to another one . I got the sensor readings from the first arduino but i need to transmit to another arduino circuit without using any webserver . can anyone suggest how to do tis?

  21. You can do it by using Blynk Bridge if you have internet connection to the ESPs. Check this article for more info :
    http://www.geekstips.com/blynk-bridge-another-way-to-communicate-between-two-esp8266/

  22. Anonymous says:

    Hi GeeksTips ,

    I used 3 ESP´s…. One is AP (ESP8266-E12) and the other ons are Clients (ESP8266-01). How can i connect both Clients with Static IP’s to the AP…. I will use this constilation to messure Temps with these Clients. The AP is still work as an “offline Monitor”. Can you help me please…

    Thanks in adwance 😉

    • Well, follow my tutorial. Setup your ESP12 as a AP using WiFi.mode(WIFI_AP_STA) and the code from setupAccessPoint() function, and then connect with the ESP01s using network settings from the AP WiFi.config(ip, gateway, subnet); WiFi.begin(ssid, password);

  23. fazel says:

    hello everyone iam new here!!!

    can i send http request from php to esp8266(known ip address)…

    • Hello ! Yes, you can! You need to expose your ESP Server IP (forward) into the network from where you have the PHP code.

  24. DHANDABANI M says:

    Internet of Things project – Communication between ESP8266 modules
    Dear Sir,
    I am getting this error how to clear this? Please give the solution.
    WARNING: Category ‘Cloud’ in library Ospom is not valid. Setting to ‘Uncategorized’
    In file included from C:\Program Files\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:33:0,

    from C:\Users\VEPL\Documents\Arduino\_1\_1.ino:2:

    C:\Program Files\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiType.h:26:19: fatal error: queue.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Mega or Mega 2560.

    • Hello! I am not sure what caused this error. I assume some missing libraries or something like that. Please make sure you have installed the ESP and also the proper board.

  25. ADemo says:

    Thank’s for this tutorial.
    Without using Blynk Bridge, I wan’t to have, for example, a wifi module (say A) which have bidirectional communication with B and C modules. A say to B : give my the data and B send the data to A; A say to C : do some thing and C say to A the job is done.
    A communicates also with a program on a PC via USB.
    For this, is this the good solution to have
    – A is an AP+STA and create a softAP
    -B and C are AP+STA
    I try this with ESP32 modules but it doesn’t work…
    As this solution a chance to work with this configuration.
    Thank’s and sorry for my very bad english

    • It should work, but its allot to work on. Also please check the Blink Bridge tutorial, which may also bee a solution for your project.

Leave a Reply

Your email address will not be published.