Mesh Networking: How Nodes Relay Data for Each Other
In a mesh, no node is the centre. Every node can forward packets for the others, so coverage grows one hop at a time instead of one router at a time.
How a mesh actually forms
When a node switches on, it listens. Neighbours notice it, and after a short exchange each one builds a picture of who is within range and how strong that link is. That picture is the mesh. There is usually no central controller deciding the topology, and there may not even be a fixed list of routes, because the network is allowed to change as nodes move or die.
The forwarding method that Bluetooth Mesh uses is managed flooding. A node that needs to send a message broadcasts it with a hop limit, usually 3 to 127, and a sequence number. Any node that receives it checks two things: has it seen this sequence number before, and is the hop count still above zero. If both are true it rebroadcasts it, which means the message spreads outwards in every direction until it reaches the edge of the network. The important consequence is that reliability and cost are traded against each other. A flooded message is sent many times, so delivery is very likely, but every node in the path spends airtime retransmitting it, and the latency grows with the number of hops. ESP-MESH takes a different approach on Wi-Fi, building a tree of parent and child nodes, which is more efficient in a fixed building and less forgiving of nodes that move.
What a mesh costs you
Coverage is the obvious win. A node that cannot reach the gateway can still reach a node that can, so a building with five nodes can cover areas that two nodes cannot. This is why mesh is the standard answer for a sensor deployment across a large site.
Latency and power are the costs. Every relay is also a receiver, and a receiver is the most power-hungry state a radio has. A mains-powered relay node is easy. A battery node acting as a relay will not last. This is why most real deployments put the relays on the mains and keep the battery nodes as leaves, and why the profile of each node matters more in a mesh than in a star. There is a failure mode worth naming, because it surprises people: in a flooding mesh, a node can be perfectly healthy and still useless if every route to the gateway happens to pass through one node that is offline. The fix is redundancy. Overlap coverage so no single node is a bridge, and check that the network still reaches the gateway after you pull any one node out of it.
Step by step
-
Build a two-node link first
Get one message crossing between two boards with no router involved. This is the whole idea in its simplest form, and it should work before you add complexity.
-
Add a third node and watch the hop count
Print the hop count on each message as the topology changes. Seeing it rise and fall as nodes move is what makes the concept real.
-
Measure the range of one hop
Walk two nodes apart until messages stop arriving, and note the distance in different rooms. Indoors, expect tens of metres rather than hundreds.
-
Simulate a node failure
Switch off a middle node and watch the network route around it, or fail to. This is the redundancy conversation, and it is the one that matters for reliability.
-
Power a relay node from the mains
Compare the current draw of a relay node on battery and on USB power. The difference justifies the whole architecture in one measurement.
-
Scale to a small deployment
Add nodes around a room, log the hop count and the message loss over a day, and plot it. Real mesh data is never as tidy as the diagram.
What you'll need
| Item | Qty | Why |
|---|---|---|
| ESP32 DevKit boards | 4 | Four boards give a network with enough nodes for a genuine relay to be needed. |
| ESP32-S3 or ESP32-C3 node | 2 | A second chip family to compare against, and a lower power option for a battery leaf node. |
| DHT22 temperature sensor | 4 | Each node needs to originate its own reading, otherwise you are only testing the forwarder. |
| 5 V USB power supply with a short cable | 2 | Mains power for the relay nodes, which is where a relay belongs in a real deployment. |
| 18650 cell and protected holder | 2 | For the leaf nodes, so you can compare battery life between a leaf and a relay. |
| Breadboard and jumper wires | 1 set | You will rewire nodes constantly as you test the topology. |
Practise it before you build it
Every step above has a matching circuit in the ThinkEdge Learn simulator. The simulator runs a real
Arduino sketch against a modified-nodal-analysis solver, so digitalWrite actually drives the
LED on screen and the readings change when you change the wiring — no hardware, no burnt components.
The Mega has 4 hardware serial ports (Serial, Serial1, Serial2, Serial3). That means you can talk to 4 different devices at the SAME time — like a GPS, a Bluetooth module, an XBee radio, and the USB. Use 3 of those ports to read 3 different sensors in parallel and stream their data to the Serial Monitor as a CSV row every second. This is the foundation of every real Arduino data logger.
In factories, conveyor belts carry products past a sensor that counts them. A simple "break-beam" sensor (a light source + photodetector) registers each object as it passes. In this project, you'll simulate the conveyor with your hand: every time you press the button (mimicking a product passing the sensor), the counter increments and the LED blinks. Add a buzzer to beep once for every 10 items. This is the same logic as a people counter at a door, a coin counter at a bank, or a bottle counter on a bottling line.
Combine a PIR motion sensor with a slide switch (arm/disarm) and a buzzer. This is the same logic as a real home alarm: you arm the system when you leave, and if anything moves while it is armed, it sounds the alarm. We also use millis() to keep the alarm sounding for a fixed time even if the motion stops.
Mount an HC-SR04 ultrasonic sensor on top of a servo. Sweep the servo from 0° to 180° and back, and at each step measure the distance. Print the results to the Serial Monitor as "angle,distance" pairs. Open the Serial Plotter in the Arduino IDE to see a live radar-like graph of the room. With Processing on your computer, you can build a full visual radar.
An Arduino pin is not a power supply. Each GPIO pin is rated to source at most about 20 mA — that is the limit for one pin, and the whole chip together is limited to roughly 40 mA. A 5 V relay coil needs about 50 mA to pull its contacts closed, which is more than twice what a single pin will give. Wire the pin straight to the coil and you do not get a working relay; you get a pin running hot, a supply sagging under USB, and contacts that only just close. The fix is an NPN transistor. The pin drives the transistor's base through a resistor — only a few milliamps — and the transistor switches the full coil current. The relay then does the one thing it is genuinely better at than a transistor: its coil, carrying 50 mA, pulls a set of metal contacts that carry a completely separate circuit. Nothing in that second circuit ever touches the Arduino. That is galvanic isolation, and it is the reason the relay has survived fifty years of transistors — you can switch a high-voltage load from a 5 V logic signal without the two ever meeting.
Common questions
How many nodes can a mesh network handle?
The radio link and the flooding overhead set the limit rather than a hard number. In a classroom build, twenty to fifty nodes over a building is comfortable, and the real constraint is airtime: every flooded message is retransmitted by several nodes, so a chatty network saturates the channel. Keep reports infrequent and the mesh stays healthy.
Is BLE Mesh or ESP-NOW better for a school project?
ESP-NOW is simpler and quicker to get running, because it is just Wi-Fi peer to peer with a fixed peer list. Bluetooth Mesh is the standardised option with defined models for lighting, sensors and actuators, and it is what you would use if the project may grow into a real product. For a first build, ESP-NOW teaches the same idea with less setup.
What is the biggest problem with mesh networks?
Power. A relaying node is a receiver most of the time, and that is where the current goes. Design with mains-powered relays and battery-powered leaves, and the network is reliable. Design with everything on batteries and the mesh collapses within weeks, usually at the node that happened to be a relay.
Related guides
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. NCERT Science mapping on 47 projects, with Arabic and English copy in the regional builds.