Struggle with NRF24L01 Radio Module

I have previously been working with NRF24LO1 Radio Modules. I have been trying to send a simple “Hello World” Message from an Elegoo Nano to an Arduino Uno. All of my attempts have failed. I don’t know what the problem is. I have been using the how to mechatronics code from their NRF24 video so I think the problem lies in my wiring but again I don’t know.

This is the sender code for the Nano

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

This is the receiver code for the Uno.

/*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

In previous attempts I have used an off brand 5v Sparkfun Pro Micro with no voltage regulator so I believe I fried that particular radio module.

There will be pictures in the comments of my wiring.

Help will be appreciated.

Thank You!

I would not let me post any pictures of the wiring.

The very first thing that you need to know when using the rf24 radios is that they take more power to operate properly than the 3.3V regulator on most any Arduinos can supply. That is the number one problem with getting them to work. As mentioned in robin2's tutorial a 10uF cap across the radio power supply may help, but I supply mine with there own 3.3V supply. These adapters are handy.

Robin2's simple rf24 tutorial is a very good starting point to learn about the rf24. His simple example code is excellent.

How to post images so we don't have to download them and everyone can see them.
How to post an image.
Another page on posting images.

droidboy:
I would not let me post any pictures of the wiring.

  1. add the picture as an attachment
  2. right click and "copy link location"
  3. paste the link using link tags in the same message

See this Simple Image Posting Guide

...R

Thank you for all the feedback.

I followed through robin's tutorial and uploaded the master code to the nano and the slave code to the Uno.

I also moved the wires going to D7 and D8 to D9 and D10.

The Tx light on the nano is flashing every second indicating to me that it is sending data. Also in it's serial monitor this message appears "11:34:35.286 -> Data Sent Message 4 Acknowledge data 0, 0". So again I believe it is sending data.

However on the Uno side of things the Rx light is not lighting and there are no messages in its serial monitor other than the start up message, 11:38:32.161 -> SimpleRxAckPayload Starting. I don't think it is receiving anything.

Just for now I would like to use the master slave code but would later like to use a bidirectional connection.

Thanks for the directions on how to post pictures on the forum. I converted all the wiring pictures from Jpg to Png but it still wouldn't take them. I then found that the attachments won't take more than 2 megabytes and each of the pictures is 2.5.

Thanks again for the feed back. At Least now I have a Nano sending Data.

droidboy:
and there are no messages in its serial monitor other than the start up message, 11:38:32.161 -> SimpleRxAckPayload Starting.

Start with the simpler first example in my Tutorial. There is no point trying anything else if it does not work.

Have you tried the connection test program in my Tutorial to confirm that each Arduino can talk to the nRF24 it is attached to?

...R

droidboy:
Thanks for the directions on how to post pictures on the forum. I converted all the wiring pictures from Jpg to Png but it still wouldn't take them. I then found that the attachments won't take more than 2 megabytes and each of the pictures is 2.5.

Is there some reason you can't resize them?

The Simple Tx and Rx code is the code you are talking about right. I didn't see any other code than the Simple Tx Rx code and the two way code.

Also I noticed you have three libraries in use. SPI.h, nRF24Lo1.h and RF24.h. I have the first and third but I don't think I have the second one. Is the second one different than the third. The RF24.h library I got from the library manganger in the IDE. Do I need to get the second one? I think this might be my problem.

I lowered the image size to 1.5 Megabytes but now it says the image has failed security checks.

The nRF24Lo1.h file is part of RF24.h. So if RF24.h is installed so is nRF24Lo1.h.

droidboy:
Also I noticed you have three libraries in use. SPI.h, nRF24Lo1.h and RF24.h. I have the first and third but I don't think I have the second one.

In this nRF24Lo1.h you have a lower-case O. It should be a zero. nRF24L01.h

If you had simply copied and pasted the code from my Tutorial that problem would not have arisen.

If that is not the problem then please post the program that you are trying to compile and also post the error message that the compiler produces.

...R

Sorry, I did copy and paste both the Tx code and the Rx code from your tutorial though.

This is the Tx code

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

This is the Rx code

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        newData = false;
    }
}

There are no error messages flashing. The nano is still looking like it is sending items but the uno does not receive anything.

Please post the images. Any problems uploading them has to be on your end.

Have you tried resetting the radios after uploading? As mentioned in Robin2's tutorial, the radios do not reset when the Arduino does. It requires that you cycle power to the Arduino (and radio) to reset the radio.

I will try that.

I also tried to make a schematic in drawings showing the wiring as my pictures aren't working.

NRF24lO1 radio Module wiring.pdf (207 KB)

NRF24lO1 radio Module wiring.pdf (207 KB)

I just tried resetting them. It didn't work.

Feel the Nano board carefully. Is it getting hot? I doubt that you can power the radio from the 50mA max that it can supply from the 3.3V output.

Have you tried putting a 10uF cap across the 3.3V power to the radios as described in the tutorial? Lack of power is a common problem with getting rf24 radios to work. Speaking from experience.

droidboy:
There are no error messages flashing.

If you have no error message I don't understand why you said in Reply #8 that you were missing one of the library files - that seems to have led us all on pointless wild goose chase.

Have you tried the connection test program in my Tutorial to confirm that both the nano and the Uno can talk to the nRF24 they are connected to. That needs to be your first test.

If the connection tests give positive results then the next issue is how are you powering the nRF24s?

Take things step by step and you will get them working.

...R