0

I'm a Raspberry Pi n00b and a python beginner, but I have a lot of experience with DIY electronics, arduino and c#.

I've tried everything I can think of, and I just can't get the Pi to recognise the RF24.

here's my setup

Raspberry Pi 3 model B nRF24L01+

I'm using this tutorial which uses the Blavery version of the RF24 library, but I have tried at least 4 different tutorials and libraries, which all seem pretty similar.

here is the code:

import RPi.GPIO as GPIO
from lib_nrf24 import NRF24
import time
import spidev

GPIO.setmode(GPIO.BCM)

pipes = [[0xe7, 0xe7, 0xe7, 0xe7, 0xe7], [0xc2, 0xc2, 0xc2, 0xc2, 0xc2]]

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0, 17)
radio.setPayloadSize(32)
radio.setChannel(0x60)

radio.setDataRate(NRF24.BR_1MBPS)
radio.setPALevel(NRF24.PA_MIN)
radio.setAutoAck(True)
radio.enableDynamicPayloads()
radio.enableAckPayload()

radio.openReadingPipe(0, pipes[1])
radio.printDetails()

radio.startListening()

while(1):
    ackPL = [1]
    while not radio.available(0):
        time.sleep(1 / 100)
    receivedMessage = []
    radio.read(receivedMessage, radio.getDynamicPayloadSize())
    print("Received: {}".format(receivedMessage))

    print("Translating the receivedMessage into unicode characters")
    string = ""
    for n in receivedMessage:
        # Decode into standard unicode set
        if (n >= 32 and n <= 126):
            string += chr(n)
    print(string)
    radio.writeAckPayload(1, ackPL, len(ackPL))
    print("Loaded payload reply of {}".format(ackPL))

and here is the output:

Warning (from warnings module):
  File "/home/pi/Desktop/NRF24L01/lib_nrf24.py", line 377
    self.GPIO.setup(self.ce_pin, self.GPIO.OUT)
RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
STATUS   = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1    � = 0x0808080808 0x0808080808 
RX_ADDR_P2-5    � = 0x08 0x08 0x08 0x08 
TX_ADDR      = 0x0808080808 
RX_PW_P0-6  � = 0x08 0x08 0x08 0x08 0x08 0x08 
EN_AA        = 0x08 
EN_RXADDR   � = 0x08 
RF_CH        = 0x08 
RF_SETUP    � = 0x08 
CONFIG       = 0x08 
DYNPD/FEATURE   � = 0x08 0x08 
Data Rate    = 2MBPS
Model        = nRF24L01
CRC Length   = 8 bits
PA Power     = PA_MIN

Sometimes the addresses are different, but they never match the addresses from the code.

I've tried checking all the wiring with a multimeter, and it seems to be solid. I've tried with many different wires including ribbon cable directly to the nRF24 module and using a breadboard with the breakout. I tried using a capacitor on the power supply to the RF24. I tried sever different RF modules, all of which I tested with an Arduino and they work fine. I tried it with a Raspberry Pi 2, and had more or less the same results.

As its my first time using Pi, I don't really know the steps for how to debug the problem. I unfortunately don't have an oscilliscope/signal analyzer, so it's hard to test the serial pins. Any suggestions would be greatly appreciated!

thanks

1

3 Answers 3

0

This was too long to be a comment ...

  • You can get fix the warning by calling GPIO.cleanup() at the appropriate location.
  • Have a look at this post.
    • Seems to indicate either a dead nRF (less likely in your case given you got it working with an arduino)
    • SPI is not working (enabled ?). You should confirm SPI is correctly enabled
  • Try the example here as is and see if that works as expected ?
    • If it does, its probably your code, if it does not it is probably something else being overlooked
    • I noticed there is a time.sleep(1) call in the example code like so (but missing in yours ... may be its is required ?)

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0, 17)
time.sleep(1)                        # missing 
radio.setRetries(15,15)
radio.setPayloadSize(32)
radio.setChannel(0x60)
0

WOW

ok so I saw this post and just gave it a try, and it worked. That is to say I just swapped the old RF24 module out for a new one and BOOM. I guess the radios don't like 5v at all

2
  • The datasheet is quite explicit. Power Supply +1.9V - +3.6V DC
    – joan
    Commented Jul 10, 2018 at 17:55
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Commented Feb 9, 2020 at 19:52
0

This answer fixed my issues

In lib_nrf24.py in function:

def begin(self, csn_pin ... after self.spidev.open add:

self.spidev.max_speed_hz = 4000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.