ESP to ESP Communication

In this tutorial we will make two ESP8266 as wireless serial (chat application) using UDP communication protocol. You can have communication between multiple ESPs at the same time. We are using UDP broadcast. UDP is unreliable, but works for many application. UDP gives advantage of sending one message to all ESP8266 devices on same network at the same time using broadcast.

In this post I will explain two types of ESP to ESP communication methods.

One ESP to another ESP communication

In this we make one ESP as Access point and another as Client which connects to access point and starts communication. This example is like chat using two ESPs.

esp8266 to esp8266 communication

ESP8266 Code for ESP to ESP Communication

Access Point ESP Program

This ESP makes access point. Access point always have IP: 192.168.4.1

Client ESP8266 Program

This ESP connects to access point. First Device which connects to Access point have 192.168.4.2 IP

Results one to one ESP Communication

After Uploading program in both ESP. Open Serial monitor of both esp8266 and type some message i.e. Send some serial data to ESP8266. Note that baud rate is 9600.

communication test results

From above result it is clear that UDP communication have some problems, If data is repetitive then UDP is OK. Another problem with my program is I am sending single byte to another ESP this creates problem of Packet sequence issue.

Many to Many ESP Communication

In this example all ESP8266 connected on same WiFi network can read messages of all devices and can send message to all WiFi Devices. The basic difference between one to one and Many to Many is all ESP8266 are in STA mode (client). To make intercommunication use MODBUS like addressing system. Ignore messages which are having different address.

many esp to esp communication

In this program I am using only one IP i.e. broadcast IP 192.168 43.255. Make sure your IP range and make last digits to 255.

Upload this program in All ESP8266. Change SendIP as per your network series. Give your WiFi Router SSID and Password.

Results of Multiple ESP communication

multiple esp communication

I sent 123456789 from one ESP to another, Few numbers are missed as I said earlier UDP is unreliable. You can clearly see missing data packets. Its useful when you send data multiple times and have some feedback mechanism. This way you can have esp to esp communication.

Leave a Reply