NRF24 Server side not initializing

Hey Guys,

I am trying to play around with 2 nrf24l+'s. I have 2 arduinos with both modules wired in the same through the voltage regulator module. When running any of the example sketches from the radiohead library my server side always throws init failed to the serial monitor.

If I switch the server and client arduinos to check the components work I get the sane error no matter which arduino is the server.

Does anyone have a clue as to how to fix it?
I have attached the wiring schematic and I have used all 3 different types of data transfer examples from the radiohead library.

CLIENT SIDE

// nrf24_client.pde
// -- mode: C++ --
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (Anarduino Mini Details) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println(“init failed”);
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println(“setChannel failed”);
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println(“setRF failed”);
}

void loop()
{
Serial.println(“Sending to nrf24_server”);
// Send a message to nrf24_server
uint8_t data = “Hello World!”;
nrf24.send(data, sizeof(data));

nrf24.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);

if (nrf24.waitAvailableTimeout(500))
{
// Should be a reply message for us now
if (nrf24.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
Serial.println(“recv failed”);
}
}
else
{
Serial.println(“No reply, is nrf24_server running?”);
}
delay(400);
}

SERVER SIDE

// nrf24_server.pde
// -- mode: C++ --
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (Anarduino Mini Details) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println(“init failed”);
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println(“setChannel failed”);
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println(“setRF failed”);
}

void loop()
{
if (nrf24.available())
{
// Should be a message for us now
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf24.recv(buf, &len))
{
// NRF24::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);

// Send a reply
uint8_t data = “And hello back to you”;
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
Serial.println(“Sent a reply”);
}
else
{
Serial.println(“recv failed”);
}
}
}

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

…R

PS … To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

I tried your code and adjusted my wiring for it.

I still have the same fail to initialise with the server side

Snailinabottle:
I tried your code and adjusted my wiring for it.

I still have the same fail to initialise with the server side

Please post the code that YOU uploaded to your Arduinos and I will have a look at it. Also post a sample of the output from your two Arduinos.

Have you tried the connection test program in my Tutorial to make sure the Arduino can talk to the nRF24 it is connected to?
If you are getting a very fast response on the receive Arduino it usually means it is not communicating properly with its Arduino.

What Arduinos are you using?

How are you powering the nRF24s?

...R

Hey Robin thanks for your help so far.

here is the code i uploaded to my arduinos. I am using a sintron UNO dip and a generic chinese smd uno. I am powering my NRF24 through one of the little 5v-3.3v modules.

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

Serial monitor output on server.

Server

09:40:19.345 -> SimpleTx Starting
09:40:20.392 -> Data Sent Message 0  Tx failed
09:40:21.392 -> Data Sent Message 0  Tx failed
09:40:22.393 -> Data Sent Message 0  Tx failed
09:40:23.446 -> Data Sent Message 0  Tx failed
09:40:24.447 -> Data Sent Message 0  Tx failed
09:40:25.447 -> Data Sent Message 0  Tx failed
09:40:26.449 -> Data Sent Message 0  Tx failed
09:40:27.496 -> Data Sent Message 0  Tx failed
09:40:28.497 -> Data Sent Message 0  Tx failed
09:40:29.500 -> Data Sent Message 0  Tx failed
09:40:30.553 -> Data Sent Message 0  Tx failed
09:40:31.554 -> Data Sent Message 0  Tx failed
09:40:32.554 -> Data Sent Message 0  Tx failed
09:40:33.554 -> Data Sent Message 0  Tx failed
09:40:34.602 -> Data Sent Message 0  Tx failed
09:40:35.605 -> Data Sent Message 0  Tx failed
09:40:36.606 -> Data Sent Message 0  Tx failed
09:40:37.661 -> Data Sent Message 0  Tx failed
09:40:38.661 -> Data Sent Message 0  Tx failed
09:40:39.662 -> Data Sent Message 0  Tx failed
09:40:40.664 -> Data Sent Message 0  Tx failed
09:40:41.713 -> Data Sent Message 0  Tx failed

I note that the client is receiving many packages per second yet the Tx is only refreshing about 1per second.

Serial output client

Client

09:41:36.609 -> ⸮SimpleRx Starting
09:41:38.210 -> Data received 
09:41:38.257 -> Data received 
09:41:38.257 -> Data received 
09:41:38.310 -> Data received 
09:41:38.310 -> Data received 
09:41:38.310 -> Data received 
09:41:38.310 -> Data received 
09:41:38.357 -> Data received 
09:41:38.357 -> Data received 
09:41:38.411 -> Data received 
09:41:38.411 -> Data received 
09:41:38.411 -> Data received 
09:41:38.411 -> Data received 
09:41:38.458 -> Data received 
09:41:38.458 -> Data received 
09:41:38.511 -> Data received 
09:41:38.511 -> Data received 
09:41:38.511 -> Data received 
09:41:38.511 -> Data received 
09:41:38.558 -> Data received 
09:41:38.558 -> Data received 
09:41:38.611 -> Data received 
09:41:38.611 -> Data received 
09:41:38.611 -> Data received 
09:41:38.611 -> Data received 
09:41:38.658 -> Data received 
09:41:38.658 -> Data received 
09:41:38.711 -> Data received 
09:41:38.711 -> Data received 
09:41:38.711 -> Data received

Robin,

I just found your diagnostic program and ran it and it appears that one of my nrfs isnt getting a good connecting im going to re solder it and hopefully that fixes it.

your diagnostic tool is wonderful and I have just added it to my toolbox sketches.

If i still have trouble after resoldering ill be in touch

this is a a good result, is it not?

12:23:32.414 -> CheckConnection Starting
12:23:32.448 -> 
12:23:32.448 -> FIRST WITH THE DEFAULT ADDRESSES after power on
12:23:32.482 ->   Note that RF24 does NOT reset when Arduino resets - only when power is removed
12:23:32.585 ->   If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
12:23:32.675 ->      communicating with the nRF24
12:23:32.716 -> 
12:23:32.716 -> STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
12:23:32.763 -> RX_ADDR_P0-1	 = 0xe7e7e7e7e7 0xc2c2c2c2c2
12:23:32.801 -> RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
12:23:32.848 -> TX_ADDR		 = 0xe7e7e7e7e7
12:23:32.902 -> RX_PW_P0-6	 = 0x00 0x00 0x00 0x00 0x00 0x00
12:23:32.948 -> EN_AA		 = 0x3f
12:23:32.948 -> EN_RXADDR	 = 0x03
12:23:32.948 -> RF_CH		 = 0x4c
12:23:33.002 -> RF_SETUP	 = 0x07
12:23:33.002 -> CONFIG		 = 0x0e
12:23:33.002 -> DYNPD/FEATURE	 = 0x00 0x00
12:23:33.045 -> Data Rate	 = 1MBPS
12:23:33.045 -> Model		 = nRF24L01+
12:23:33.102 -> CRC Length	 = 16 bits
12:23:33.102 -> PA Power	 = PA_MAX
12:23:33.149 -> 
12:23:33.149 -> 
12:23:33.149 -> AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
12:23:33.203 ->  and 250KBPS data rate
12:23:33.203 -> 
12:23:33.203 -> STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
12:23:33.303 -> RX_ADDR_P0-1	 = 0xe7e7e7e7e7 0x4141417852
12:23:33.350 -> RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
12:23:33.350 -> TX_ADDR		 = 0xe7e7e7e7e7
12:23:33.403 -> RX_PW_P0-6	 = 0x00 0x20 0x00 0x00 0x00 0x00
12:23:33.450 -> EN_AA		 = 0x3f
12:23:33.450 -> EN_RXADDR	 = 0x03
12:23:33.503 -> RF_CH		 = 0x4c
12:23:33.503 -> RF_SETUP	 = 0x27
12:23:33.503 -> CONFIG		 = 0x0e
12:23:33.550 -> DYNPD/FEATURE	 = 0x00 0x00
12:23:33.550 -> Data Rate	 = 250KBPS
12:23:33.603 -> Model		 = nRF24L01+
12:23:33.603 -> CRC Length	 = 16 bits
12:23:33.646 -> PA Power	 = PA_MAX
12:23:33.646 -> 
12:23:33.646 ->

Snailinabottle:
this is a a good result, is it not?

Yes, that seems OK.

I’m curious to know what needed to be soldered

…R