m2mMesh is an Arduino library that provides a self-organising machine-to-machine (m2m) mesh network between Espressif ESP8266/8285/32 microcontrollers, using ESP-Now as a transport.
It was written to allow small, cheap microcontroller based projects to communicate with no need for 'infrastructure' or 'servers'. None of the communication across the mesh is encrypted. Do not use the m2mMesh to send sensitive information unless you encrypt the payload before adding it to a message. There is an aspiration to optionally support encryption of the payload.
Beware m2mMesh is still riddled with problems that need addressing and various features may change in both style and internal implementation, so it has not been submitted for inclusion in the Arduino Library Manager yet.
m2mMesh abstracts away a lot of unpleasantness around mesh networking to try and make it easy to implement in an Arduino project.
The library was written to allow networking between large numbers of cheap battery powered devices over a small-ish outdoor area that would nonetheless be hard to cover with conventional Wi-Fi. For long range communication or long battery life another technology, eg. LORA is better suited.
Member nodes can have 'names' and you then package and send data to the name (or MAC address) and the library keeps everything ticking over in the background. The mesh also generates a shared 'time signal' and optionally propagates an RTC for syncing events across nodes.
By using ESP-Now there is no need for Wi-Fi access points and there can be multiple routes to a destination which are tolerant to changing conditions, moving nodes and unreliable transmission. There is a general aspiration to allow other transports on other microcontrollers but the low cost, high performance and ubiquity of the Espressif devices means it hasn't been tackled yet.
The resulting mesh network does not offer 'Internet access' for other devices, it is intended purely for machine-to-machine (m2m) communication, though one or more nodes can act as bridges into other messaging protocols such as MQTT.
In principle m2mMesh appears to overlap with Espressif's ESP-Mesh library, but this is focused on IoT connectivity and expects 'controller' and 'gateway' nodes. m2mMesh is non-IP, completely self-organising and 'flat'.
The routing protocol behind the scenes is inspired by Open-Mesh and the routing algorithm is a simplified hybrid of the B.A.T.M.A.N. III and IV algorithms, but shares no code.
m2mMesh nodes can also speak conventional Wi-Fi and IP, connecting to, or acting as access points but care should be taken to ensure they do not become isolated on different channels from the other nodes. Presently all nodes in the mesh must be on the same Wi-Fi channel.
This is the very first public release, which is working for the specific project I wrote it for. However I'm aware my naming of methods, approaches to passing arguments and so on are messy and inconsistent so some of this may change frequently. This is reflected in the version numbering, which is currently 0.1.0.
From the project page, select 'Code' -> 'Download ZIP' and save the file somewhere appropriate.
You can then install in the Arduino IDE by choosing 'Sketch' -> 'Include Library' -> 'Add .ZIP Library...'.
You are strongly recommended to try the various examples before starting work on your own application using it.
The only dependency is on the ESP-Now library in the Espressif SDK, which should be present in the Arduino core. You will need version 2.5.2 or higher of the ESP8266 Arduino core, but this is now quite old.
This project is hosted on GitHub.
In order to make this library accessible to 'casual' programmers who are likely to be using the Arduino IDE (I'm one myself) there are many examples included. You only need 2-3 Espressif devices to be able to try all the features of m2mMesh. All these examples show things happening in the Serial console.
From the project page, select 'Code' -> 'Download ZIP' and save the file somewhere appropriate.
You can then install in the Arduino IDE by choosing 'Sketch' -> 'Include Library' -> 'Add .ZIP Library...'.
Once the library API is stable it will be submitted to the Arduino Library Manager for inclusion.
Documentation for m2mMesh is included as markdown in the 'docs' directory but also as README.md files included with every example which will give you a quicker start.
This project uses Semantic Versioning to be compatible with the Arduino library standards.
For a list of available versions, see the repository tag list. There is also the changelog.
Fixed compilation for ESP32-C3 target, which has very slight change in Espressif SDK from other ESP32 versions.
Improved methods for retrieving arrays from messages.
First public release.
Drop me a message on m2mMesh@arcanium.london, I can't promise to be super-responsive but I'll try.
I'd love to get help with this work, either drop me a message here or on m2mMesh@arcanium.london. I'm new to using git for collaboration so please be patient.
We encourage public contributions! Please review CONTRIBUTING.md for details on our code of conduct and development process.
The Espressif ESP-Now resources are helpful.
Copyright (c) 2021 Nick Reynolds
This project is licensed under the GNU Lesser General Public License - see LICENCE.md file for details.
This library was inspired by the work done by others on PainlessMesh and Open-Mesh. As mentioned in the documentation the routing algorithm is a simplified hybrid of the B.A.T.M.A.N. III and IV protocols, but shares no code.