nRF24L01 programming notes

Viewed 20 times

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


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

radio = NRF24(GPIO, spidev.SpiDev())




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

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

    while not radio.available(0):
        if time.time() - start > 2:
            print("Timed out.")


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

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 11 hours ago
  • Also figured that my wireless mouse and keyboard might be interfering but unplugging and turning off those didn’t make any difference – StevenCellist 11 hours ago
  • 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 17 mins 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 17 mins 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 11 mins 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 10 mins 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 3 mins ago   Edit
  • 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 3 mins ago   Edit
  • # 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 2 mins ago   Edit

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: