20 lines
619 B
Python
20 lines
619 B
Python
from pyLoraRFM9x import LoRa, ModemConfig
|
|
|
|
def on_recv(payload):
|
|
print("From:", payload.header_from)
|
|
print("Received:", payload.message)
|
|
print("RSSI: {}; SNR: {}".format(payload.rssi, payload.snr))
|
|
print(payload.message.hex())
|
|
|
|
|
|
# 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) |