Go Down

Topic: Transmission stops after X seconds/transmissions (nrf24l01+) (Read 106 times) previous topic - next topic


I searched all over for a solution for this, and tried many setups.

I have two nano's, two nrf24l01+ and two socket adapters.
My set up is two nano's connected to a PC, but the power for socket adapters and nrf24l01+ is coming from 5v power bank (5v to 3.3v is on the socket adapter).

In all setups, codes and libraries, all works OK for a while, and then the receiver gets nothing, until resetting transmitter board. it can work for 10 seconds or 5 minutes. but then it stops.

I tried:

1. Switching nrf modules
2. Many rf24 libraries (maniacbug, nRF24, TMRh20, gcopeland)
3. Ping code, message code, servo operating code, in liberality examples, all works for few seconds.
4. Changing delay or adding millis()
5. Debugging with serial messages
6. powering from arduino's 3.3v without socket adapters.

HELP :-)


You need to post your programs.

Have a look at this Simple nRF24L01+ Tutorial.  I use the code in several projects and have not had any problems with prolonged operation.

Two or three hours spent thinking and reading documentation solves most programming problems.


I use the standard rf24 library (github.com/nRF24/RF24) with this example code (Only changed ce and csn leg numbers):

Code: [Select]

* 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(2,3);

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

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

void setup() {
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));

  // 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.
  // Open a writing and reading pipe on each radio, with opposite addresses
  // Start the radio listening for data

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) )){
    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;
    if ( timeout ){                                             // Describe the results
        Serial.println(F("Failed, response timed out."));
        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(F(", Got response "));
        Serial.print(F(", Round-trip delay "));
        Serial.println(F(" microseconds"));

    // Try again 1s later

/****************** 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 "));

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

} // Loop


Image from Reply #2 so we don't have to download it. See this  Simple Image Guide

Two or three hours spent thinking and reading documentation solves most programming problems.


I use the standard rf24 library (github.com/nRF24/RF24) with this example code (Only changed ce and csn leg numbers):
It will be easier to help if you try the examples in my Tutorial as I am more familiar with them.

Your photo does not show how you are powering your Arduinos and nRF24s. I'm not sure that the Nano's 3.3v pin is capable of powering an nRF24.

And it does not seem as if you have 10µF capacitors across Vcc and GND for the nRF24s

Two or three hours spent thinking and reading documentation solves most programming problems.



The socket adapter has capacitors on it, it also take 5v from the outside rail and output 3.3v to the nRF
Servo also takes 5v from the outside rail (powered with power bank, not in the picture).
Arduinos powered from PC's USB.

I will try your examples...


Most often Arduinos don't draw enough current to keep a power bank turned on... just a thought.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)


Whandall, you are absolutely correct,
I searched and found one power bank that just has an on/off button and the lights on it and on the adapters is always on. And still, I will try other power sources...

Go Up