Setup a self hosted Meshtastic monitoring system on a Raspberry Pi with a Waveshare SX1262 LoRa Hat.
sudo apt update
sudo apt upgrade
wget https://github.com/meshtastic/firmware/releases/download/v2.5.4.8d288d5/meshtasticd_2.5.4.8d288d5_arm64.deb
sudo apt install ./meshtasticd_2.5.4.8d288d5_arm64.deb
sudo nano /etc/meshtasticd/config.yaml
Lora:
Module: sx1262 # Waveshare SX126X XXXM
DIO2_AS_RF_SWITCH: true
CS: 21
IRQ: 16
Busy: 20
Reset: 18
Webserver:
Port: 443 # Port for Webserver & Webservices
RootPath: /usr/share/doc/meshtasticd/web # Root Dir of WebServer
General:
MaxNodes: 200
MaxMessageQueue: 100
You must reboot after configuring the following, otherwise the SPI LoRa hat will not be found in the next step.
sudo nano /boot/firmware/config.txt
# meshtasticd
dtparam=spi=on
dtoverlay=spi0-0cs
sudo systemctl enable meshtasticd
sudo systemctl start meshtasticd
You will need to restart terminal afterwards, so the meshtastic
command is found.
sudo apt-get install python3
sudo apt-get install python3-pip
pip3 install --upgrade meshtastic --break-system-packages
meshtastic --host localhost --setlat x --setlon y
sudo apt install mosquitto
sudo nano /etc/mosquitto/mosquitto.conf
# configure local mqtt server
listener 1883
protocol mqtt
max_connections -1
log_dest syslog
allow_anonymous true
sudo service mosquitto restart
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE `meshtastic-map`;
CREATE USER 'meshtastic-map'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `meshtastic-map`.* TO 'meshtastic-map'@'localhost';
FLUSH PRIVILEGES;
Install NodeJS 22.x
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt-get install -y nodejs
sudo apt install git
git clone https://github.com/liamcottle/meshtastic-map
cd meshtastic-map/
npm install
touch .env
nano .env
DATABASE_URL="mysql://meshtastic-map:password@localhost:3306/meshtastic-map?connection_limit=100"
npx prisma migrate deploy
npx prisma generate
node src/mqtt.js --mqtt-broker-url mqtt://localhost
node src/index.js
Config
-> Module Config
-> MQTT
:
- Enabled: true
- MQTT Server Address: localhost
- MQTT Username: uplink
- MQTT Password: uplink
- Encryption Enabled: true
- JSON Enabled: false
- TLS Enabled: false
- Root topic: msh/ANZ
- Proxy to Client Enabled: false
Enable map reporting to show this node with firmware info etc on the map
- Map Reporting Enabled: true
- Map Report Publish Interval (s): 300
Enable channel uplink to allow packets from other nodes to be sent to MQTT and show on the map
Channels
-> Primary
:
- Uplink Enabled: true
nano /etc/systemd/system/meshtastic-map.service
[Unit]
Description=meshtastic-map
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=liamcottle
WorkingDirectory=/home/liamcottle/meshtastic-map
ExecStart=/usr/bin/env node /home/liamcottle/meshtastic-map/src/index.js
[Install]
WantedBy=multi-user.target
sudo systemctl enable meshtastic-map.service
sudo systemctl start meshtastic-map.service
nano /etc/systemd/system/meshtastic-map-mqtt.service
[Unit]
Description=meshtastic-map-mqtt
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=liamcottle
WorkingDirectory=/home/liamcottle/meshtastic-map
ExecStart=/usr/bin/env node /home/liamcottle/meshtastic-map/src/mqtt.js \
--mqtt-broker-url mqtt://localhost \
--mqtt-username uplink \
--mqtt-password uplink \
--mqtt-topic 'msh/#' \
--collect-map-reports \
--collect-neighbour-info \
--collect-positions \
--collect-text-messages \
--collect-waypoints \
--ignore-direct-messages \
--purge-interval-seconds 60 \
--purge-nodes-unheard-for-seconds 604800 \
--purge-device-metrics-after-seconds 2592000 \
--purge-environment-metrics-after-seconds 2592000 \
--purge-map-reports-after-seconds 604800 \
--purge-neighbour-infos-after-seconds 604800 \
--purge-power-metrics-after-seconds 2592000 \
--purge-positions-after-seconds 604800 \
--purge-service-envelopes-after-seconds 604800 \
--purge-text-messages-after-seconds 604800 \
--purge-traceroutes-after-seconds 604800 \
--purge-waypoints-after-seconds 604800 \
--drop-packets-not-ok-to-mqtt \
--old-firmware-position-precision 16
[Install]
WantedBy=multi-user.target
sudo systemctl enable meshtastic-map-mqtt.service
sudo systemctl start meshtastic-map-mqtt.service