Skip to main content

MQTT Integration for Sensor Data

MQTT Integration for Sensor Data

Meshtastic includes a built-in MQTT bridge that can publish all mesh traffic — including telemetry sensor packets — to an MQTT broker. This enables real-time integration with Home Assistant, InfluxDB, Grafana, and other data platforms without any custom firmware modifications.

Enabling the MQTT Bridge on a Gateway Node

The MQTT bridge runs on any Meshtastic node with a working WiFi connection (ESP32-based nodes such as the T-Beam or HELTEC V3). Configure the bridge via the Meshtastic CLI or the Python API:

meshtastic --set mqtt.server mqtt.example.com
meshtastic --set mqtt.username meshuser
meshtastic --set mqtt.password s3cr3t
meshtastic --set mqtt.root msh/region/us-east
meshtastic --set mqtt.enabled true
meshtastic --set mqtt.json true          # publish decoded JSON, not raw protobuf
meshtastic --set mqtt.tls_enabled true   # strongly recommended for production

The gateway node will now publish every received mesh packet to the topic msh/region/us-east/2/json/<portnum>/<sender_node_id>. Telemetry packets arrive on the TELEMETRY_APP port.

JSON Packet Format

A typical decoded telemetry JSON payload looks like this:

{
  "from": 1234567890,
  "to": 4294967295,
  "type": "telemetry",
  "payload": {
    "temperature": 22.4,
    "relative_humidity": 58.2,
    "barometric_pressure": 1013.7,
    "air_util_tx": 0.4
  },
  "timestamp": 1714500000,
  "channel": 0,
  "rssi": -87,
  "snr": 7.5
}

Node-RED Integration

Node-RED provides a low-code flow editor ideal for parsing and routing Meshtastic telemetry. A typical flow consists of:

  1. MQTT In node — subscribe to msh/region/+/2/json/TELEMETRY_APP/#
  2. JSON node — parse the payload string to a JavaScript object
  3. Function node — extract fields, add tags (node name, location)
  4. InfluxDB Out node or Home Assistant node — write the data to your chosen store

Home Assistant MQTT Sensor Configuration

Add the following to your Home Assistant configuration.yaml to create sensors for a Meshtastic node named SensorNode-01:

mqtt:
  sensor:
    - name: "SensorNode-01 Temperature"
      state_topic: "msh/region/us-east/2/json/TELEMETRY_APP/1234567890"
      value_template: "{{ value_json.payload.temperature }}"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: "SensorNode-01 Humidity"
      state_topic: "msh/region/us-east/2/json/TELEMETRY_APP/1234567890"
      value_template: "{{ value_json.payload.relative_humidity }}"
      unit_of_measurement: "%"
      device_class: humidity

    - name: "SensorNode-01 Pressure"
      state_topic: "msh/region/us-east/2/json/TELEMETRY_APP/1234567890"
      value_template: "{{ value_json.payload.barometric_pressure }}"
      unit_of_measurement: "hPa"
      device_class: pressure

Restart Home Assistant after editing the configuration. The sensors will populate with live data as new telemetry packets arrive via the MQTT bridge.

Grafana Dashboard for Long-Term Trending

For historical analysis, write telemetry data to InfluxDB (v2 recommended) and visualise with Grafana:

  1. Create an InfluxDB bucket named mesh_telemetry.
  2. Use the Node-RED InfluxDB Out node (or the Python influxdb-client library) to write measurements with tags node_id and node_name.
  3. In Grafana, add InfluxDB as a data source and create a dashboard with time-series panels for temperature, humidity, and pressure. Use a 7-day or 30-day range to identify trends, calibration drift, or equipment failure.
  4. Configure Grafana alerting to notify via email or Slack when temperature exceeds a threshold or a sensor node stops reporting (absence of data alert).