File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 19
19
# CS = digitalio.DigitalInOut(board.RFM9X_CS)
20
20
# RESET = digitalio.DigitalInOut(board.RFM9X_RST)
21
21
22
+ # Define the onboard LED
23
+ LED = digitalio .DigitalInOut (board .D13 )
24
+ LED .direction = digitalio .Direction .OUTPUT
25
+
22
26
# Initialize SPI bus.
23
27
spi = busio .SPI (board .SCK , MOSI = board .MOSI , MISO = board .MISO )
24
28
32
36
# high power radios like the RFM95 can go up to 23 dB:
33
37
rfm9x .tx_power = 23
34
38
39
+ # Packet counter, incremented per tx
40
+ packetNum = 0
41
+
35
42
# Send a packet. Note you can only send a packet up to 252 bytes in length.
36
43
# This is a limitation of the radio packet size, so if you need to send larger
37
44
# amounts of data you will need to break it into smaller send calls. Each send
44
51
# This means you should only use this for low bandwidth scenarios, like sending
45
52
# and receiving a single message at a time.
46
53
print ('Waiting for packets...' )
54
+
47
55
while True :
56
+
48
57
packet = rfm9x .receive ()
49
58
# Optionally change the receive timeout from its default of 0.5 seconds:
50
59
#packet = rfm9x.receive(timeout=5.0)
51
60
# If no packet was received during the timeout then None is returned.
52
61
if packet is None :
62
+ LED .value = False
53
63
print ('Received nothing! Listening again...' )
54
64
else :
55
65
# Received a packet!
66
+ LED .value = True
56
67
# Print out the raw bytes of the packet:
57
68
print ('Received (raw bytes): {0}' .format (packet ))
58
69
# And decode to ASCII text and print it too. Note that you always
You can’t perform that action at this time.
0 commit comments