NRF24LO1 problems

So I have been trying to get the nrf24l01 working for the past three days .But when I upload the code the transmitter says it got response 0.I am using the tmrh library.Pls halp fast.

transmitter code:
#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.setChannel(2);
radio.setPayloadSize(4);
radio.setAutoAck(false);
radio.setCRCLength(RF24_CRC_8);
pinMode(10,OUTPUT);

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

the output of transmitter:

*** CHANGING TO TRANSMIT ROLE – PRESS ‘R’ TO SWITCH BACK
Now sending
Sent 2561392, Got response 0, Round-trip delay 18044 microseconds
Now sending
Sent 3580828, Got response 0, Round-trip delay 19580 microseconds
Now sending
Sent 4601796, Got response 0, Round-trip delay 19344 microseconds
Now sending
Sent 5622528, Got response 0, Round-trip delay 19368 microseconds
Now sending
Sent 6643284, Got response 0, Round-trip delay 19368 microseconds
Now sending
Sent 7664032, Got response 0, Round-trip delay 19416 microseconds

Reciever code:

/*
* 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 = 1;

/* 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.setChannel(2);
  radio.setPayloadSize(4);
  radio.setAutoAck(false);
  radio.setCRCLength(RF24_CRC_8);
  pinMode(10,OUTPUT);

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

Its output:

Sent response 0
Sent response 4294967295
Sent response 0
Sent response 4278255616
Sent response 0
Sent response 0
Sent response 117440512
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 0
Sent response 4294967295
Sent response 0
Sent response 4294967167
Sent response 4294967295
Sent response 4294967295
Sent response 0
Sent response 0
Sent response 50331648
Sent response 0
Sent response 0
Sent response 4294967167
Sent response 0
Sent response 4294967103
Sent response 0
Sent response 0
Sent response 4294967040
Sent response 0
Sent response 4294967167
Sent response 4294967167

Pls help have been trying a lot but just not working

I can't help, but when I bought my nRF24L01's a few months ago I tested them with that "Getting started" code which worked as expected. So I guess all I'm saying is the code is "known good".

madhavmaheshwari: Pls halp fast.

On any forum, not just this one, you should always wait at least 24 hours for all the time zones to "check in". You might have just missed the person with the best knowledge and best ability to help.

How are you powering the NRF modules? Are they the modules with an external antenna, or do they have the antenna trace on the PCB?

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

Thanks for the reply,

They are the ones with an antenna trace in the pcb .Sorry ,but was a little desperate for a reply as this is the first time i posted on this forum.

I AM VERY SORRY I CANNOT REPLY TILL 10TH MARCH AS I AM STILL IN SCHOL.AND GOING FOR A TRIP.I WAS BASICALLY TRYING TO CREATE A GESTURE CONTROL ROBOT.BUT WAS EVENTUALLY NOT ABLE TO MAKE IT WORK.ANY SUGGESTIONS ON THE CAPACITORS OR COMMON PROBLEMS WOULD BE OF GREAT HELP.

Thanks a lot, Madhav