title: "danpeig/node-red-meshtastic-msg: Node-RED Meshtastic Messages Node"
source: https://github.com/danpeig/node-red-meshtastic-msg
author:
- "[[GitHub]]"
published:
created: 2025-05-10
description: Node-RED Meshtastic Messages Node. Contribute to danpeig/node-red-meshtastic-msg development by creating an account on GitHub.
tags:
- lora
Node-RED Meshtastic Messages Node
This node allows sending and receiving packets to a Meshtastic mesh network thru a device connected via HTTP. It is based on Meshtastic.js library.
.npmrc
with the following content @jsr:registry=https://npm.jsr.io
and place it inside the Node-RED base directory (where the working settings.js
file is located). If the file already exists, append the content as a new line.@danpeig/node-red-meshtastic-msg
in the community library or NPM.node-red-meshtastic-msg
inside the Node-RED base directory (where the settings.js
file is located)npm install ./node-red-meshtastic-msg
meshtastic-msg.js
and change the relative path of the Meshtastic library according to the existing directory structure. Example: importSync("../node_modules/@meshtastic/js/dist/index.js")
.To uninstall, run npm remove @danpeig/node-red-meshtastic-msg
from the same base directory.
Meshtastic.js library has some bugs and can crash the Node-RED server in the following scenarios:
wantResponse
flag set to true
meshtastic-msg.js
and change the path of the ImportSync to the location where Meshtastic library was installed. Example: importSync("../../@meshtastic/js/dist/index.js")
..npmrc
with the following content @jsr:registry=https://npm.jsr.io
and place it inside the Node-RED base directory (where the settings.js
file is located). If the file already exists, append the content as a new line at the end.The experiments_meshtastic.js
illustrates how to use Meshtastic.js library from plain Javascript (No TypeScript, no React, no compilation, no nothing).
This node was created by Daniel BP and is available under the MIT license.
@meshtastic/js
version to 2.5.9-3: this should fix some loop and HTTP connection errors.@meshtastic/js
version to 2.5.9-2. This should fix protobuf decoding errors with the latest device firmware.This information can also be found in the specific node help pages, directly from Node-RED interface.
Send a text message to the mesh connected device
msg.payload
(string): the text message to be sent to the network[msg.channel]
(integer): the Meshtastic channel number. Defaults to 0 (primary)[msg.destination]
(integer): the destination node number, broadcast or self. Defaults broadcast[msg.wantAck]
(boolean): if the receiving devices should acknowldege receipt. Defaults to true[] = optional fields
Receive a text message from the mesh connected device
msg
(json): object with all package propertiesmsg.payload
(string): text content of the messageReceive the status code of the Meshtastic device
msg.payload
(integer): status code of the deviceThis node will watch for the defined event and output the payload received. Typically, the output should be a JSON field but there are some events that report numbers or simple strings. The events list comes from Mesthastic.js Event System Class
event
(string): select the event to monitor/watchmsg
(json): data from the eventSend a packet to the mesh connected device. Input packet can be either in the string format (msg.payload) or Uint8Array (msg.byteData) format.
msg.payload
(string): Will be converted to Uint8Array and used if byteData field is not set[msg.byteData]
(json): Data properly encoded as Uint8Array. If set, will be used instead of payload. Example [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33][msg.portNum]
(integer): Application number. Defaults to 1 (text messsage app).[msg.destination]
(integer string): Destination node number, broadcast or self. Detaults to broadcast[msg.channel]
(integer): Channel number, defaults to 0 (primary channel)[msg.wantAck]
(boolean): Confirmation, defaults to true[msg.wantResponse]
(boolean): Defaults to false[msg.echoResponse]
(boolean): Defaults to false[msg.replyId]
(integer): Defaults to null[msg.emoji]
(integer): Defaults to null[] = optional fields
Output the log from Mesthastic.js library. Usefull for debug purposes and connection status info.Note: This is not Node-RED log neither the Lora device log.
msg
(json): object with all log message propertiesmsg.payload
(string): text content of the log entry (fields [0] and [1] concatenated)This will setup the connection to the Meshtastic node. The connection protocol is HTTP. Serial, Bluetooth or MQTT are not supported.
IP or hostname
(string): IP address or hostname of the Meshtastic device to connect. Examples: 192.168.0.15, meshtastic.localUse TLS
(boolean): If true, the connection will be performed using TLS (encrypted). Default is false as most of the devices are not configured for it.Fetch interval
(integer): Interval between polling data from the device. Default is 5000ms.No packages published