From 8bbb08289ae26cd33fac6705ec48e2181ecbafec Mon Sep 17 00:00:00 2001 From: Jack Pearson Date: Tue, 28 Oct 2025 10:56:55 -0700 Subject: [PATCH 1/3] add fixed circuitpython code for feather board + readme note --- README.md | 4 ++ .../feather_code.py | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 circuit-python-lora-passthrough/feather_code.py diff --git a/README.md b/README.md index da45089..cbb67c4 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,10 @@ On the board you want to receive data, make sure you have CircuitPython installe Once you have CircuitPython running, upload the files from the ```circuit-python-lora-passthrough``` folder in this repo. Make sure to overwrite any existing ```boot.py``` and ```code.py``` files on your CircuitPython board with the ones from this folder. +> [!NOTE] +> If you're targeting a Feather rather than a flight controller board, then +> copy `feather\_code.py` + ```boot.py``` enables both virtual serial ports that the device presents over USB. This allows you to use one for the console and one for data. ```code.py``` acts as a LoRa radio forwarder over USB serial: The console port is used for logging and debugging, and is the first serial port that appears when the board is connected. The data port is used for actual data transfer, and is the second serial port. 1. Open the console port on your computer. This is the first serial port that opens when you plug in the circuitpython board. It should start by printing: diff --git a/circuit-python-lora-passthrough/feather_code.py b/circuit-python-lora-passthrough/feather_code.py new file mode 100644 index 0000000..5889751 --- /dev/null +++ b/circuit-python-lora-passthrough/feather_code.py @@ -0,0 +1,41 @@ +""" +CircuitPython Feather RP2350 LoRa Radio forwarder + +This code will forward any received LoRa packets to the serial console (sys.stdout). It cycles through neo pixel colors +to indicate packet reception. +""" + +import time + +import adafruit_rfm9x +import board +import digitalio +import usb_cdc + +# Radio constants +RADIO_FREQ_MHZ = 437.4 +CS = digitalio.DigitalInOut(board.RFM9X_CS) +RESET = digitalio.DigitalInOut(board.RFM9X_RST) + +rfm95 = adafruit_rfm9x.RFM9x(board.SPI(), CS, RESET, RADIO_FREQ_MHZ) +rfm95.spreading_factor = 8 +rfm95.signal_bandwidth = 125000 +rfm95.coding_rate = 5 +rfm95.preamble_length = 8 +# time_start = time.time() +packet_count = 0 +print("[INFO] LoRa Receiver receiving packets") +while True: + # Look for a new packet - wait up to 2 seconds: + packet = rfm95.receive(timeout=2.0) + # If no packet was received during the timeout then None is returned. + if packet is not None: + usb_cdc.data.write(packet) + packet_count += 1 + # time_delta = time.time() - time_start + # if time_delta > 10: + # print(f"[INFO] Packets received: {packet_count}") + # time_start = time.time() + data = usb_cdc.data.read(usb_cdc.data.in_waiting) + if len(data) > 0: + rfm95.send(data) From 058e55f11408e3fc0af5827e2bda09aa68b0f0e9 Mon Sep 17 00:00:00 2001 From: Jack Pearson Date: Tue, 28 Oct 2025 11:03:42 -0700 Subject: [PATCH 2/3] fix lint + spurious backslash --- README.md | 2 +- circuit-python-lora-passthrough/feather_code.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbb67c4..b7205a8 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Once you have CircuitPython running, upload the files from the ```circuit-python > [!NOTE] > If you're targeting a Feather rather than a flight controller board, then -> copy `feather\_code.py` +> copy `feather_code.py` ```boot.py``` enables both virtual serial ports that the device presents over USB. This allows you to use one for the console and one for data. ```code.py``` acts as a LoRa radio forwarder over USB serial: The console port is used for logging and debugging, and is the first serial port that appears when the board is connected. The data port is used for actual data transfer, and is the second serial port. diff --git a/circuit-python-lora-passthrough/feather_code.py b/circuit-python-lora-passthrough/feather_code.py index 5889751..7f394ab 100644 --- a/circuit-python-lora-passthrough/feather_code.py +++ b/circuit-python-lora-passthrough/feather_code.py @@ -5,7 +5,7 @@ to indicate packet reception. """ -import time +# import time import adafruit_rfm9x import board From 4c9436618067e42f254dd2ed8d27fe6871dedf80 Mon Sep 17 00:00:00 2001 From: Jack Pearson Date: Tue, 28 Oct 2025 11:10:11 -0700 Subject: [PATCH 3/3] move feather exception code into own directory --- README.md | 2 +- circuit-python-lora-passthrough-feather/boot.py | 12 ++++++++++++ .../code.py | 0 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 circuit-python-lora-passthrough-feather/boot.py rename circuit-python-lora-passthrough/feather_code.py => circuit-python-lora-passthrough-feather/code.py (100%) diff --git a/README.md b/README.md index b7205a8..179facb 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Once you have CircuitPython running, upload the files from the ```circuit-python > [!NOTE] > If you're targeting a Feather rather than a flight controller board, then -> copy `feather_code.py` +> copy from ```circuit-python-lora-passthrough-feather``` instead. ```boot.py``` enables both virtual serial ports that the device presents over USB. This allows you to use one for the console and one for data. ```code.py``` acts as a LoRa radio forwarder over USB serial: The console port is used for logging and debugging, and is the first serial port that appears when the board is connected. The data port is used for actual data transfer, and is the second serial port. diff --git a/circuit-python-lora-passthrough-feather/boot.py b/circuit-python-lora-passthrough-feather/boot.py new file mode 100644 index 0000000..8b54a07 --- /dev/null +++ b/circuit-python-lora-passthrough-feather/boot.py @@ -0,0 +1,12 @@ +""" +boot.py + +This file helps to use an RP2350 CircuitPython environment as a passthrough for +interacting with the radio and F Prime GDS. The usb_cdc.enable() function creates a +USB serial endpoint that the GDS can connect to to receive all the data that is +streamed out. The function has to be called in boot.py before the USB device is enabled. +""" + +import usb_cdc + +usb_cdc.enable(console=True, data=True) diff --git a/circuit-python-lora-passthrough/feather_code.py b/circuit-python-lora-passthrough-feather/code.py similarity index 100% rename from circuit-python-lora-passthrough/feather_code.py rename to circuit-python-lora-passthrough-feather/code.py