Lark’s Forge

Design • Build • Create

← Electronics Lab Adafruit Feather RP2040 RFM95 (LoRa)

LoRa GPS Tracker (TX / RX)

Send GPS position over 915 MHz LoRa from one Feather RP2040 to another.

Feather RP2040LoRa RFM95GPSCircuitPython
Adafruit Feather RP2040 RFM95 (LoRa)
Downloads

Code

Printable parts

STL files coming soon.

Docs

Overview

Two CircuitPython boards talking over LoRa. The transmitter reads position from an Adafruit Ultimate GPS FeatherWing and broadcasts it once a second; the receiver listens and prints every message, plus signal strength, to the serial console.

Each board's on-board NeoPixel steps through a colour every second (transmitter) or every packet (receiver), so you can see it working at a glance.

  • LoRa transmit (TX) and receive (RX) programs
  • GPS latitude, longitude, altitude, satellites and UTC time in every message
  • Signal-to-noise ratio and RSSI shown for each received packet
  • A UNIT_ID setting so several transmitters can share one receiver

Parts

Wiring

Transmitter

FromToNotes
GPS FeatherWingFeather TX / RX (UART, 9600 baud)stack the wing on the Feather
LoRa radiobuilt-in (SPI, RFM_CS / RFM_RST)no wiring needed

Receiver

FromToNotes
LoRa radiobuilt-in (SPI, RFM_CS / RFM_RST)no wiring needed
  • The code uses the pin names board.RFM_CS and board.RFM_RST, which exist on the Feather RP2040 RFM board with the radio built in.
  • Using a separate RFM95 breakout instead? Wire it to the Feather's SPI pins (SCK, MOSI, MISO) plus two free pins for CS and RESET, and change board.RFM_CS / board.RFM_RST in the code to the pins you used.
  • 915 MHz is the licence-free band in the US, Canada and Australia. Elsewhere use the 868 MHz or 433 MHz radio version and change frequency = 915.0 on both boards.

Radio settings

SettingValue
Frequency915.0 MHz
Bandwidth125 kHz
Spreading factor10
Coding rate4/8
CRCon
Transmit power19 dBm

Both boards must use exactly the same radio settings.

Directions

  1. Install CircuitPython on both Feathers.
  2. Copy the libraries below into CIRCUITPY/lib/ on both boards (adafruit_gps.mpy is only needed on the transmitter).
  3. Transmitter: copy TX.py to the board and rename it code.py. Stack the GPS FeatherWing on top.
  4. Transmitter: create a file called settings.toml on the CIRCUITPY drive containing a line like UNIT_ID = "TRUCK1" - this name is sent with every position.
  5. Receiver: copy RX.py to the second board and rename it code.py.
  6. Open the receiver's serial console (for example in Mu or Thonny). Take the transmitter outside so the GPS gets a fix - nothing is sent until it does; its console shows "Waiting for fix..." until then.

Message format

GPS;UNIT_ID;latitude,longitude,altitude;satellites;fix;YYYY-MM-DD hh:mm:ss

The receiver prints each message with the signal-to-noise ratio and RSSI added on the end.

Libraries

Copy these from the Adafruit CircuitPython Library Bundle into CIRCUITPY/lib/.

  • adafruit_rfm9x.mpy
  • adafruit_gps.mpy (transmitter)
  • neopixel.mpy
  • adafruit_bus_device/ (folder)

Code

TX.py - transmitter (rename to code.py) Download
# This was originally created by Dygear
#Remae to code.py on the TX side feather board

import os
import time
import board
import busio
import digitalio
import adafruit_rfm9x
import adafruit_gps
import neopixel

UNIT_ID = os.getenv("UNIT_ID", "UNKNOWN")
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
color_values = [
    (255,  0,  0), # 31 - Red
    (  0,255,  0), # 32 - Green
    (255,255,  0), # 33 - Yellow
    (  0,  0,255), # 34 - Blue
    (255,  0,255), # 35 - Magenta
    (  0,255,255), # 36 - Cyan
    (255,255,255), # 37 - White
    (  0,  0,  0), # 30 - Black
]
color_index = 0

uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=1)
gps = adafruit_gps.GPS(uart, debug=False)
gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
gps.send_command(b"PMTK220,1000")

LoRA = adafruit_rfm9x.RFM9x(
    board.SPI(),
    digitalio.DigitalInOut(board.RFM_CS),
    digitalio.DigitalInOut(board.RFM_RST),
    frequency = 915.0
)
LoRA.signal_bandwidth = 125000
print(f"signal_bandwidth: {LoRA.signal_bandwidth}")
LoRA.spreading_factor = 10
print(f"spreading_factor: {LoRA.spreading_factor}")
LoRA.coding_rate = 8
print(f"coding_rate: {LoRA.coding_rate}")
LoRA.enable_crc = True
print(f"enable_crc: {LoRA.enable_crc}")
LoRA.tx_power = 19;
print(f"tx_power: {LoRA.tx_power}")

last_print = time.monotonic()
while True:
    gps.update()
    current = time.monotonic()
    if current - last_print >= 1.0:
        pixel.fill(color_values[color_index])
        color_index = (color_index + 1) % len(color_values)
        last_print = current
        if not gps.has_fix:
            print("Waiting for fix...")
            continue

        print(f"GPS;{UNIT_ID};{gps.latitude:4.8f},{gps.longitude:4.8f},{gps.altitude_m};{gps.satellites:02d};{gps.has_fix};{gps.timestamp_utc.tm_year:4d}-{gps.timestamp_utc.tm_mon:02d}-{gps.timestamp_utc.tm_mday:02d} {gps.timestamp_utc.tm_hour:02d}:{gps.timestamp_utc.tm_min:02d}:{gps.timestamp_utc.tm_sec:02d}")
        LoRA.send(bytes(f"GPS;{UNIT_ID};{gps.latitude:4.8f},{gps.longitude:4.8f},{gps.altitude_m};{gps.satellites:02d};{gps.has_fix};{gps.timestamp_utc.tm_year:4d}-{gps.timestamp_utc.tm_mon:02d}-{gps.timestamp_utc.tm_mday:02d} {gps.timestamp_utc.tm_hour:02d}:{gps.timestamp_utc.tm_min:02d}:{gps.timestamp_utc.tm_sec:02d}", "UTF-8"))
RX.py - receiver (rename to code.py) Download
# This was originally created by Dygear
#rename to code.py on the RX feather board

import board
import digitalio
import neopixel
import adafruit_rfm9x

pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
pixel.brightness = 0.01
color_values = [
    (255,  0,  0), # 31 - Red
    (  0,255,  0), # 32 - Green
    (255,255,  0), # 33 - Yellow
    (  0,  0,255), # 34 - Blue
    (255,  0,255), # 35 - Magenta
    (  0,255,255), # 36 - Cyan
    (255,255,255), # 37 - White
    (  0,  0,  0), # 30 - Black
]
color_index = 0
LoRA = adafruit_rfm9x.RFM9x(
    board.SPI(),
    digitalio.DigitalInOut(board.RFM_CS),
    digitalio.DigitalInOut(board.RFM_RST),
    frequency = 915.0
)
LoRA.signal_bandwidth = 125000
print(f"signal_bandwidth: {LoRA.signal_bandwidth}")
LoRA.spreading_factor = 10
print(f"spreading_factor: {LoRA.spreading_factor}")
LoRA.coding_rate = 8
print(f"coding_rate: {LoRA.coding_rate}")
LoRA.enable_crc = True
print(f"enable_crc: {LoRA.enable_crc}")
LoRA.tx_power = 19;
print(f"tx_power: {LoRA.tx_power}")

print("Waiting for packets...")
while True:
    packet = LoRA.receive(timeout=5.0)
    if packet is not None:
        if packet.startswith(b"GPS"):
            print(f"{packet.decode('utf-8')};{LoRA.snr:.2f};{LoRA.rssi:04d}")

        pixel.fill(color_values[color_index])
        color_index = (color_index + 1) % len(color_values)

Credits & licence

Code by Dygear (github.com/Dygear) and Lark216 - published with permission.

Released under the MIT License — Copyright (c) 2025 Dygear and Lark216. Free to use, modify and share.