Node-RED Flows for Mesh Automation
Overview
Node-RED is a visual flow-based programming tool that acts as powerful middleware between your Meshtastic MQTT feed and virtually any other service. It runs on Linux (including Raspberry Pi), inside Home Assistant, or on any Node.js-capable machine.
Installing Node-RED
Standalone on Raspberry Pi / Linux:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
sudo systemctl enable nodered
sudo systemctl start nodered
Access the editor at http://your-pi-ip:1880.
In Home Assistant: Install the Node-RED add-on from the add-on store. It integrates directly with your HA entities.
Core Flow Pattern 1: Message Logger
This flow captures all text messages from Meshtastic and writes them to a log file.
[MQTT In] → [JSON Parse] → [Function: format line] → [File Write]
MQTT In topic: msh/US/2/json/text/#
Function node:
msg.payload = new Date().toISOString() + " [" +
msg.payload.from.toString(16).toUpperCase() + "] " +
msg.payload.payload.text + "
";
return msg;
File node: /home/pi/mesh_log.txt (append mode)
Core Flow Pattern 2: Position Tracker to Google Sheets
Filter position packets by a specific node ID and push lat/lon to a Google Sheet via the Sheets API node (node-red-contrib-google-sheets).
[MQTT In] → [JSON Parse] → [Switch: msg.payload.from == targetNodeId]
→ [Function: build row] → [Google Sheets: append row]
Function node:
var pos = msg.payload.payload;
msg.payload = [
new Date().toISOString(),
pos.latitude_i / 1e7,
pos.longitude_i / 1e7,
pos.altitude
];
return msg;
Core Flow Pattern 3: Two-Way Bridge - Meshtastic ↔ Telegram
Install node-red-contrib-telegrambot. This flow forwards incoming mesh messages to a Telegram chat and relays Telegram replies back to the mesh channel.
Meshtastic → Telegram:
[MQTT In: msh/US/2/json/text/#] → [JSON] → [Function: build TG msg]
→ [Telegram Sender]
Telegram → Meshtastic:
[Telegram Receiver] → [Function: build MQTT payload]
→ [MQTT Out: msh/US/2/json/text/!gatewayNodeId]
The outbound MQTT payload must match the Meshtastic JSON envelope format with a valid from node ID for your gateway node.
Emergency Channel SMS Forwarding via Twilio
Install node-red-contrib-twilio. Watch a dedicated emergency channel (channel index 1, for example) and forward any message to a phone number via SMS:
[MQTT In: msh/US/2/json/text/#] → [JSON] → [Switch: channel_id == 1]
→ [Function: format SMS] → [Twilio: send SMS]
Function node:
var from = msg.payload.from.toString(16).toUpperCase();
msg.payload = "MESH EMERGENCY from !" + from + ": " +
msg.payload.payload.text;
return msg;
Set the Twilio node with your Account SID, Auth Token, and destination phone number. This pattern is valuable for community emergency nets where responders may not be watching the mesh app.
No comments to display
No comments to display