LoRa

Architecture

LoRa architecture

Standard build

Raspberry Pi setup

The 2025-05-13 image does not enable the serial port nor SSH initially (WTF!?) and requires an HDMI monitor and a keyboard to set up.

  1. Choose a hostname, so that multiple SBCs on the network don't all call themselves raspberrypi. Suggest pi-Z, where Z is a, b, c, etc. (a serial number).
  2. Enable the SSH server. Use PasswordAuthentication no for security later on once keys have been installed.
  3. Enable console on the serial port. The default will be 115,200 baud.
  4. Enable automatic loading of the SPI module. Required for LoRa module.
  5. Enable automatic loading of the I2C module. Required for sensors.
  6. dpkg-reconfigure tzdata
  7. Follow Meshtastic on Linux installation instructions at https://meshtastic.org/docs/hardware/devices/linux-native-hardware/?os=raspbian

I used this in config.d:

# MeshAdv-Pi E22-900M30S
# https://github.com/chrismyers2000/MeshAdv-Pi-Hat
Lora:
  Module: sx1262
  # These numbers correspond to GPIOx labels on the Pi header pinout, so `21`
  # means `GPIO21`.
  CS:     8
  IRQ:   16
  Busy:  19
  Reset:  5
  TXen:  13
  RXen:   6
  DIO3_TCXO_VOLTAGE: true

Next: Set up.

Bluetooth

sed 's/BLUETOOTH_ENABLED=1/BLUETOOTH_ENABLED=0/' /etc/default/bluetooth
# I have a feel that the "primary" UART at /dev/ttyS0 is the one that
# varies its baud rate as the VPU clock changes.  Perhaps the real UART is
# used to interface with the bluetooth chip?
# https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts
systemctl disable hciuart
# Add disable-bt to the device tree, and reboot.
# /dev/serial0 seems to indicate the "primary" UART, which is the reliable
# (PL011) UART only if bluetooth is diabled with dtoverlay=disable-bt in
# config.txt.

Not using WiFi

systemctl disable wpa_supplicant.service

I2C

install  i2c-tools

CLI

i python3-pip

Shutdown button

E22 900M30S LoRa module

E22-900T22S LoRa module (on Waveshare hat, SKU 16807)

E22-900T22S pinout

Pin Purpose
1 NRST, Reset, active low.
2 GND
3 GND
4 NC
5 NC
6 NC
7 NC
8 GND
11 GND
12 ANT
13 GND
14 GND
15 GND
16 GND
19 GND
20 M0, Together with M1, define the "mode" (0-3). These "bits" are 0 when the jumper grounds the pin.
21 M1
22 RXD
23 TXD
24 AUX
25 VCC, 2.5 - 5.2 V
26 GND

User guide.

The RXD and TXD module pins are not connected to the I/O header, but instead to a CP2102 USB-to-serial bridge.

I/O header traces

The jumpers can be set in one of three positions (A, B, or C):

UART hats not supported by Meshtastic.

Raspberry Pi

Arguments against the Raspberry Pi:

Arguments for:

Optimizing radio parameters experiment

Precis: For a given set of radio parameters, send pings and keep track of the number of echoes received.

LG01: OpenWrt gateway

It's not immediately obvious what the purpose of the LG01 is. It's not an OTS solution, so it's probably intended for whatever it can be used for. The Raspberry Pi is easier to work with as a system at the heart of a site installation, so the LG01 on hand could be gainfully under-utilised by reading sensor data (via the exposed IOs) and providing the readings to the Raspberry Pi. The Arduino Unos with LoRa shields can accomplish the same task via the UART, but the LG01 could do so via the LAN, or even over the Internet.

Installing packages

  1. Go to the repository.
  2. Download the .ipk of interest.
  3. scp example.ipk LG01:/tmp/.
  4. opkg install example.ipk on the LG01.

It is not practical to install additional packages with opkg update. The web server that hosts the package repository has a recent TLS certificate and the OpenWrt build from 2017 does not include that certificate (wget returns exit code 5). After trying to install the certificate, I instead tried to configure a proxy (option http_proxy in opkg.conf), with no luck.

Flashing the Arduino

The virtual port appears in the Arduino IDE (is this some kind of zeroconf magic?), but attempts to upload to it are met with:

Resetting the board
Failed to reset the board, upload failed
Failed uploading: uploading error: exit status 1

Sketches (.hex files) may be uploaded manually via the web UI at Sensor, Flash MCU.

This was seen in ps output when uploading a sketch:

avrdude -c linuxgpio -C /etc/avrdude.conf -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDE

It should also be possible to upload with:

avrdude -c linuxgpio -C /etc/avrdude.conf -p m328p -Uflash:w:/tmp/LoRa-chat.ino.hex

..but this causes:

avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

..so back to the web UI then.

EEPROM

The web UI seems to erase the EEPROM whenever a new sketch is uploaded.

Serial link from the router (MIPS CPU) to the Arduino

On the router, /dev/ttyATH0 is connected to the Arduino UART:

screen /dev/ttyATH0 115200

The screen package was installed (along with ss and ser2net).