Gateway Setup Guides

Step-by-step setup guides for Raspberry Pi MQTT gateways and MeshCore Linux room servers.

Raspberry Pi MQTT Gateway Setup

What This Achieves

Connecting a Meshtastic USB device to a Raspberry Pi and running Mosquitto turns the Pi into a persistent internet gateway. It forwards mesh packets to MQTT (locally and/or to a cloud broker), enables remote monitoring of all nodes on your mesh, and allows the node to relay messages between the mesh and internet-connected services - all without leaving the Meshtastic app running on a laptop.

Hardware Requirements

ComponentNotes
Raspberry Pi 3B+, 4, or Zero 2W3B+ or 4 for comfort; Zero 2W for power-constrained installs. All run Pi OS Lite adequately.
MicroSD card (16 GB+)Class 10 / A1 rated. Use a quality brand - SD card failures are the #1 Pi reliability issue.
Meshtastic USB nodeT-Beam, Heltec V3, RAK WisBlock, or any device that enumerates as a serial CDC ACM device.
USB cableData-capable USB-A to USB-C (or micro, depending on node).
Case and power supplyOfficial Pi PSU or PoE HAT for rooftop deployments.

Software Setup

Step 1 - Flash the OS

Use Raspberry Pi Imager to flash Raspberry Pi OS Lite (64-bit) to the SD card. In the imager's Advanced Options, pre-configure:

Step 2 - Install dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y mosquitto mosquitto-clients python3-pip
pip3 install meshtastic

Step 3 - Configure Mosquitto

Edit /etc/mosquitto/mosquitto.conf (or create a file in /etc/mosquitto/conf.d/):

# Allow anonymous local connections (safe for LAN-only installs)
listener 1883
allow_anonymous true

# For remote access, use authentication instead:
# listener 1883 0.0.0.0
# allow_anonymous false
# password_file /etc/mosquitto/passwd
sudo systemctl enable mosquitto
sudo systemctl start mosquitto

Step 4 - Configure the Meshtastic node

Connect to the node via the Meshtastic app or CLI and set:

Via CLI:

meshtastic --set mqtt.address localhost --set mqtt.enabled true --set mqtt.json_enabled true

Step 5 - Verify packets are flowing

mosquitto_sub -h localhost -t 'msh/#' -v

You should see topic/payload pairs appear each time a mesh packet is received by your gateway node. Position packets, text messages, and telemetry all appear as separate topics.

Remote Access Options

systemd Service for the Meshtastic Connection

If you run a Python script to bridge or monitor the mesh, create /etc/systemd/system/mesh-bridge.service:

[Unit]
Description=Meshtastic mesh bridge
After=network.target mosquitto.service

[Service]
User=pi
ExecStart=/usr/bin/python3 /home/pi/mesh_bridge.py
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
sudo systemctl enable mesh-bridge
sudo systemctl start mesh-bridge

Node-RED on the Same Pi

Install Node-RED for visual flow-based packet processing with zero additional cloud dependency:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Use the MQTT-in node subscribed to msh/# to receive all mesh packets, then add function nodes to parse JSON, filter by type, and push to dashboards, databases, or notification services. The Node-RED UI dashboard module provides a web-accessible map and message log without any external services.

Power Budget

BoardIdle powerNotes
Raspberry Pi 4 (2 GB)~3.4 WPoE HAT adds ~1 W; suitable for rooftop enclosure with PoE switch
Raspberry Pi 3B+~2.9 WGood balance of capability and power
Raspberry Pi Zero 2W~0.9 WBest for solar/battery; limited to single USB device, requires USB OTG adapter

Add ~0.5 - 1 W for the connected Meshtastic node. A small 12 V/7 Ah SLA battery can sustain a Zero 2W + node gateway for 40+ hours without solar input.

Setting Up a Meshtastic MQTT-to-Internet Gateway

An MQTT gateway connects your Meshtastic mesh to the internet, enabling message delivery to non-LoRa clients, integration with home automation, and connection to the global Meshtastic MQTT network.

What the MQTT Gateway Does

A Meshtastic node in "MQTT gateway" mode:

Requirements

Configuration Steps

Option A: Using the Meshtastic Public MQTT Server

# Configure via CLI:
meshtastic --set mqtt.enabled true
meshtastic --set mqtt.server mqtt.meshtastic.org
meshtastic --set mqtt.username meshdev
meshtastic --set mqtt.password large4cats

# Configure which channels to bridge (enable MQTT uplink/downlink per channel)
meshtastic --ch-index 0 --ch-set uplink_enabled true
meshtastic --ch-index 0 --ch-set downlink_enabled true

# Configure WiFi (if not already done)
meshtastic --set network.wifi_ssid "YourSSID"
meshtastic --set network.wifi_psk "YourPassword"

Privacy note: The public MQTT server relays messages globally. Only use it for the default (unencrypted) channel unless you want your encrypted channel traffic relayed globally.

Option B: Self-Hosted Mosquitto MQTT Broker

# Install Mosquitto on Raspberry Pi or VPS:
sudo apt install mosquitto mosquitto-clients
sudo systemctl enable --now mosquitto

# Configure anonymous access (for a local network only):
echo "allow_anonymous true" | sudo tee -a /etc/mosquitto/mosquitto.conf
sudo systemctl restart mosquitto

# Configure node to use your local broker:
meshtastic --set mqtt.server 192.168.1.100
meshtastic --set mqtt.enabled true

Verifying the Gateway is Working

# Subscribe to all Meshtastic MQTT topics and watch for packets:
mosquitto_sub -h mqtt.meshtastic.org -u meshdev -P large4cats -t "msh/US/2/e/#" -v

# Or on your local broker:
mosquitto_sub -h 192.168.1.100 -t "msh/#" -v

You should see base64-encoded packets appearing as mesh traffic is received.

MQTT Packet Decoding

Meshtastic MQTT packets are protobuf-encoded. To decode them for integration with other systems:

pip install meshtastic
# meshtastic library includes MQTT packet decoding

from meshtastic.mqtt import MQTT
# See meshtastic Python API docs for full MQTT integration examples