Uncategorized

nRF24L01 troubleshooting notes

Asked 
Viewed 27 times
0

I have recently bought two nRF24L01+ radio chips for communication between my Raspberry Pi and Arduino. I will be solely using this from Raspberry towards Arduino. The tutorial I followed: https://circuitdigest.com/microcontroller-projects/wireless-rf-communication-between-arduino-and-raspberry-pi-using-nrf24l01

My problem is: I don’t receive anything. The Raspberry seems to send everything properly (i.e. “H”, “i”, “0”, … etc) Serial output is listed below. Can someone please help me?

The code I am using for Raspberry:

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

GPIO.setmode(GPIO.BCM)

pipes = [[0xE0, 0xE0, 0xF1, 0xF1, 0xE0], [0xF1, 0xF1, 0xF0, 0xF0, 0xE0]]

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0,25)

radio.setPayloadSize(8)
radio.setChannel(0x76)
radio.setDataRate(NRF24.BR_1MBPS)
radio.setPALevel(NRF24.PA_MIN)

radio.setAutoAck(True)
radio.enableDynamicPayloads()
radio.enableAckPayload()

radio.openWritingPipe(pipes[0])
radio.printDetails()

sendMessage = list(" Hi")
while len(sendMessage) < 8:
    sendMessage.append(0)

while True:
    start = time.time()
    radio.write(sendMessage)
    print("Sent the message: {}".format(sendMessage))
    radio.startListening()

    while not radio.available(0):
        time.sleep(1/100)
        if time.time() - start > 2:
            print("Timed out.")
            break

    radio.stopListening()
    time.sleep(3)

The code for my Arduino:

#include<SPI.h>                   // spi library for connecting nrf
#include<RF24.h>                  // nrf library

RF24 radio(9, 10) ;  // ce, csn pins    
void setup() {
  Serial.begin(9600) ;     // start serial monitor baud rate
  Serial.println("Starting.. Setting Up.. Radio on..") ; // debug message
  radio.begin();        // start radio at ce csn pin 9 and 10
  radio.setPALevel(RF24_PA_MIN) ;   // set power level
  radio.setChannel(0x76) ;            // set chanel at 76
  const uint64_t pipe = 0xE0E0F1F1E0LL ;    // pipe address same as sender i.e. raspberry pi
  radio.openReadingPipe(1, pipe) ;        // start reading pipe 
  radio.enableDynamicPayloads() ;
  radio.powerUp() ;          
}

void loop() {

  radio.startListening() ;        // start listening forever
  char receivedMessage[8] = {0} ;   // set incmng message for 32 bytes
  if (radio.available()) {       // check if message is coming
    radio.read(receivedMessage, sizeof(receivedMessage));    // read the message and save
    Serial.println(receivedMessage) ;    // print message on serial monitor 
    Serial.println("Turning off the radio.") ;   // print message on serial monitor
    radio.stopListening() ;   // stop listening radio
    String stringMessage(receivedMessage) ;     // change char to string
    delay(1000);    // delay of 1 second 
    Serial.print(stringMessage);   // print received mesage
  }
  delay(10);
}

Output: just a loop of

Turning off the radio.

Turning off the radio.

Turning off the radio.

I have checked my wiring three times over…

  • Figured my Arduino gives that output even while the Raspberry is turned off… – StevenCellist yesterday
  • Also figured that my wireless mouse and keyboard might be interfering but unplugging and turning off those didn’t make any difference – StevenCellist yesterday
  • Hi @StevenCellist, Welcome and nice to meet you. Ah, let me see. If Arduino gives same output even Rpi is turned off, then Arduino is not receiving anything or just rubbish from Rpi, and so the problem is perhaps on the Rpi side. Let us start doing troubleshooting the Rpi side: (1) Make sure the SPI software and hardware wiring is OK, by doing SPI loop back. (2) Make sure nRF24L01 is working, by pinging, ie, read config register 0x00 should read 0x80. Of course you can skip (1) and just do (2) If you read 0x80 from nRF24L01’s register 0x00, then SPI is OK. / to continue, … – tlfong01 18 hours ago    
  • (3) Read the tutorial “Wireless RF Communication using nRF24L01 Module -Abhiemanyu Pandit 2019aug01, circuitdigest.com/microcontroller-projects/…, (4) Run the tutorial’s python program for Rpi. The statement “radio.printDetails()” should print the “details” does it? – tlfong01 18 hours ago   
  • References: (1) nrf24l01 Features – components101 components101.com/wireless/nrf24l01-pinout-features-datasheet (2) nRF24L01+ Single Chip 2.4GHz Transceiver Product Specification v1.0 – Nordic 2008 components101.com/sites/default/files/component_datasheet/… – tlfong01 17 hours ago   
  • Ref (1) says the following: “The nRF24L01 module is a bit tricky to use especially since there are many cloned versions in the market. If you are having any problem with getting it work, try adding a 10uF and 0.1uF capacitor in parallel to the Vcc and Ground pins. Also make sure the 3.3V supply is clean and does not have any noise coupled in it.” – tlfong01 17 hours ago   
  • Then read the GitHub for the bad news: only for “virtual GPIO”, no longer supported. nRF24L01 Python Library – BLavery/lib_nrf24 2018 may V0.3 beta, no longer being maintained by the original author github.com/BLavery/lib_nrf24 For Raspberry Pi and virtual-GPIO. NRF24: strictly 3.3V supply!! Although logic pins are 5V tolerant. – tlfong01 17 hours ago   
  • Docs says the following: “This is BETA only so far. Everything has worked earlier, send, receive, including two RF24 on one host, and including RPI, virtual-GPIO and regular arduino sketch, all talking to each other. But recent testing has been only LIBRARY plus “example-nrf24-pair.py” on virtual-GPIO, so other parts are yet to be re-verified.” – tlfong01 17 hours ago    
  • # StevenCellist, So are you using “Virtual GPIO”? Have you found any updated program NOT using virtual GPIO? The Rpi python program looks not that hard. Perhaps you can rewrite it not using virtual GPIO. PS – I NEVER heard of “virtual GPIO”, so I asked. – tlfong01 17 hours ago    
  • I visited GiHub and found it was 5 years old, tweaked from the BegaBone program. So I don’t think it worth your time playing with a Non rpi hardware compatible, tweaked program and NO LONGER supported. Find an updated Rpi program and let me know. Thanks and cheers. – tlfong01 17 hours ago   
  • Just now I searched this forum for “nRF24L01” and found 100+ posts. I skimmed and found the follow best for troubleshooting: “Major trouble with nRF24L01+ controllers and the RF24 library – Asked 5 years ago Viewed 8k times” (1) raspberrypi.stackexchange.com/questions/23441/…. Many of the 100+ posts above had not answers, but this very good one by @jhallard summarized the causes of trouble and also gave a good recommendation for testing. – tlfong01 5 mins ago    
  • As I said earlier, I have done the following last evening: (1) Used SPI loop back test to make sure that SPI wiring is working, (2) Use a one line python statement to read the nRF24L01’s config register at address 0x00 and read successfully the default POR contents of 0x80. Next step is to try any tutorial but NOT your recommended one, for the reasons I gave above. In case you read the the above post @jhallardand and wish to try another tutorial recommend there, and still have problem,s I am happy to reproduce your setup, and see if I overlooked any other causes of trouble. Cheers. – tlfong01 2 mins ago    Edit   

==========================================================================

Asked 
Viewed 8k times
5
6

I’ve had a hellish last three days. All I’ve wanted to do is get an Arduino Uno and a Raspberry Pi B+ talking to eachother with these little guys, and after following many different tutorials, I’ve had absolutely no luck.

Some of the tutorials I have been following to get the circuit set up are these:

I have looked up the exact pin out of the Raspberry Pi B+ and used it to double check that I am getting the pin out correct, considering that most of the tutorials are using RPi model B’s.

The libraries I have tried using are the following:

At first I tried using the one by Stanley Seow, but it had been updated a bit since the tutorial so I was getting function input errors while trying to run the code that comes with the tutorials listed above. I was able to try out the examples included with the library, but none of them worked. Whenever I would run the function radio.printDetails(), I would get an output like the following:

On the Pi, with CE going to GPIO 25 and CSN going to GPIO 8 (CE0)

===============SPI Configuration ====================
CSN Pin      = CEO (PI Hardware Driven)
CE Pin       = Custom GPIO25
Clock Speed  = 8 Mhz
==================== NRF Config ===========================
Status    = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_PO-1 = 0xfffffffffff 0xfffffffffffff
TX_ADDR  = 0xfffffffffff
... = 0xfffff
... = 0xfffff
... = 0xff 0xff 0xff 0xff

...

Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_MAX

On the arduino, with the pins quadruple checked and in the right spot I get the same thing, everything is 0xff...fff

What could be wrong here? I’ve tried all of the examples included in all of the libraries listed above and everything either gives me the radio.printDetails() output listed above or one with all 0x0000‘s.

4

I finally figured it out. What happened was that when I first got the modules I accidentally hooked them both up to a 5V rail instead of the recommended 3.3V, or at least this is my best guess as to why nothing was working. I got another pair of the RF modules today and made sure to only connect them to 3.3V and they work absolutely perfectly with all of the tutorials listed above.

.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: