IoT & Integration

MeshCore MQTT integration

Connect your MeshCore network with IoT platforms via MQTT for data export, automation and integration with external systems

What is the MQTT bridge?

The MQTT bridge in MeshCore allows you to export messages and telemetry to an MQTT broker. From there you can forward data to IoT platforms like Home Assistant, Node-RED, InfluxDB, Grafana, and more.

MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe protocol perfect for IoT. MeshCore nodes can act as gateway: they receive messages via LoRa and publish them to MQTT topics. This opens a world of integration possibilities.

In this guide we explain how to configure MQTT, how message formatting works, and what practical applications exist. Whether you want to connect a smart home or visualize data in Grafana, MQTT makes it possible.

How the MQTT bridge works

๐Ÿ“ก

1. Node receives LoRa message

Your MeshCore node (gateway) receives messages via LoRa radio from other nodes in the mesh network.

๐Ÿ”„

2. Convert to JSON

The node converts the Protobuf message to readable JSON format with all metadata and payload data.

๐Ÿ“ค

3. Publish to MQTT

The JSON message is published to an MQTT topic on your broker. Other systems can subscribe to these topics.

Setting up MQTT bridge

To use MQTT you need an MQTT broker (like Mosquitto) and a MeshCore node acting as gateway. Follow these steps:

Step 1: Install MQTT broker

Install Mosquitto on a Raspberry Pi, server, or use a cloud broker like mqtt.meshtastic.org (free but public!). Local broker is recommended for privacy: sudo apt install mosquitto mosquitto-clients

Step 2: Configure node MQTT settings

Via the MeshCore app or CLI, configure MQTT settings: broker address (e.g. 192.168.1.100), port (1883), username/password (optional), and enable MQTT.

Step 3: Choose MQTT root topic

Messages are published to msh/EU_868/2/c/LongFast/!nodeid. The root (msh/) is configurable. You can set a custom prefix for your network.

Step 4: Test the connection

Subscribe to all topics: mosquitto_sub -h localhost -t "msh/#" -v. Send a test message via MeshCore app. You should see the message appear in JSON format.

Practical applications

๐Ÿ 

Home Assistant integration

Trigger automations in Home Assistant based on MeshCore messages. For example: light on when someone sends "home" via mesh.

๐Ÿ“Š

Grafana dashboards

Export telemetry to InfluxDB and visualize in Grafana. Monitor battery levels, temperature, GPS tracks of all nodes.

๐Ÿ””

Alert notifications

Send push notifications to your phone via Telegram, Discord, or Pushover when certain messages arrive.

๐ŸŒ

Web dashboards

Build custom web interfaces showing real-time data from the mesh network. Subscribe via WebSocket to MQTT topics.

๐Ÿ’พ

Data logging

Log all messages to a database for historical analysis. See network activity over time, track node movements.

๐Ÿ”—

Multi-network bridging

Connect multiple MeshCore networks via MQTT. Gateway nodes can forward messages between physically separated networks.

MQTT message format

MeshCore publishes messages as JSON payloads. Example of a text message:

{
  "sender": "!a1b2c3d4",
  "from": 2748779476,
  "id": 123456789,
  "timestamp": 1699123456,
  "to": 4294967295,
  "channel": 0,
  "type": "text",
  "payload": {
    "text": "Hello via MQTT!"
  }
}

Each message contains metadata (sender ID, timestamp, channel) and a payload object with the actual data. For telemetry messages the payload contains batteryLevel, voltage, temperature, etc. For position messages: latitude, longitude, altitude.

Benefits of MQTT integration

๐Ÿ”Œ

Universal compatibility

MQTT is supported by almost all IoT platforms. Easy to integrate with Home Assistant, Node-RED, Domoticz, OpenHAB, etc.

๐ŸŒ

Remote access

Access your MeshCore network from anywhere via internet. Monitor nodes and send messages without being physically in range.

๐Ÿ“Š

Data persistence

Store all messages in database for long-term analysis. MeshCore itself has no storage, but MQTT + database does.

โšก

Real-time streaming

Publish/subscribe model ensures instant updates. No polling needed, data arrives automatically.

๐Ÿ”€

Multiple subscribers

Multiple systems can subscribe to the same topic simultaneously. For example: Grafana + Home Assistant + custom script.

๐Ÿ› ๏ธ

JSON is easy

JSON format is human-readable and works with every programming language. Easier to parse than binary Protobuf.

Frequently asked questions

Do I need a local MQTT broker?

No, you can also use a public broker like mqtt.meshtastic.org or test.mosquitto.org. Note: public brokers are insecure (everyone can listen). For production use a local broker (Mosquitto on Raspberry Pi) is recommended.

Which node should I use as MQTT gateway?

Any MeshCore node can act as gateway, but preferably use a stationary node with good power supply (USB or solar). Raspberry Pi + MeshCore node is a popular setup. The gateway must always be online.

Can I send messages via MQTT to the mesh network?

Yes! Publish a JSON message to the correct MQTT topic and the gateway node will forward it to the mesh. You can send messages from Home Assistant to the network this way. See the MQTT docs for the exact format.

How secure is MQTT?

MQTT itself is unencrypted (plain text). Use TLS encryption (MQTTS on port 8883) and username/password authentication. For extra security: VPN tunnel to your broker. Never use public brokers for sensitive data!

What is the difference between uplink and downlink topics?

Uplink topics (msh/.../c/...) are for messages from mesh to MQTT. Downlink topics (msh/.../2/c/...) are for messages from MQTT to mesh. Subscribe to uplink, publish to downlink.

Can I use MQTT without a physical gateway node?

No, you always need at least one node connected to the MQTT broker (via WiFi/Ethernet or USB to computer). This node acts as bridge between LoRa mesh and MQTT. Remote-only access via MQTT without node is not possible.

Start with MQTT integration

Ready to connect your MeshCore network with IoT platforms? Install an MQTT broker and configure a gateway node.