File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
circuit-python-lora-passthrough Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import usb_cdc
2+ usb_cdc .enable (console = True , data = True )
Original file line number Diff line number Diff line change 1+ """
2+ CircuitPython Feather RP2350 LoRa Radio forwarder
3+
4+ This code will forward any received LoRa packets to the serial console (sys.stdout). It cycles through neo pixel colors
5+ to indicate packet reception.
6+ """
7+ import time
8+ import board
9+ import digitalio
10+ import adafruit_rfm9x
11+ import usb_cdc
12+
13+ # Radio constants
14+ RADIO_FREQ_MHZ = 437.4
15+ CS = digitalio .DigitalInOut (board .SPI0_CS0 )
16+ RESET = digitalio .DigitalInOut (board .RF1_RST )
17+
18+ rfm95 = adafruit_rfm9x .RFM9x (board .SPI (), CS , RESET , RADIO_FREQ_MHZ )
19+ rfm95 .spreading_factor = 8
20+ rfm95 .signal_bandwidth = 125000
21+ rfm95 .coding_rate = 5
22+ rfm95 .preamble_length = 8
23+ time_start = time .time ()
24+ packet_count = 0
25+ print ("[INFO] LoRa Receiver receiving packets" )
26+ while True :
27+ # Look for a new packet - wait up to 2 seconds:
28+ packet = rfm95 .receive (timeout = 2.0 )
29+ # If no packet was received during the timeout then None is returned.
30+ if packet is not None :
31+ usb_cdc .data .write (packet )
32+ packet_count += 1
33+ time_delta = time .time () - time_start
34+ if time_delta > 10 :
35+ print (f"[INFO] Packets received: { packet_count } " )
36+ time_start = time .time ()
37+ data = usb_cdc .data .read (usb_cdc .data .in_waiting )
38+ if len (data ) > 0 :
39+ rfm95 .send (data )
You can’t perform that action at this time.
0 commit comments