MeshCore plugin development
Build custom modules and extend MeshCore functionality with your own plugins
What is MeshCore plugin development?
MeshCore has a modular plugin architecture that allows developers to extend the mesh network functionality without modifying the core firmware. With plugins you can add custom features like integrating sensors, logging data, calling external APIs and more.
The plugin API provides hooks into the firmware lifecycle allowing you to react to events like messages received, nodes detected, telemetry updates and routing decisions. This makes MeshCore extremely flexible for specific use cases.
Whether you want to connect a weather station, build an automatic emergency alert system or create custom visualizations - MeshCore plugins make it possible. This guide shows you how to get started with plugin development.
Plugin architecture overview
MeshCore plugins are based on an event-driven architecture with clearly defined interfaces
Plugin manifest
Every plugin starts with a manifest file that defines 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 setup the build tools:
cd meshcore-firmware
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 need. Register callbacks for events like 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 sends 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 send 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
Visualize 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, optimize 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. You just need to 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 the right permissions plugins can change radio parameters like transmit 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 + plugin.json via GitHub. Users can then add your plugin to their firmware build and compile themselves. A plugin marketplace may come in the future.
Can I make money with plugins?
MeshCore is open source, but you can create commercial plugins if you want. Many developers choose an open source + donations model, or sell support and custom development.
Start with MeshCore plugin development
With the plugin API you can customize MeshCore for your specific use case without modifying the core firmware
Start building your first plugin today and share your creations with the community!