nrf24l01 failes to send

Hi, guys. I am trying to send information using 2 arduino nanos, 2 nrf sockets (to protect nrf as it is connected to 5v) and nrf24l01. However, it failes to send and I do not understand why. I connected everything using jumpers on a breadboard.

Note: I did not use capacitor between VCC and GND pins of nrf socket.

pins connections:

(nano) (nrf socket)
D13 SCK
D12 MI
D11 MO
D8 CSN
D7 CE
5v VCC

I am using GettingStarted programm that is provide by nrf24 library.

/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/

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

/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 0;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 0;

void setup() {
  Serial.begin(115200);
  Serial.println(F("RF24/examples/GettingStarted"));
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
  
  radio.begin();
  radio.setAutoAck(false);
  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
  
  
/****************** Ping Out Role ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.
    
    
    Serial.println(F("Now sending"));

    unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
     if (!radio.write( &start_time, sizeof(unsigned long) )){
       Serial.println(F("failed"));
     }
        
    radio.startListening();                                    // Now, continue listening
    
    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
    
    while ( ! radio.available() ){                             // While nothing is received
      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
          timeout = true;
          break;
      }      
    }
        
    if ( timeout ){                                             // Describe the results
        Serial.println(F("Failed, response timed out."));
    }else{
        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
        radio.read( &got_time, sizeof(unsigned long) );
        unsigned long end_time = micros();
        
        // Spew it
        Serial.print(F("Sent "));
        Serial.print(start_time);
        Serial.print(F(", Got response "));
        Serial.print(got_time);
        Serial.print(F(", Round-trip delay "));
        Serial.print(end_time-start_time);
        Serial.println(F(" microseconds"));
    }

    // Try again 1s later
    delay(1000);
  }



/****************** Pong Back Role ***************************/

  if ( role == 0 )
  {
    unsigned long got_time;
    
    if( radio.available()){
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
      }
     
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      Serial.print(F("Sent response "));
      Serial.println(got_time);  
   }
 }




/****************** Change Roles via Serial Commands ***************************/

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == 0 ){      
      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
      role = 1;                  // Become the primary transmitter (ping out)
    
   }else
    if ( c == 'R' && role == 1 ){
      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
       role = 0;                // Become the primary receiver (pong back)
       radio.startListening();
       
    }
  }


} // Loop

COM port output

Now sending
failed
Failed, response timed out.

I'd start by checking if you can even see the radio on the SPI bus. After 'startListening()' try calling 'isChipConnected()'. It returns a bool (true if the radio is found). If that fails, you have a hardware problem. If it succeeds, try using the code in @Robin2's nRF24L01+ Tutorial.

@gfvalvo , thanks. The chip is connected, I am getting true. Furthermore, the code from tutorial works, but I still do not understand why the code from GettingStarted was not working. Can anyone explain why?

Hi,
Welcome to the forum.
Do both codes use the same Library?

Tom.. :slight_smile:

Thanks @TomGeorge. Yes, they do.

VCC = 5V ?

The max voltage for this device is 3.6v

Steve

Yeah, normally it is 3.6V. However, I am using nrf socket that regulates 5V.

elnur94:
Furthermore, the code from tutorial works,

Then scrap the code you're trying to use and base your project's code on the tutorial.

The code from tutorial was working first time. But after turning off the transmitter and receiver it stopped working.

Transmittter output:

Data Sent Message 0 Tx failed

Have you tried to reseat the jumper wires or replacing them? Bad connections could be a cause.

elnur94:
Yeah, normally it is 3.6V. However, I am using nrf socket that regulates 5V.

Ah, sorry, did not notice that.
That's the first time I have seen one of those sockets and it looks like it makes life a lot simpler. I will have to order one now!

Steve

@Danois90, yes I have tried, but still no result.

Have you tried to use a higher PA level (increase the range) of the NRF's? Do you have a spare NRF to test if either of your test items has been damaged?

@Danois90 I tried all MAX, MIN and LOW. And as you told replaced nrfs, but nothing changed

When I call radio.isChipConnected() it returns true. However, i can not send information by calling radio.write();

elnur94:
The code from tutorial was working first time. But after turning off the transmitter and receiver it stopped working.

Transmittter output:

Data Sent Message 0 Tx failed

How do you mean "turning off the Tx and Rx"?
Did you turn the controllers OFF as well?
Can you post a picture of your project so we can see your component layout please?
Thanks.. Tom.... :slight_smile:

elnur94:
The code from tutorial was working first time. But after turning off the transmitter and receiver it stopped working.

That suggests you have a bad connection somewhere.

Have you tried the connection test program in my Tutorial?

Wireless problems can be very difficult to debug and the only way to do so is by being very very systematic. Statements like "But after turning off the transmitter and receiver it stopped working" don't provide useful information. Everyone knows it won't work when it is switched off so that is clearly not what you meant to say.

And you need to tell us in great detail exactly what you did to switch off and restart.

The programs (along with the other advice) in my Tutorlal work for me and they have worked for other Forum members. They are what I use to test my own nRF24 modules if I run into a problem.

Have you some spare nRF24 modules in case one of them is faulty?

...R

I attached 3 photos of receiver, schematic for transmitter it is the same. By "turning off" I meant unplugging usb cable of nano and plugging it again. After plugging back it stopped working. Here is the debugging code (it just tests the connection between the Arduino and its nRF24 without attempting to send or receive any data to / from another nRF24). And yes, I do have 2 more nrf.

RECEIVER OUTPUT

CheckConnection Starting

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 = 0x00
EN_RXADDR = 0x02
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 = 0x00
EN_RXADDR = 0x02
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

TRANSMITTER OUTPUT

CheckConnection Starting

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 = 0x4141417852 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x4141417852
RX_PW_P0-6 = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW


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 = 0x4141417852 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x4141417852
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x23
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW

Images from Reply #17 so we don't have to download them. See this Simple Image Guide

...R

elnur94:
I attached 3 photos of receiver, s

I would not trust myself to make sense of the wiring from your (or any) photographs of the hardware. It is just too easy to make a mistake. Also, in each of your photos there are wires going off-screen.

You need to make a complete wiring diagram with pencil and paper and with all the connections labelled. Then post a photo of the drawing,

...R