Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Lora_to_FSK_mod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import serial
import time
import sys

# Adjust COM port and baudrate if needed
PORT = "COM3" # <-- change to your actual COM port
BAUDRATE = 57600 # RN2483 default is 57600 baud

def send_cmd(radio, cmd, delay=0.2):
"""Send a command and return response line."""
radio.write((cmd + "\r\n").encode("utf-8"))
time.sleep(delay)
resp = radio.read_all().decode("utf-8").strip()
return resp

def main():
try:
radio = serial.Serial(PORT, BAUDRATE, timeout=1)
except Exception as e:
print(f"Failed to open {PORT}: {e}")
sys.exit(1)

# Flush any junk
radio.reset_input_buffer()
radio.reset_output_buffer()

# Step 1: check connection
resp = send_cmd(radio, "sys get ver")
if resp and "RN2483" in resp:
print("Successfully connected to RN2483")
else:
print("No response from RN2483, check wiring/port.")
sys.exit(1)

# Step 2: pause MAC (LoRaWAN stack)
print("Pausing LoRaWAN stack...")
print(">>", send_cmd(radio, "mac pause"))

# Step 3: configure FSK modulation
print("Switching to FSK...")
print(">>", send_cmd(radio, "radio set mod fsk"), " --> setting the Modulation to FSK")
print(">>", send_cmd(radio, "radio set freq 868000000"), " --> setting the freq to 868000000") # adjust region # Using EU (868 MHz band)
print(">>", send_cmd(radio, "radio set bitrate 50000"), " --> setting the bits per sec to 50000")
print(">>", send_cmd(radio, "radio set fdev 25000"), " --> setting the freq dev to 25000")
print(">>", send_cmd(radio, "radio set rxbw 125"), " --> setting the receiver bw to 125")
print(">>", send_cmd(radio, "radio set afcbw 41.7"), " --> setting the AFC bw to 41.7")
print(">>", send_cmd(radio, "radio set prlen 8"), " --> setting the praamble length to 8")
print(">>", send_cmd(radio, "radio set crc on"), " --> enablling CRC for packets")
print(">>", send_cmd(radio, "radio set sync 12AABBCCDD"), " --> setting up to 8 bytes sync word")
print(">>", send_cmd(radio, "radio set bt 0.5"), " --> setting Gaussian bt to 0.5")
print(">>", send_cmd(radio, "radio set pwr 14"), " --> TX power (dbm) to 14")

# Optional: test transmit (payload "Hello")
print("Sending test TX...")
print(">>", send_cmd(radio, "radio tx 48656C6C6F"))

radio.close()

if __name__ == "__main__":
main()
27 changes: 27 additions & 0 deletions ping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# To ping the Board (Change the PORT to whichever port it is connected to)

import serial
import time

# Change COM3 if your port is different
PORT = "COM3"
BAUD = 57600
cmd = "sys reset" + "\r\n" # Write the cmd to ping it to RN2483

try:
ser = serial.Serial(PORT, BAUD, timeout=1)

# Give the RN2483 a moment to initialize
time.sleep(5)

# Send a command
ser.write(cmd.encode("utf-8"))

# Read response
response = ser.read(100) # read up to 100 bytes
print("Response:", response.decode(errors="ignore"))

ser.close()

except Exception as e:
print("Error:", e)
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dataclasses==0.6
DateTime==5.5
future==1.0.0
iso8601==2.1.0
pytz==2025.2
PyYAML==6.0.3
serial==0.0.97
pyserial==3.5
typing==3.7.4.3
zope.interface==8.0.1