Nrf24lo1 Help

I just bought a few Nrf24 modules on amazon, but I can't get them to work. I'm following the instructions from this link:

I have no idea what the problem is! One thing I did notice is that my libraries are different. When I include the libraries I get:

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

This is different from the libraries illustrated from that link. I don't know if it's the code, the modules, or just something I'm doing. Any help would be greatly appreciated.

Thanks,
Anthony

this is the link to the amazon page

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

...R

I followed your instructions, and used your code. It still won't work. I can provide any inormation or pictures of the circuits if you need them.

Tell us exactly what Arduinos you are using and whether you have low power nRF24s (with pcb antenna) or the high power version (with external antenna).

Have you tried my connection test program with both of your Arduinos?

Make a couple of simple pencil drawings showing exactly how you have everything connected and post photos of the drawings. See this Simple Image Posting Guide

Post the two programs that YOU have uploaded to your Arduinos.

Post a sample of the output from each Arduino.

Have you some spare nRF24s in case one of them is faulty.

...R

Robin2:
Tell us exactly what Arduinos you are using and whether you have low power nRF24s (with pcb antenna) or the high power version (with external antenna).

OP provided a link to them. :wink:

Whandall:
OP provided a link to them. :wink:

Thanks. I had missed that. Seems like he has plenty of spares.

...R

I wired both arduous exactly the same way so if one of them is wrong both of them are wrong. Also, I have like ten of these modules and tried swapping them out but nothing changed.

I included the code I have running on both Arduino and the picture of one of the Arduino. The serial port for my emitter is totally blank, and for the receiver, the only thing that's printed is, "SimSimpleRx Starting"

Code for receiver-----------------------------------------------------------------------------------------------------

#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>

#include <SPI.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;
}
}

code for emitter------------------------------------------------------------------------------------------------------

#include <SPI.h>

#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.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;
}

These are the pcitures

IMG_4737.pdf (33.8 KB)

IMG_4739.pdf (23 KB)

update
this is the serial monitor for the sender
it keeps repeating this.

Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed

The serial monitor for the receiver just displays "SimSimpleRx Starting" or just "simpleRx Starting" it varies

I ran the test on both Arduino and this is what the serial monitor displayed:
CheckConnection Starting

Also, Sorry for spamming messages.

FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x27
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

You are not making it easy to help you. It's a good idea to read several other Threads before Posting your first question so you can learn how things are usually done.

When posting code please use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor See How to use the forum

Please DO NOT post images as PDFs. Post them as JPG or PNG files and make then make them visible in your Post so we don't have to download them. See this Simple Image Posting Guide

If the output from the connection test is identical to what you posted for both Arduinos then they seem to be able to communicate with their attached nRF24s.

You have not said what sort of Arduinos you are using. And I am still waiting to see the diagrams for how you have everything connected.

...R

I'm really sorry for the inconvenience. I'm new to this and should have been more prepared. I'm using two Arduino Unos. I included a link to a google doc with the images on it because I can't get them to upload. Sorry again for any trouble

https://docs.google.com/document/d/1_0PDGvgqjmhRH9XAkK6lzpMjbOxOXXGGcxkbQ_uA_Wg/edit?usp=sharing

This is the emitter code

#include <SPI.h>

#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>



// SimpleTx - the master or the transmitter



#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 receiver code

#include <SPI.h>

#include <printf.h>
#include <nRF24L01.h>
#include <RF24_config.h>
#include <RF24.h>



// SimpleRx - the slave or the receiver


#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;
    }
}

If you can't upload a JPG file the likely problem is that it contains EXIF data from a phone or camera. The usual solution is to copy it to a PNG file.

In any case I did have a look at your images and they don't show anything useful - photos of hardware rarely do.

For some reason the code at the top of each of your programs is different from my Tutorial. I have no idea whether that would affect the workings of the program. Best thing is to use my code with no changes - I know that works.

Please post photos of simple pencil drawings showing how you have YOUR equipment connected - as requested back in Reply #3

...R

I uploaded the picture to the google doc again. I think I followed your directions properly. I drew my setup and everything. I hope this helps.

https://docs.google.com/document/d/1_0PDGvgqjmhRH9XAkK6lzpMjbOxOXXGGcxkbQ_uA_Wg/edit?usp=sharing

It's working now. My serial monitor is displaying "Data received message n" 0-9. I'm not sure what changed because I didn't do anything new.

AnthonyP12:
I uploaded the picture to the google doc again.

For the future, it is much easier to help you if you upload pictures here and make them visible in your Post.

Good to hear it's working.

...R