The ESP32 microcontroller earns plenty of praise for delivering wireless connectivity, generous features, and solid performance at minimal cost. It's become a backbone to my smart home devices and sensors. A growing number of smart devices adds a strain on my Wi-Fi network. Upgrading to high-end network gear can fix that, but I wanted to confirm if my setup needs that before jumping the gun.
That search led me to a project that lets me create a Wi-Fi-free mesh network using only ESP32 boards. It relies on ESP-NOW, a lightweight peer-to-peer protocol for ESP32 and ESP8266 devices to communicate without using a router or access point. With the zh_network library, I extended the functionality of ESP-NOW to create a mesh network. Here’s how I built a Wi-Fi-free ESP-NOW-based mesh network with ESP32 boards, and what you can expect if you follow the same approach.
7 sensors under $10 that completely changed my smart home
You don't need to splurge to build a smart home
A pure ESP-NOW mesh that doesn’t use Wi-Fi
Consists of ESP32 boards only
The ESP32 boards communicate over ESP-NOW without using traditional Wi-Fi. Those boards stay in station mode, using the ESP-NOW protocol’s peer-to-peer packet exchange to communicate directly with one another via MAC addresses. Also, they don’t connect to an access point or use any Wi-Fi channel, even though they operate at 2.4 GHz.
The goal is to create a mesh network in which ESP32 boards exchange messages without using my Wi-Fi router. The zh_network library adds an overlay over the existing ESP-NOW’s peer-to-peer protocol. The library turns ESP32 into an ESP-NOW node to form a routed mesh network. It manages packet forwarding and routing internally, so there's no need for any peer list or MAC address table. This approach makes it different from ESP-MESH, which relies on Wi-Fi channels, Wi-Fi beacons, and AP/STA roles.
A Wi-Fi-free mesh is suitable for low-power sensors and small, battery-powered devices. Also, it extends the range of my smart home where my home Wi-Fi can't reach.
What you’ll need to build an ESP-NOW-based mesh network
ESP32 boards with Wi-Fi support
The basic requirement of the zh_network is an ESP32 board with Wi-Fi capability. The ESP32-H2, which lacks Wi-Fi support, won’t work. Also, you’ll need compatible USB cables and power sources, depending on where you plan to deploy them.
To prepare ESP32 firmware, you can either use Arduino IDE or PlatformIO. I used the PlatformIO IDE extension since I already use VSCode. After creating a new PlatformIO project, I defined the zh_network, and zh_vector libraries in the platformio.ini file to build it and adjusted the configuration for each ESP32 board. But first, I had to find ESP32's MAC addresses using a small script that outputs the values in Hex format, which I then manually converted to an array format.
During firmware setup for sensor nodes, I defined the MAC addresses of all the ESP32 boards with specific sensors connected to them. Flashing the same firmware on the ESP32 boards without any sensors turned them into relays. For the gateway node, I added an MQTT component to the ESP32’s firmware to forward the messages to an MQTT server running in Home Assistant. Testing and writing code took me several hours since I don’t do it often. But flashing multiple ESP32 devices only took a few minutes.
Here’s how the mesh network behaves: The sender nodes capture data when the sensor is triggered, package it, and transmit it to the nearest node. Relay nodes act as intermediaries, validating messages before forwarding to reduce noise. Finally, the gateway node does the heavy lifting of decoding the received message and passes the payload via MQTT to Home Assistant.
Real-world applicability and limitations of the mesh
Scale determines performance
Since I had to predefine the messages, the scalability and size of the packet to forward were quite limiting. Only On/Off and Open/Close-like messages were suitable for quick transmission. Also, adding too many nodes meant the messages would keep bouncing back and forth, and the routing efficiency would diminish. That also bumped up the multi-hop latency. Since I was using more than two nodes, I needed to define the Wi-Fi channel, so the nodes could hear each other easily.
The zh_network’s developer also offers the zh_gateway library, but it works only with the ESP32 ESP-IDF v5.2 version. It broke things when I tried using the latest ESP-IDF version. So, I steered clear and preferred defining the MQTT values directly in the Gateway node’s firmware.
6 projects you can complete in a weekend with the $5 ESP32
The ESP32 is affordable and powerful, and there's a lot you can do with one.
Is a Wi-Fi-free ESP32-based mesh worth it?
Totally doable and surprisingly fun, especially for low-power sensors and battery-powered smart devices. Of course, it depends on ESP-NOW's bandwidth and range, as well as the requirement that the ESP32 be on the same channel. It’s a practical and inexpensive experiment that took the load off my home router. But then it proved that a smart home upgrade doesn't need costly network gear. A handful of ESP32 boards can tackle the range problem.
- Brand
- AITRIP
- Connectivity Features
- UART, USB
The ESP32 is a fantastic development board that combines solid specs with an affordable price. Despite being cheaper than Arduino and Raspberry Pi Pico, it outperforms most of its rivals. Plus, the ESP32 even has Wi-Fi and Bluetooth functionality built into every board, making it great for projects where you can't physically keep the microcontroller connected to your PC at all times.
