I am trying out the following test with two RFM95W boards on Raspberry Pis.
https://learn.adafruit.com/adafruit-rad ... lora-radio
The board is detected by the Pi, and instead of the button press, I have a send program that sends packets every 2 seconds and the receiver listens continuously. Only a handful of packets, if any, are received by the receiver. What might be going on?
RFM95W Lora radio cannot receive
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
This is from sending around 1000 packets.
- jerryn
- Posts: 1868
- Joined: Sat Sep 14, 2013 9:05 am
Re: RFM95W Lora radio cannot receive
It would be helpful to see the code you are actually using for both the transmit and receive systems.
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Sender Code
Code: Select all
# Configure LoRa Radio
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
prev_packet = None
count = 0
while True:
count = count + 1
# draw a box to clear the image
display.fill(0)
send_data = bytes(str(count), "utf-8")
status = rfm9x.send(send_data)
print("sending " + str(count) + ", status " + str(status))
display.text(str(count), 25, 15, 1)
display.show()
time.sleep(2)
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Receiver code
Code: Select all
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
rfm9x.receive_timeout = 0.5
prev_packet = None
while True:
packet = None
# draw a box to clear the image
display.fill(0)
display.text('RasPi LoRa', 35, 0, 1)
#print("Timeout " + str(rfm9x.receive_timeout))
# check for packet rx
packet = rfm9x.receive()
if packet is None:
display.text('- Waiting for PKT -', 15, 20, 1)
display.show()
#print("CRC Error " + str(rfm9x.crc_error()))
else:
# Display the packet text and rssi
display.fill(0)
prev_packet = packet
packet_text = str(prev_packet, "utf-8")
display.text('RX: ', 0, 0, 1)
display.text(packet_text, 25, 0, 1)
print("Received " + packet_text)
display.show()
time.sleep(0.1)
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Both these are pretty much the programs from https://learn.adafruit.com/lora-and-lor ... y-pi-setup>.
Code indentation is not shown properly due to the editor.
Code indentation is not shown properly due to the editor.
- jerryn
- Posts: 1868
- Joined: Sat Sep 14, 2013 9:05 am
Re: RFM95W Lora radio cannot receive
I tried your code -- using a pizero2w for the receiver and a pi400 for the transmitter -- I get much better results
There are some misses but that is not uncommon. Switching to the "reliable datagram" mode would likely improve that.
Here is the code I ran (note -- using the "code" tags from the menubar preserves formatting.
transmit
receive
edited to add --
If I swap transmit and receive so I am receiving on the pi400 then I am not missing any packets. This is like because the pi400 process the screen updates so much faster so there is much less "dead" time before it starts listening again.
Code: Select all
pi@gjnpirfm9xswitch:~ $ python receive.py
Received 1
Received 1
Received 2
Received 4
Received 5
Received 7
Received 8
Received 9
Received 10
Received 11
Received 12
Received 14
Received 16
Received 17
Received 18
There are some misses but that is not uncommon. Switching to the "reliable datagram" mode would likely improve that.
Here is the code I ran (note -- using the "code" tags from the menubar preserves formatting.
transmit
Code: Select all
import time
import busio
from digitalio import DigitalInOut, Direction, Pull
import board
# Import the SSD1306 module.
import adafruit_ssd1306
# Import the RFM9x radio module.
import adafruit_rfm9x
# Button A
btnA = DigitalInOut(board.D5)
btnA.direction = Direction.INPUT
btnA.pull = Pull.UP
# Button B
btnB = DigitalInOut(board.D6)
btnB.direction = Direction.INPUT
btnB.pull = Pull.UP
# Button C
btnC = DigitalInOut(board.D12)
btnC.direction = Direction.INPUT
btnC.pull = Pull.UP
# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
# 128x32 OLED Display
reset_pin = DigitalInOut(board.D4)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=reset_pin)
# Clear the display.
display.fill(0)
display.show()
width = display.width
height = display.height
# Configure LoRa Radio
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
prev_packet = None
count = 0
while True:
count = count + 1
# draw a box to clear the image
display.fill(0)
send_data = bytes(str(count), "utf-8")
status = rfm9x.send(send_data)
print("sending " + str(count) + ", status " + str(status))
display.text(str(count), 25, 15, 1)
display.show()
time.sleep(2)
Code: Select all
import time
import busio
from digitalio import DigitalInOut, Direction, Pull
import board
# Import the SSD1306 module.
import adafruit_ssd1306
# Import the RFM9x radio module.
import adafruit_rfm9x
# Button A
btnA = DigitalInOut(board.D5)
btnA.direction = Direction.INPUT
btnA.pull = Pull.UP
# Button B
btnB = DigitalInOut(board.D6)
btnB.direction = Direction.INPUT
btnB.pull = Pull.UP
# Button C
btnC = DigitalInOut(board.D12)
btnC.direction = Direction.INPUT
btnC.pull = Pull.UP
# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
# 128x32 OLED Display
reset_pin = DigitalInOut(board.D4)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=reset_pin)
# Clear the display.
display.fill(0)
display.show()
width = display.width
height = display.height
# Configure RFM9x LoRa Radio
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
rfm9x.receive_timeout = 0.5
prev_packet = None
while True:
packet = None
# draw a box to clear the image
display.fill(0)
display.text('RasPi LoRa', 35, 0, 1)
#print("Timeout " + str(rfm9x.receive_timeout))
# check for packet rx
packet = rfm9x.receive()
if packet is None:
display.text('- Waiting for PKT -', 15, 20, 1)
display.show()
#print("CRC Error " + str(rfm9x.crc_error()))
else:
# Display the packet text and rssi
display.fill(0)
prev_packet = packet
packet_text = str(prev_packet, "utf-8")
display.text('RX: ', 0, 0, 1)
display.text(packet_text, 25, 0, 1)
print("Received " + packet_text)
display.show()
time.sleep(0.1)
If I swap transmit and receive so I am receiving on the pi400 then I am not missing any packets. This is like because the pi400 process the screen updates so much faster so there is much less "dead" time before it starts listening again.
- jerryn
- Posts: 1868
- Joined: Sat Sep 14, 2013 9:05 am
Re: RFM95W Lora radio cannot receive
I modified the examples to use "reliable datagram" and node addressing so each packet sent is acknowledged.
This eliminated missed messages.
here is the new code -- I removed the extraneous stuff for the buttons.
transmit with ack:
receive with ack
This eliminated missed messages.
Code: Select all
pi@gjnpirfm9xswitch:~ $ python receive_ack.py
Received 1
Received 2
Received 3
Received 4
Received 5
Received 6
Received 7
Received 8
Received 9
Received 10
Received 11
Received 12
Received 13
Received 14
Received 15
Received 16
Received 17
Received 18
Received 19
Received 20
Received 21
Received 22
Received 23
Received 24
Received 25
transmit with ack:
Code: Select all
import time
import busio
from digitalio import DigitalInOut
import board
# Import the SSD1306 module.
import adafruit_ssd1306
# Import the RFM9x radio module.
import adafruit_rfm9x
# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
# 128x32 OLED Display
reset_pin = DigitalInOut(board.D4)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=reset_pin)
# Clear the display.
display.fill(0)
display.show()
width = display.width
height = display.height
# Configure LoRa Radio
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
# set delay before sending ACK
rfm9x.ack_delay = 0.1
# set node addresses
rfm9x.node = 1
rfm9x.destination = 2
prev_packet = None
count = 0
while True:
count = count + 1
# draw a box to clear the image
display.fill(0)
send_data = bytes(str(count), "utf-8")
status = rfm9x.send_with_ack(send_data)
print("sending " + str(count) + ", status " + str(status))
display.text(str(count), 25, 15, 1)
display.show()
time.sleep(2)
receive with ack
Code: Select all
import time
import busio
import board
from digitalio import DigitalInOut
# Import the SSD1306 module.
import adafruit_ssd1306
# Import the RFM9x radio module.
import adafruit_rfm9x
# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
# 128x32 OLED Display
reset_pin = DigitalInOut(board.D4)
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=reset_pin)
# Clear the display.
display.fill(0)
display.show()
width = display.width
height = display.height
# Configure RFM9x LoRa Radio
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
rfm9x.tx_power = 23
rfm9x.receive_timeout = 0.5
# set delay before transmitting ACK (seconds)
rfm9x.ack_delay = 0.1
# set node addresses
rfm9x.node = 2
rfm9x.destination = 1
prev_packet = None
while True:
packet = None
# draw a box to clear the image
display.fill(0)
display.text('RasPi LoRa', 35, 0, 1)
#print("Timeout " + str(rfm9x.receive_timeout))
# Look for a new packet: only accept if addresses to my_node
packet = rfm9x.receive(with_ack=True)
if packet is None:
display.text('- Waiting for PKT -', 15, 20, 1)
display.show()
#print("CRC Error " + str(rfm9x.crc_error()))
else:
# Display the packet text and rssi
display.fill(0)
prev_packet = packet
packet_text = str(prev_packet, "utf-8")
display.text('RX: ', 0, 0, 1)
display.text(packet_text, 25, 0, 1)
print("Received " + packet_text)
display.show()
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Thank you so much!
This is really interesting. The reliable send/receive does work better. I am using a Pi 3B+ for both the sender and receiver, so do you think the low speed I/O might be why the original programs don't work as well?
Another question - this might be another thread on its own. My ultimate goal is to get the board to send a Lorawan packet to TTN console. I have a RAK Lorawan gateway (https://store.rakwireless.com/products/ ... 2876102854) that will be forwarding packets to TTN. However, the gateway does not seem to pick up any packets when the board sends out Lora packets. Any ideas?
This is really interesting. The reliable send/receive does work better. I am using a Pi 3B+ for both the sender and receiver, so do you think the low speed I/O might be why the original programs don't work as well?
Another question - this might be another thread on its own. My ultimate goal is to get the board to send a Lorawan packet to TTN console. I have a RAK Lorawan gateway (https://store.rakwireless.com/products/ ... 2876102854) that will be forwarding packets to TTN. However, the gateway does not seem to pick up any packets when the board sends out Lora packets. Any ideas?
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Also, is there a way to use the CircuitPython library to print which channel the packet is received on? The API documentation does not list any methods.
- jerryn
- Posts: 1868
- Joined: Sat Sep 14, 2013 9:05 am
Re: RFM95W Lora radio cannot receive
Sorry for the delayed response.
Regarding LoRaWAN, the Circuitpython adafruit_rfm9x library only supports LoRa (peer to peer) communication, not LoRaWAN. Your LoRaWAN gateway will not respond to packets generated by this library. Unfortunately, at this time, the is no support for LoRAWAN in Circuitpython. The deprecated adafruit_tinylora library does not work with the LoRaWAN The Things Network (TTN) V3.
edited to remove Arduino reference — I forgot you are using Raspberry Pi.
Regarding LoRaWAN, the Circuitpython adafruit_rfm9x library only supports LoRa (peer to peer) communication, not LoRaWAN. Your LoRaWAN gateway will not respond to packets generated by this library. Unfortunately, at this time, the is no support for LoRAWAN in Circuitpython. The deprecated adafruit_tinylora library does not work with the LoRaWAN The Things Network (TTN) V3.
edited to remove Arduino reference — I forgot you are using Raspberry Pi.
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Ouch. That is not good news. So essentially the board is unusable with LoRaWAN? Is there another library that can be used with the board?
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Also, I upgraded my Pi to a 4B from a 3 B+ and there are 4 I/O pins on the board that prevent the RFM95 board to be inserted into the GPIO slot. Is the board incompatible with 4B?
- jerryn
- Posts: 1868
- Joined: Sat Sep 14, 2013 9:05 am
Re: RFM95W Lora radio cannot receive
I use the "riser" header" https://www.adafruit.com/product/4079 to get extra clearance on a Pi 4. It is compatible with the riser header.
As to using the Pi with LoraWAN, I don't know offhand of any libraries for the PI but I have not looked recently. Hopefully someone else can help. I'll try to take look as well in the next few days.
Good luck!
Note: I do not represent Adafruit. Just trying to help... sorry to bring bad news.
As to using the Pi with LoraWAN, I don't know offhand of any libraries for the PI but I have not looked recently. Hopefully someone else can help. I'll try to take look as well in the next few days.
Good luck!
Note: I do not represent Adafruit. Just trying to help... sorry to bring bad news.
- jaxandra
- Posts: 13
- Joined: Fri Apr 21, 2023 12:38 pm
Re: RFM95W Lora radio cannot receive
Thank you! I appreciate the help. I figured you were representing adafruit.
Off topic: is there any official support for any of these boards through adafruit? It seems disingenuous that they are selling these with claim for Lorawan support.
Off topic: is there any official support for any of these boards through adafruit? It seems disingenuous that they are selling these with claim for Lorawan support.
Please be positive and constructive with your questions and comments.