<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Prince</title>
    <description>The latest articles on Forem by Prince (@prince20218).</description>
    <link>https://forem.com/prince20218</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2909548%2Fea01d2d3-6c9e-4724-9e50-b8df939aee68.png</url>
      <title>Forem: Prince</title>
      <link>https://forem.com/prince20218</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/prince20218"/>
    <language>en</language>
    <item>
      <title>How to Connect Multiple ESP32 in a Mesh Network to Extend Communication Range</title>
      <dc:creator>Prince</dc:creator>
      <pubDate>Thu, 26 Feb 2026 17:31:28 +0000</pubDate>
      <link>https://forem.com/prince20218/how-to-connect-multiple-esp32-in-a-mesh-network-to-extend-communication-range-4hmh</link>
      <guid>https://forem.com/prince20218/how-to-connect-multiple-esp32-in-a-mesh-network-to-extend-communication-range-4hmh</guid>
      <description>&lt;p&gt;When working with IoT projects, one of the biggest limitations of the ESP32 is &lt;strong&gt;wireless range&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A single ESP32 using Wi-Fi usually communicates reliably within:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏠 50 – 100 meters indoors&lt;/li&gt;
&lt;li&gt;🌳 200+ meters outdoors (Line of Sight)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In real-world environments with walls and interference, communication often drops even earlier. ([Engineers Garage][1])&lt;/p&gt;

&lt;p&gt;But what if you need to send data across:&lt;/p&gt;

&lt;p&gt;✅ A farm&lt;br&gt;
✅ A large building&lt;br&gt;
✅ A robot fleet&lt;br&gt;
✅ A smart city setup&lt;br&gt;
✅ An off-grid monitoring system&lt;/p&gt;

&lt;p&gt;Buying expensive RF modules is not always necessary.&lt;/p&gt;

&lt;p&gt;👉 Instead, you can create a &lt;strong&gt;Mesh Network using multiple ESP32 nodes&lt;/strong&gt;.&lt;/p&gt;



&lt;p&gt;📡 What is the Idea?&lt;/p&gt;

&lt;p&gt;Instead of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ESP32 A  ----------------------  ESP32 B
        (too far ❌)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ESP32 A  →  ESP32 B  →  ESP32 C  →  ESP32 D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each ESP32 becomes a &lt;strong&gt;relay node&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every node:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receives data&lt;/li&gt;
&lt;li&gt;Rebroadcasts data&lt;/li&gt;
&lt;li&gt;Extends the network coverage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Military communication systems&lt;/li&gt;
&lt;li&gt;IoT Smart Cities&lt;/li&gt;
&lt;li&gt;Disaster recovery networks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;work in real life.&lt;/p&gt;




&lt;p&gt;🔥 Real World Test Results&lt;/p&gt;

&lt;p&gt;Using &lt;strong&gt;ESP-NOW protocol&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;~320 meters stable communication between two ESP32&lt;/li&gt;
&lt;li&gt;Up to &lt;strong&gt;500 meters using Long Range Mode&lt;/strong&gt; outdoors ([Makiuto][2])&lt;/li&gt;
&lt;li&gt;Theoretical range can reach &lt;strong&gt;1 km in ideal conditions&lt;/strong&gt; ([Engineers Garage][1])&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now imagine:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Number of Nodes&lt;/th&gt;
&lt;th&gt;Approx Coverage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2 ESP32&lt;/td&gt;
&lt;td&gt;300 – 500 m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 ESP32&lt;/td&gt;
&lt;td&gt;600 – 1000 m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5 ESP32&lt;/td&gt;
&lt;td&gt;1.5 – 2 km&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10 ESP32&lt;/td&gt;
&lt;td&gt;Entire village 🌍&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each node simply forwards the message to the next one.&lt;/p&gt;

&lt;p&gt;This technique is called:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Multi-Hop Communication&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;🧠 Real Use Cases&lt;/p&gt;

&lt;p&gt;This technique is already used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🐄 Smart agriculture sensor networks&lt;/li&gt;
&lt;li&gt;🚒 Emergency rescue communication&lt;/li&gt;
&lt;li&gt;🏭 Industrial automation monitoring&lt;/li&gt;
&lt;li&gt;🤖 Multi-robot coordination&lt;/li&gt;
&lt;li&gt;🌲 Forest fire detection systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;/p&gt;

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




&lt;h2&gt;
  
  
  ⚙️ Required Hardware
&lt;/h2&gt;

&lt;p&gt;You only need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2 or more ESP32 boards&lt;/li&gt;
&lt;li&gt;Power source (Battery / Solar)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No:&lt;/p&gt;

&lt;p&gt;❌ Router&lt;br&gt;
❌ Internet&lt;br&gt;
❌ SIM card&lt;br&gt;
❌ Gateway&lt;/p&gt;

&lt;p&gt;ESP-NOW allows up to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;20 devices without encryption&lt;/li&gt;
&lt;li&gt;10 encrypted nodes communicating directly ([Engineers Garage][1])&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;🧪 Basic ESP-NOW Relay Example&lt;/p&gt;

&lt;p&gt;📍 Sender Node&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;esp_now_send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;receiverMac&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;📍 Relay Node (Receiver + Forwarder)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;OnDataRecv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;incomingData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;len&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;incomingData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

   &lt;span class="c1"&gt;// Forward to next ESP32&lt;/span&gt;
   &lt;span class="n"&gt;esp_now_send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nextNodeMac&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;📍 Final Receiver Node&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the message travels across multiple ESP32 like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sensor → Node1 → Node2 → Node3 → Base Station
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;📉 Trade-Offs&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Advantage&lt;/th&gt;
&lt;th&gt;Limitation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No internet needed&lt;/td&gt;
&lt;td&gt;Lower bandwidth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Low power&lt;/td&gt;
&lt;td&gt;Needs node placement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Long distance&lt;/td&gt;
&lt;td&gt;Small packet size (~200B)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Very cheap&lt;/td&gt;
&lt;td&gt;Network planning required&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;🛰️ Bonus: Range Optimization Tips&lt;/p&gt;

&lt;p&gt;To push your network even further:&lt;/p&gt;

&lt;p&gt;✔ Enable Long Range WiFi Mode&lt;br&gt;
✔ Use external antennas&lt;br&gt;
✔ Increase retransmission attempts&lt;br&gt;
✔ Place relay nodes at height&lt;br&gt;
✔ Avoid metal obstacles&lt;/p&gt;

&lt;p&gt;Some hobbyists even reported &lt;strong&gt;&amp;gt;1km line-of-sight using LR mode and antennas&lt;/strong&gt; in field tests.&lt;/p&gt;




&lt;p&gt;🏁 Conclusion&lt;/p&gt;

&lt;p&gt;By creating a &lt;strong&gt;Mesh Network of ESP32 nodes&lt;/strong&gt;, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiply your communication range&lt;/li&gt;
&lt;li&gt;Eliminate infrastructure costs&lt;/li&gt;
&lt;li&gt;Build scalable IoT systems&lt;/li&gt;
&lt;li&gt;Deploy networks in remote areas&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All using a $5 microcontroller.&lt;/p&gt;




&lt;p&gt;If you're building:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart farming systems&lt;/li&gt;
&lt;li&gt;Drone communication&lt;/li&gt;
&lt;li&gt;Industrial monitoring&lt;/li&gt;
&lt;li&gt;Home automation across buildings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then ESP32 Mesh Networking is a game changer.&lt;/p&gt;

&lt;p&gt;Happy Building 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.engineersgarage.com/what-is-esp-now/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://makiuto.github.io/p/esp-now-range-test-real-world-results-for-esp32-devices.html/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://forum.mysensors.org/topic/12127/zhnetwork-a-esp-now-based-mesh-network-for-esp8266-esp32-hardware/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>iot</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
