Nrf24 init failed even with correct connections and same code?

Hello, I have a project I am working on requiring wireless transmission. I am using the radio head library, with the default code for the nrf24. I have measured battery power and everything seems fine, with a stable 3.3v being supplied, and every pin having some pwm power going to it.

Here is the code for the server arduino:

// 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 (http://www.anarduino.com/mini/) 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");
    }
  }
}

Additionally here is a wiring diagram from my PCB layout:


I used the connections outlined in the dronebot video (The nRF24L01 - Wireless Joystick for Arduino Robot Car with nRF24L01+ - YouTube), but I did not use the breakout board and wired it directly, with a capacitor and a 3.3v step down.

I use a newly bought 9v alkaline battery to power it all.

Although I have concerns that the module itself may be damaged, as I had manually soldered out its pins (in a very unelegant way...) and replaced it with my own, to better fit the pcb. And I fear I might have lifted a trace in the nrf24. So I just want to know, is there anything wrong with my design, or should I buy two more sets of nrf24s?

The first error I see is the assumption that measuring battery voltage is measuring battery power. It is not. Measuring battery voltage only confirms the chemistry in the battery is working. To measure the battery power, you must measure the CURRENT produced by your battery when loaded by a suitable resistor. Then monitoring the battery voltage AND the current will tell you if the battery is fine or not.

But for the NRF24, try using a pair of AA batteries in series for it's power, with the - side connected to the NRF ground and the Arduino ground. The NRF needs quite a bit of current when it does it's very brief transmission. You will not be able to see this current pulse on a digital meter.

The current is a stable 12ma, is this sufficient. If it isn't how can I increase current in my circuit design?

I suspect that this may be contributing to your problem(s). These batteries are a poor choice for a projects battery power source. You may have more success with 3x (or 4x) 1.5V AA batteries.

No. You have no idea of the dynamic currents involved, nor of the effects of those current pulses on the battery voltage. Separate the battery powering your Arduino from those powering your NRF module.

Ok, I will think about and try these suggestions out! By the way, are the 3-4 AA batteries in series or parallel?

Series.

!.5 volts times the number of cells in series = total voltage.

I will just buy another set of NRF24's because I actually think I may have damaged the existing ones, as I know there is enough current and voltage already. Perhaps then I will try the many AA battery idea, as a last resort.

If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. The code in the examples is, I think, simpler than the RadioHead examples and has been proven to work many many times. If it does not work for you, there is likely a hardware problem.

Run the CheckConnection.ino (look in reply #30 in the tutorial) to verify the physical wiring between the radio module and its processor (Arduino).

Some other tips:

If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings.

Reset the radios by cycling power to them after uploading new code. I have found that to help. They do not reset with the Arduino.

Have a look at the common problems page.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.