netmon-multinode/RasPi/RXTest.py

20 lines
619 B
Python
Raw Normal View History

2022-04-24 03:41:28 +02:00
from pyLoraRFM9x import LoRa, ModemConfig
def on_recv(payload):
2022-04-24 14:54:40 +02:00
print("From:", payload.header_from)
print("Received:", payload.message)
print("RSSI: {}; SNR: {}".format(payload.rssi, payload.snr))
print(payload.message.hex())
2022-04-24 03:41:28 +02:00
# Use chip select 1. GPIO pin 5 will be used for interrupts and set reset pin to 25
# The address of this device will be set to 2
lora = LoRa(0, 25, 255, reset_pin = 22, modem_config=ModemConfig.Bw125Cr45Sf128, tx_power=14, freq=868, acks=False)#, receive_all=True)
lora.cad_timeout = 1
lora.on_recv = on_recv
lora.set_mode_rx()
import time
while True:
time.sleep(0.5)