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)