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)