There's nothing more simple than the concept of a wireless mesh network... but there's nothing more complex than building such a mesh. A steep learning curve is involved ( and, worst af all, the examples you may find never cover the whole story ) !
Here the steps to build your mesh ( we will cover each separately ):
1) build the mesh between nodes - easy
2) add ota ( wireless ) update of the nodes - intermediate
3) add a bridge ( to the internet ) - intermediate
4) an app ( to access the mesh from anywhere ) - intermediate
Let's start from the first step.
Parts required- ESP32 development boards ( two or more ), I used a ttgo t-display
- PlatformIO development software ( install from here)
- PainlessMesh library
After programming the boards with the node software you should have something like this
NOTE: You should program one board with the WHITE define enabled ( line 22 ) and the other board with the RED define enabled ( line 23 )
The code simply:
- creates a wireless mesh ( see defines in line 15-17 )
- writes the software version, the id of the node and the number of nodes in the mesh on the first 3 lines ( yes I know is the number of the 'other nodes' in the mesh, but I was too lazy to add 1 to the value returned by nodes.size() )
- writes the message received on the fourth line
- broadcasts a message ( to all the other nodes ) every time the lower button is pressed
Now you can add other nodes and they will be automatically discovered and added to the mesh ( after a small delay )
Mesh testingNow you know that the nodes ( a few inches apart ) on your desk are able to communicate.
So lets space a node until it is out of the mesh range ( until the mesh node count decreases ) now add a new node 'in between', a green node, ( let's call it 'the-node-in-the-middle' attack )... and after a small delay... the node is automagically reconnected.
Good job, your mesh is indeed self configuring, self healing, self recovering...
NOTE It is never a good idea to keep the nodes too close to each other ( as shown on the video ;-)
What Next?This is the first ( and easy ) step of our job.
In the next step we'll continue adding ota support.
MeshLamp ( fast and easy project )If you are not happy with the basic node software proposed let's see how easily we can control a lamp with a switch using our wireless mesh.
Parts Required
Same as above
Programming
After programming the boards with the MeshLamp software you should have something like this
NOTE: You should program both boards with the same software ( and yes both boards are switch and lamp at the same time )
The code simply:
- creates a wireless mesh ( see defines in line 15-17 )
- the lower button toggle the associated lamp ( or all lamps if no association performed )
- the higher button perform the association: short press on the lamp, long press on the switch and the association is completed
I do not recommend any hardware or software
The ttgo t-display I used is a small and inexpensive ESP32 board, with a small color display ( 240x135 ), onboard antenna ( sorry no external antenna connector ), tp4054 battery charger, cp2014 usb converter, no sd slot, small form factor. It becomes quite warm during usage. Can't say nothing about its reliability. Here you can find a small documentation.
Comments