Introduction: Painless Mesh on M5Stack Core2
In this project, I combine the touch.ino example included with the M5Core2 library and the basic.ino example included with the Painless Mesh library to demonstrate the mesh network capabilities of the M5Stack Core2. The result is touchWithPainlessMesh.ino, which enables M5Stack Core2 hardware to broadcast color values based on touch point data to other M5Stack Core2 hardware on the network. Other hardware on the network will change their screen background color according to the color values they receive, and they display that value on their screens, along with the number of nodes on the network and the last touch point.
You can find documentation about M5Stack Core2 hardware (and other M5Stack products) at this link:
Info about the Painless Mesh library can be found on their GitLab page at this link:
If you aren't familiar with Arduino, you can get started here:
- Arduino-capable computer with Arduino IDE installed
- 2 (at least) M5Stack Core2
Step 1: M5Stack Core2 Setup
Follow the M5Stack Core2 Quick Start with Arduino guide at this link:
Once you have completed this guide, test it out by installing and running one of the examples included under the "Examples for M5Stack-Core2" header at File->Examples in the Aurdino IDE.
If you can open, build, and run one of the examples, you're good! You can find more detail on teh M5Stack Core2 libraries at the dedicated GitHub page here:
Step 2: Set Up Painless Mesh
Follow this guide on installing additional Arduino libraries:
and use info from the Panless Mesh GitLab page here:
to install the Painless Mesh library for ESP32 devices. After installing the library, you can test it by building the basic.ino example found at File->Examples->under the "Examples from Custom Libraries" head->Painless Mesh.
But be careful! The M5Core2 board setup uses serial communications to drive the display. To get the basic.ino example to build for M5Stack Core2 hardware, you will have to comment out all of the serial lines in the file.
Step 3: Download and Test TouchWithPainlessMesh.ino
Follow the link below to my GitHub, where you can grab touchWithPainlessMesh.ino:
If you properly set up your Arduino IDE and installed the required additional libraries in the previous steps, you should be able to build this .ino file and run it on your M5Stack Core2 hardware!
Once you have the file working, you can use it as a launching point to power your M5Stack Core2 mesh networking projects. Let me know in the comments if you end up using it in anything!