MeshCore plugin development
Build custom modules and extend MeshCore functionality with your own plugins
What is MeshCore plugin development?
MeshCore features a modular plugin architecture enabling developers to extend mesh network functionality without modifying core firmware. With plugins you can add custom features such as integrating sensors, logging data, calling external APIs, and considerably more.
The plugin API provides hooks into the firmware lifecycle, allowing you to react to events such as messages received, nodes detected, telemetry updates, and routing decisions. This renders MeshCore exceptionally flexible for specific use cases.
Whether you want to connect a weather station, build an automatic emergency alert system, or create custom visualisations, MeshCore plugins make it achievable. This guide demonstrates how to commence plugin development.
Plugin architecture overview
MeshCore plugins are based on an event-driven architecture with clearly defined interfaces
Plugin manifest
Every plugin begins with a manifest file defining metadata and capabilities:
Event handlers
Plugins register handlers for specific events in the mesh:
State management
Plugins can store persistent state in the firmware:
API integration
Access to MeshCore core functionality via plugin API:
Plugin development step by step
From setting up development environment to deploying your first plugin
Step 1: set up development environment
Clone the MeshCore repository and set up the build tools:
cd MeshCore
git submodule update --init --recursive
pip install platformio
pio run
Step 2: create plugin skeleton
Create a new plugin folder with the basic files:
touch src/plugins/myPlugin/plugin.json
touch src/plugins/myPlugin/myPlugin.h
touch src/plugins/myPlugin/myPlugin.cpp
Step 3: configure plugin manifest
Define your plugin metadata in plugin.json:
Step 4: implement plugin logic
Write your plugin code in C++ and implement the event handlers you require. Register callbacks for events such as messages received, nodes detected, or telemetry updates.
Step 5: build and test
Compile the firmware with your plugin and flash to a test device. Test your functionality thoroughly and debug any issues with serial monitor.
Example: temperature sensor plugin
A simple plugin that reads a DHT22 sensor and transmits temperature via mesh
How does this work?
This plugin reads temperature and humidity from a DHT22 sensor every minute and broadcasts it via the mesh network. It also responds to "TEMP_REQUEST" messages by immediately sending a temperature reading back to the requester.
Popular plugin types
Sensor integration
Connect external sensors (temperature, GPS, pressure) and transmit data via mesh
Data logging
Log mesh events to SD card or external database for analysis
Notification systems
Send automatic alerts based on mesh events or sensor values
Mapping plugins
Visualise network topology, node positions, and Signal strength
Protocol bridges
Connect MeshCore to other networks (WiFi, LoRaWAN, MQTT)
Automation
Build bots that automatically respond to messages or events
Best practices for plugin development
Follow these guidelines to build stable and performant plugins
-
β
Keep plugins small and focused - A plugin should do one thing well, not everything at once
-
β
Respect resource limits - ESP32 has limited memory and CPU; optimise your code
-
β
Use async patterns - Never block the main loop; use callbacks and timers
-
β
Implement error handling - Catch exceptions and log errors clearly
-
β
Document your API - Write clear comments and a README for users
-
β
Test thoroughly - Test on real hardware and in different network conditions
Frequently asked questions
In which programming language do I write MeshCore plugins?
MeshCore plugins are written in C/C++ because the firmware runs on embedded hardware (ESP32, nRF52). You can also use Python for external plugins that communicate with the firmware via serial or MQTT.
Can I use existing arduino libraries in my plugin?
Yes, most Arduino libraries are compatible with MeshCore because it is built on the Arduino framework. Simply watch out for library conflicts and memory usage.
How do I debug my plugin during development?
Use the serial monitor in PlatformIO for debug output. You can use Log.info(), Log.debug(), and Log.error() for structured logging. You can also use a hardware debugger (like J-Link) to set breakpoints.
Can plugins modify radio configuration?
Yes, with appropriate permissions plugins can alter radio parameters such as transmission power, spreading factor, and bandwidth. This should be done carefully to maintain network stability.
How do I distribute my plugin to other users?
You can share your plugin as a folder with code plus plugin.json via GitHub. Users can then add your plugin to their firmware build and compile themselves. A plugin marketplace may arrive in future.
Can I earn money with plugins?
MeshCore is open source, but you can create commercial plugins if desired. Many developers choose an open source plus donations model, or sell support and custom development.
Start with MeshCore plugin development
With the plugin API you can customise MeshCore for your specific use case without modifying the core firmware
Start building your first plugin today and share your creations with the community!