DEV Community

Cover image for How to Connect Multiple ESP32 in a Mesh Network to Extend Communication Range
Prince
Prince

Posted on

How to Connect Multiple ESP32 in a Mesh Network to Extend Communication Range

When working with IoT projects, one of the biggest limitations of the ESP32 is wireless range.

A single ESP32 using Wi-Fi usually communicates reliably within:

  • ๐Ÿ  50 โ€“ 100 meters indoors
  • ๐ŸŒณ 200+ meters outdoors (Line of Sight)

In real-world environments with walls and interference, communication often drops even earlier. ([Engineers Garage][1])

But what if you need to send data across:

โœ… A farm
โœ… A large building
โœ… A robot fleet
โœ… A smart city setup
โœ… An off-grid monitoring system

Buying expensive RF modules is not always necessary.

๐Ÿ‘‰ Instead, you can create a Mesh Network using multiple ESP32 nodes.


๐Ÿ“ก What is the Idea?

Instead of this:

ESP32 A  ----------------------  ESP32 B
        (too far โŒ)
Enter fullscreen mode Exit fullscreen mode

You do this:

ESP32 A  โ†’  ESP32 B  โ†’  ESP32 C  โ†’  ESP32 D
Enter fullscreen mode Exit fullscreen mode

Each ESP32 becomes a relay node.

Every node:

  • Receives data
  • Rebroadcasts data
  • Extends the network coverage

This is exactly how:

  • Military communication systems
  • IoT Smart Cities
  • Disaster recovery networks

work in real life.


๐Ÿ”ฅ Real World Test Results

Using ESP-NOW protocol:

  • ~320 meters stable communication between two ESP32
  • Up to 500 meters using Long Range Mode outdoors ([Makiuto][2])
  • Theoretical range can reach 1 km in ideal conditions ([Engineers Garage][1])

Now imagine:

Number of Nodes Approx Coverage
2 ESP32 300 โ€“ 500 m
3 ESP32 600 โ€“ 1000 m
5 ESP32 1.5 โ€“ 2 km
10 ESP32 Entire village ๐ŸŒ

Each node simply forwards the message to the next one.

This technique is called:

Multi-Hop Communication


๐Ÿง  Real Use Cases

This technique is already used in:

  • ๐Ÿ„ Smart agriculture sensor networks
  • ๐Ÿš’ Emergency rescue communication
  • ๐Ÿญ Industrial automation monitoring
  • ๐Ÿค– Multi-robot coordination
  • ๐ŸŒฒ Forest fire detection systems

For example:

In farm testing using ESP-NOW mesh, developers achieved about 200m range even without direct line of sight, just by forwarding messages through nodes. ([MySensors Forum][3])


โš™๏ธ Required Hardware

You only need:

  • 2 or more ESP32 boards
  • Power source (Battery / Solar)

No:

โŒ Router
โŒ Internet
โŒ SIM card
โŒ Gateway

ESP-NOW allows up to:

  • 20 devices without encryption
  • 10 encrypted nodes communicating directly ([Engineers Garage][1])

๐Ÿงช Basic ESP-NOW Relay Example

๐Ÿ“ Sender Node

esp_now_send(receiverMac, (uint8_t *) &data, sizeof(data));
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ Relay Node (Receiver + Forwarder)

void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len)
{
   memcpy(&data, incomingData, sizeof(data));

   // Forward to next ESP32
   esp_now_send(nextNodeMac, (uint8_t *) &data, sizeof(data));
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ Final Receiver Node

Serial.println(data.temperature);
Enter fullscreen mode Exit fullscreen mode

Now the message travels across multiple ESP32 like:

Sensor โ†’ Node1 โ†’ Node2 โ†’ Node3 โ†’ Base Station
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“‰ Trade-Offs

Advantage Limitation
No internet needed Lower bandwidth
Low power Needs node placement
Long distance Small packet size (~200B)
Very cheap Network planning required

๐Ÿ›ฐ๏ธ Bonus: Range Optimization Tips

To push your network even further:

โœ” Enable Long Range WiFi Mode
โœ” Use external antennas
โœ” Increase retransmission attempts
โœ” Place relay nodes at height
โœ” Avoid metal obstacles

Some hobbyists even reported >1km line-of-sight using LR mode and antennas in field tests.


๐Ÿ Conclusion

By creating a Mesh Network of ESP32 nodes, you can:

  • Multiply your communication range
  • Eliminate infrastructure costs
  • Build scalable IoT systems
  • Deploy networks in remote areas

All using a $5 microcontroller.


If you're building:

  • Smart farming systems
  • Drone communication
  • Industrial monitoring
  • Home automation across buildings

Then ESP32 Mesh Networking is a game changer.

Happy Building ๐Ÿš€



Top comments (0)