Connecting between two NRF24s

Sorry, I just got a problem
I use this code and it still can't connect between two NRF24, but I tried you're checkconnection.ino it seem's that the arduino are connecting good with nrf24, did anyone know what's the problem?

// SimpleTx - the master or the transmitter

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


#define CE_PIN  7
#define CSN_PIN 8

const byte Address[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(Address);
}

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

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;
}
// SimpleRx - the slave or the receiver

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

#define CE_PIN  7
#define CSN_PIN 8

const byte Address[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, Address);
    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;
    }
}

I use this diagram to connect my nrf24


Update:
I edit my code to

//tx
radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setPALevel(RF24_PA_MIN);
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(Address);
\\rx
Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setPALevel(RF24_PA_MIN);
    radio.openReadingPipe(0, Address);
    radio.startListening();

and message 0 to message 1

I got the information from here:Simple nRF24L01+ 2.4GHz transceiver demo - #2 by Robin2

@ymj1225
Welcome.
Please read the forum guidelines How to get the best out of this forum

When you've read them please post your code in code tags </> as per the instructions. Posting an image of code is useless.

Please do not hijack other topics.

Thank you.

After you have read the guidelines, post both the transmitter and receiver code you have tried.
Also post a diagram of how you have connected the NRF24L01 devices to your Arduinos.
If the code and wiring appear correct, then the most likely problem is insufficient power to the radio devices.

The code has CE and CSN at pins 9 and 10. The diagram has CE and CSN at pins 7 and 8. Which?

Post a clear photo of your wiring.

I use the 9 and 10

Why does the diagram show 7 and 8?

Bad data is worse than no data.

OK,sorry I change to CE=7 and CSN=8

I'm now getting this? the left one says failed but the right one has success?

The receiver got the message but the transmitter did not get the corresponding 'ack' back. That can be symptom of a power problem.

I'm using my laptop to connect my Arduino, the usb port output was 5v is this problem?

I think you need a better power supply,
in your marginally working case, even a capacitor on the power pins could make it work.

Ok, I'll try it later thanks.

Oh, I use a 10uF capacitance and it works!!! thank you.

1 Like

The NRF24L01 is 5volt pin compatible, but must be powered at 3.3 volts or less.
A good solution for powering these is a purpose made adapter module:

I'm glad it works now.

The 3.3V supply of Arduinos is very dependent on the model/make,
and rarely enough for a standard NRF24L01+.
Using one of the adapters that @6v6gt linked, solves that problem.

ok then guys after all i need to use capicitor or an adapter and connect it to 3.3v
right?

The adapter connects to 5V. The adapter has a 3.3V regulator on it's board.