Setting Up Meshtastic on Raspberry Pi Zero 2 with SX1278 RA-02
Take a Raspberry Pi Zero 2, add a dirt-cheap SX1278 RA-02 module, and get Meshtastic running against all odds. After a week of wrestling with unsupported out-of-box setup, this guide shares horrible secrets of making it work.
I'm a beginner at setting up things like this and might have done everything completely wrong, but this setup got Meshtastic running.
Update
Version v2.5.9.936260f works without any code modifications
Prerequisites
Hello, friend. If you're reading this, our thoughts are aligned, and you want to set up Meshtastic on a Raspberry Pi Zero 2 with that beautiful and cheap SX1278 RA-02 module. I hope you haven't spent too much time on this yet, because I spent SEVEN FUCKING LONG DAYS on it.
I'm writing this guide because I prayed to Jesus Christ to make this shit work, and promised I'd share my journey if successful.
I'm using Raspberry Pi OS lite (64-bit) 6.6.51+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.51-1+rp
Board Connections
Here's how to connect the LoRa module to GPIO:
Alright, we’ll need to build the meshtasticd
binary to get everything working. The binary from the Meshtastic repository didn’t work for me.
I’ve placed the binary and source code here. The source code itself remains unchanged - only the configuration and headers for the variants are modified. Yes, this config was literally put together through brute force. If anyone knows the right way, I’d be glad to hear your advice.
Next, I'll try to outline process of building from source
Meshtastic Installation Steps
meshtasticd
from source, it's not necessary to set up everything else manually. Download the official .deb
package, install it using apt install ./packagename.deb
, and then replace the /usr/sbin/meshtasticd
binary with your newly built version.1. Install Dependencies
sudo apt install libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev -y
2. Configure SPI Interface
Edit /boot/firmware/config.txt
to enable SPI interface and force SPI0 (primary SPI bus):
dtparam=spi=on
dtoverlay=spi0-0cs
3. Install PlatformIO
Choose either method:
Using curl:
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
Or using wget:
wget -O get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
4. Clone Repository
Either clone the official repo:
git clone https://github.com/meshtastic/firmware.git
Or clone my modified repo (recommended for this setup):
git clone https://git.speedyweedyops.org/pohui_pohui/meshtastic_rpi2w_sx1278_RA_02
5. Build the Binary
Activate PlatformIO environment and build:
source ~/.platformio/penv/bin/activate
cd meshtastic_rpi2w_sx1278_RA_02
pio run -e native
The built binary will be in .pio/build/native/
named "program". Copy it to the appropriate location:
cp .pio/build/native/program /usr/sbin/meshtasticd
6. Configure SystemD Service
Create the service file:
sudo nano /etc/systemd/system/meshtasticd.service
Add this content:
[Unit]
Description=Meshtastic Native Daemon
After=network-online.target
[Service]
User=root
Group=root
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/sbin/meshtasticd
[Install]
WantedBy=multi-user.target
7. Configure Meshtastic
Create and edit the config file:
sudo nano /etc/meshtastic/config.yaml
Add this configuration:
---
Lora:
Module: RF95
Reset: 22
CS: 8
IRQ: 25
Logging:
LogLevel: debug # debug, info, warn, error
TraceFile: /var/log/meshtasticd.json
AsciiLogs: true # default if not specified is !isatty() on stdout
Webserver:
Port: 443 # Port for Webserver & Webservices
RootPath: /usr/share/doc/meshtasticd/web # Root Dir of WebServer
General:
MaxNodes: 200
MaxMessageQueue: 100
8. Start the Service
sudo systemctl daemon-reload
sudo systemctl restart meshtasticd.service
sudo systemctl status meshtasticd.service
if all steps were done correctly, we must see something like
This means we've completed the main task. This setup provides the basic Meshtastic functionality - we'll have access to just the web interface, though it offers quite rich configuration options. I haven't gotten around to setting up Bluetooth and Wi-Fi yet - maybe I'll cover that in a future article.
Also I'll try to expand this article with more detailed explanations of the code changes that differ from the source.
Or I might say fuck it (most likely)
Diff between original v2.5.9.936260f code and my modified version
variants/portduino/variant.h
platformio.ini
files that modified, other differences related to a bit fresher source version.