
(Adapted from: https://gitlab.com/painlessMesh/painlessMesh)
The Meshquitto’s mesh network is based on the painlessMesh’s setup of a mesh network with ESP8266 and ESP32 devices. As the name says it, Meshquitto uses the MQTT protocol and connects the mesh network to the outside network by using the Meshquitto gateway.
Hence, before we look at the Meshquitto network, let’s understand the painlessMesh setup.
painlessMesh is a library that takes care of the particulars of creating a simple mesh network using esp8266 and esp32 hardware. The goal is to allow the programmer to work with a mesh network without having to worry about how the network is structured or managed. Interestingly to know, painlessMesh is based on easyMesh.
True ad-hoc networking
painlessMesh is a true ad-hoc network, meaning that no-planning, central controller, or router is required. Any system of 1 or more nodes will self-organize into fully functional mesh. The maximum size of the mesh is limited (we think) by the amount of memory in the heap that can be allocated to the sub-connections buffer and so should be really quite high.
JSON based
painlessMesh uses JSON objects for all its messaging. There are a couple of reasons for this. First, it makes the code and the messages human readable and painless to understand and second, it makes it painless to integrate painlessMesh with javascript front-ends, web applications, and other apps. Some performance is lost, but I haven’t been running into performance issues yet. Converting to binary messaging would be fairly straight forward if someone wants to contribute.
Wifi & Networking
painlessMesh is designed to be used with Arduino, but it does not use the Arduino WiFi libraries, as we were running into performance issues (primarily latency) with them. Rather the networking is all done using the native esp32 and esp8266 SDK libraries, which are available through the Arduino IDE. Hopefully though, which networking libraries are used won’t matter to most users much as you can just include painlessMesh.h, run the init() and then work the library through the API.
painlessMesh is not IP networking
painlessMesh does not create a TCP/IP network of nodes. Rather each of the nodes is uniquely identified by its 32bit chipId which is retrieved from the esp8266/esp32 using the system_get_chip_id() call in the SDK. Every node will have a unique number. Messages can either be broadcast to all of the nodes on the mesh, or sent specifically to an individual node which is identified by its’ nodeId.
Dependencies
painlessMesh makes use of the following libraries, which can be installed through the Arduino Library Manager
· ArduinoJson
· TaskScheduler
· ESPAsyncTCP (ESP8266)
· AsyncTCP (ESP32)
For more details on painlessMesh: https://gitlab.com/painlessMesh/painlessMesh