-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlora_rx.py
More file actions
43 lines (36 loc) · 862 Bytes
/
lora_rx.py
File metadata and controls
43 lines (36 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import time
LORA_CFG = {
"freq_khz": 915000,
"sf": 7,
"bw": 125,
"coding_rate": 5,
"preamble_len": 8,
"output_power": 5,
"crc": True,
"invert_iq": False,
}
def update_display(counter, rx):
display.fill(0)
display.text("Receiving...", 0, 0, 1)
display.text(str(counter), 0, 12, 1)
display.text(f"RSSI: {rx.rssi}", 0, 24, 1)
display.show()
def main():
print("Initializing...")
modem = get_modem(LORA_CFG)
display.fill(0)
display.text("Receiving...", 0, 0, 1)
display.show()
counter = 0
rx_counter = 0
while True:
rx = modem.recv(timeout_ms=5000)
if rx:
print(f"Received: {rx}")
rx_counter += 1
update_display(rx_counter, rx)
else:
print("RX Timeout!")
time.sleep(1)
counter += 1
main()