Rfm9x Radio with raspberry pi

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Rfm9x Radio with raspberry pi

Post by Iza22 »

Hello!
After connecting my rfm9x LoRa radio to a raspberry pi 3b, the OLED displays an error that the radio is not detected and I keep getting an error that says “failed to detect rfm9x with correct version—check wiring”
the code I used is the following from the Adafruit website:

Code: Select all

# SPDX-FileCopyrightText: 2018 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""
Wiring Check, Pi Radio w/RFM9x

Learn Guide: https://learn.adafruit.com/lora-and-lorawan-for-raspberry-pi
Author: Brent Rubell for Adafruit Industries
"""
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)

while True:
    # Clear the image
    display.fill(0)

    # Attempt to set up the RFM9x Module
    try:
        rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, 915.0)
        display.text('RFM9x: Detected', 0, 0, 1)
    except RuntimeError as error:
        # Thrown on version mismatch
        display.text('RFM9x: ERROR', 0, 0, 1)
        print('RFM9x Error: ', error)

    # Check buttons
    if not btnA.value:
        # Button A Pressed
        display.text('Ada', width-85, height-7, 1)
        display.show()
        time.sleep(0.1)
    if not btnB.value:
        # Button B Pressed
        display.text('Fruit', width-75, height-7, 1)
        display.show()
        time.sleep(0.1)
    if not btnC.value:
        # Button C Pressed
        display.text('Radio', width-65, height-7, 1)
        display.show()
        time.sleep(0.1)

    display.show()
    time.sleep(0.1)

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rfm9x Radio with raspberry pi

Post by mikeysklar »

Thanks for posting the test code you are running.

Which release of Pi OS are you running?

Can you post a photo of your setup?

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

Bullseye, and I run some code to make sure I had the most updated version

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

I want to post a picture of the setup but it keeps saying the photo is too big, what can I do to post it?

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

I attached a photo with the setup
Attachments
IMG-5150.JPG
IMG-5150.JPG (144.67 KiB) Viewed 210 times

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rfm9x Radio with raspberry pi

Post by mikeysklar »

Thank you for the photo of your setup and Pi OS release. Since your display is working it means you have the pins aligned and i2c is enabled.

You will want to confirm that SPI is enabled. This should show devices like spidev0.0 and spidev0.1.

Code: Select all

ls /dev/spi*
The packages installed and versions can be shown with pip3 list. This will tell us if the libraries are current.

Code: Select all

pip3 list
When you run the script are you using either:

Code: Select all

sudo python3 rfm9x_check.py
or

Code: Select all

python3 rfm9x_check.py
Is there anything related to SPI or rfm in the output of `dmesg`?:

Code: Select all

dmesg

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

I ran the code:

Code: Select all

ls /dev/spi*
and as you said the spidev0.0 and spidev0.1 devices were there
I also ran:

Code: Select all

pip3 list
The first attached photo displays the output:

When I run the script I usually use

Code: Select all

python3 rfm9x_check.py
But I just ran:

Code: Select all

sudo python3 rfm9x_check.py
and received the same error as before

Regarding the

Code: Select all

dmesg
command, I ran it and I'm not sure I saw anything related to SPI or rfm, I attached a second photo with part of the output that I thought could be relevant. If it is not, is there anything in particular I should look for to indicate information about the SPI or rfm?

Thank you
Attachments
Photo 2 (dmesg output)
Photo 2 (dmesg output)
IMG-5155.JPG (206.21 KiB) Viewed 200 times
Photo 1 (pip3 output)
Photo 1 (pip3 output)
IMG-5154.JPG (151.15 KiB) Viewed 200 times

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rfm9x Radio with raspberry pi

Post by mikeysklar »

I didn't see anything relevant in the dmesg, but we can skip that since you do have /dev/spi* devices showing up.

Thank you for the pip3 output list. There is a newer version of the rfm9x library which just came out and might help as there were some SPI fixes in v2.2.8.

Code: Select all

pip3 install -U adafruit-circuitpython-rfm9x
The last thing to try if this does not resolve the issue is to use another SD card and go back a release from Pi OS Bullseye to the Legacy Pi OS Lite Buster.

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

Hello
Thank you for your reply,
I ran the code you mentioned to get the updated library and it did not fix the issue.
I purchased a new SD card and attempted to get the radio working with the Legacy OS as you suggested and it still did not solve the issue.

The SPI is enabled and the tests show spi devices in the terminal correctly
I am not sure what else we could try

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rfm9x Radio with raspberry pi

Post by mikeysklar »

Thank you for trying the legacy setup and new library.

While it seems unlikely a hardware failure with a working OLED display it is a possibility.

Let's try a replacement rfm9x bonnet and please let us know if it resolves the issue.

You can email [email protected] requesting a replacement. Provide them with this forum link and your invoice#.

User avatar
Iza22
 
Posts: 7
Joined: Sat Jul 02, 2022 8:44 am

Re: Rfm9x Radio with raspberry pi

Post by Iza22 »

Thank you for your help, the new bonnet worked, it appears as "Detected"

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: Rfm9x Radio with raspberry pi

Post by mikeysklar »

Excellent. Thank you for the followup confirmation.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”