Two nRF24L01+/Arduino UNOs don't talk to each other

Has anyone any experience using nRF24L01+ ? I am trying to establish simple ping/pong communication between two nodes connected on two arduino UNOs using this guide Getting Started with nRF24L01+ on Arduino | maniacbug and the RF24 library. So far it seems that the wires are connected well because I am getting addresses for both nodes :

RF24/examples/GettingStarted/

ROLE: Pong back

*** PRESS 'T' to begin transmitting to the other node

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xf0f0e1d23c 0xf0f0f0f0d2
RX_ADDR_P2-5	 = 0x69 0x96 0xa5 0xc3
TX_ADDR		 = 0xf0f0f0d269
RX_PW_P0-6	 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		 = 0x00
EN_RXADDR	 = 0x3f
RF_CH		 = 0x4c
RF_SETUP	 = 0x07
CONFIG		 = 0x0f
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01+
CRC Length	 = 16 bits
PA Power	 = PA_HIGH

What disappoints me is that by using GettingStarted example RF24: GettingStarted.pde both nodes are working but they are unable to establish connection.

My first question is: as every network equipment has a MAC address to be identified, shouldn't all rf24s have something similar ?

I have seen this :

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

is this some kind of MAC address or id ?

Please help, I am so thrilled about those sensors and I can't wait to make them talk :slight_smile:
No sleep today If I do not make them work :smiley:

No, had you read the manual instead of trying to apply a different concept with different actions (Mac Address) to a simple address called a pipe address... Nothing More nothing Less. Are both of your units in the same mode? if so then they're either talking at themselves or listening at themselves. Mode must be low for one unit, the receiver, IIRC after that every thing works... This is what I've read and I believe it to be accurate.

Doc

they have the same exact configuration. I have used the code provided from maniacbug's website which was mentioned to be working as is. To be honest, I have read the datasheet but I do not know where to spot the problem. Both units seem to be active and working (I do not have 0xfffffffff which mean that I might had a defective device).

I have also tried to set the same payload and channel but nothing happens. I am getting timeout messages from the client and the server does nothing. Has anyone used this kind of device with rf24 libraries ?

anyone please ?

I have used the nRF24L01 modules in several projects. Try this: Sending structs with nRF24L01 modules and the RF24 library - Bajdi electronics

@Bajdi is this code working as is ? I mean, I purchased two nRF24L01+ nodes from an ebay seller and tried them with RF24 wiring and Mirf. I failed completely with RF24, I succeeded with Mirf only once, yesterday, with a very simple send/receive program but afterwards I still fail. I know that the nodes work successfully because RF24 returns all of their addresses and not 0xfffffffff s.

thanks for the link

@Bajdi do you have any basic code that works for Arduino 1.0.5 ? There are also lots of libraries out there (either forks of rf24 or not) and there is a confusion in which works or not.

That code works for me in Arduino 1.0.5. Are you sure you are connecting them correctly? I never use the 3V3 power from the Arduino, to noisy...

@hyp3rkyd,
the following is what I got with my own nRF2401 test. I loaded the Getting Started
sketch from the installed library. Code is shown below.

These things are only good for about 10m range, BTW, unless you get a high
power module, like bajdi has.

BTW, I am using boards that have nice fat 3.3V regulators, and don't have a UNO,
so I don't know how well its 3V3 supply can handle RF modules. Also, if you read
this other thread, you'll see a lot of people appear to have power problems,
although adding a large cap across the RF module Vcc pins seems to help.

http://forum.arduino.cc/index.php?topic=82906.0

It worked fine the first time. My signon variables are a little different from yours,
and the data rate is slower, so you seem to have a different Getting Started
sketch. I just pressed 'T' and 'R', and it worked fine for both transmit and
receive.

RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe7e7e7e7e7 0xf0f0f0f0d2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR          = 0xe7e7e7e7e7
RX_PW_P0-6       = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA            = 0x3f
EN_RXADDR        = 0x03
RF_CH            = 0x4c
RF_SETUP         = 0x27
CONFIG           = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate        = 250KBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_HIGH
*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending 3628...ok...Got response 3628, round-trip delay: 25
Now sending 4654...ok...Got response 4654, round-trip delay: 24
Now sending 5680...ok...Got response 5680, round-trip delay: 24
Now sending 6705...ok...Got response 6705, round-trip delay: 24
Now sending 7731...ok...Got response 7731, round-trip delay: 24
*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK
Got payload 283422...Sent response.
Got payload 284449...Sent response.
Got payload 285475...Sent response.
Got payload 286500...Sent response.
Got payload 287526...Sent response.

Here is the source code for the sketch, no changes.

/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */

/**
 * Example for Getting Started with nRF24L01+ radios. 
 *
 * This is an example of how to use the RF24 class.  Write this sketch to two 
 * different nodes.  Put one of the nodes into 'transmit' mode by connecting 
 * with the serial monitor and sending a 'T'.  The ping node sends the current 
 * time to the pong node, which responds by sending the value back.  The ping 
 * node can then see how long the whole cycle took.
 */

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

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10 

RF24 radio(9,10);

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

//
// Role management
//
// Set up role.  This sketch uses the same software for all the nodes
// in this system.  Doing so greatly simplifies testing.  
//

// The various roles supported by this sketch
typedef enum { role_ping_out = 1, role_pong_back } role_e;

// The debug-friendly names of those roles
const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};

// The role of the current running sketch
role_e role = role_pong_back;

void setup(void)
{
  //
  // Print preamble
  //

  Serial.begin(57600);
  printf_begin();
  printf("\n\rRF24/examples/GettingStarted/\n\r");
  printf("ROLE: %s\n\r",role_friendly_name[role]);
  printf("*** PRESS 'T' to begin transmitting to the other node\n\r");

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
  //radio.setPayloadSize(8);

  //
  // Open pipes to other nodes for communication
  //

  // This simple sketch opens two pipes for these two nodes to communicate
  // back and forth.
  // Open 'our' pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

  //if ( role == role_ping_out )
  {
    //radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
  }
  //else
  {
    //radio.openWritingPipe(pipes[1]);
    //radio.openReadingPipe(1,pipes[0]);
  }

  //
  // Start listening
  //

  radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

  radio.printDetails();
}

void loop(void)
{
  //
  // Ping out role.  Repeatedly send the current time
  //

  if (role == role_ping_out)
  {
    // First, stop listening so we can talk.
    radio.stopListening();

    // Take the time, and send it.  This will block until complete
    unsigned long time = millis();
    printf("Now sending %lu...",time);
    bool ok = radio.write( &time, sizeof(unsigned long) );
    
    if (ok)
      printf("ok...");
    else
      printf("failed.\n\r");

    // Now, continue listening
    radio.startListening();

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    // Describe the results
    if ( timeout )
    {
      printf("Failed, response timed out.\n\r");
    }
    else
    {
      // Grab the response, compare, and send to debugging spew
      unsigned long got_time;
      radio.read( &got_time, sizeof(unsigned long) );

      // Spew it
      printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
    }

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

  //
  // Pong back role.  Receive each packet, dump it out, and send it back
  //

  if ( role == role_pong_back )
  {
    // if there is data ready
    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      unsigned long got_time;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &got_time, sizeof(unsigned long) );

        // Spew it
        printf("Got payload %lu...",got_time);

	// Delay just a little bit to let the other unit
	// make the transition to receiver
	delay(20);
      }

      // First, stop listening so we can talk
      radio.stopListening();

      // Send the final one back.
      radio.write( &got_time, sizeof(unsigned long) );
      printf("Sent response.\n\r");

      // Now, resume listening so we catch the next packets.
      radio.startListening();
    }
  }

  //
  // Change roles
  //

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == role_pong_back )
    {
      printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");

      // Become the primary transmitter (ping out)
      role = role_ping_out;
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
    }
    else if ( c == 'R' && role == role_ping_out )
    {
      printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");
      
      // Become the primary receiver (pong back)
      role = role_pong_back;
      radio.openWritingPipe(pipes[1]);
      radio.openReadingPipe(1,pipes[0]);
    }
  }
}
// vim:cin:ai:sts=2 sw=2 ft=cpp

@oric_dan thank you very much !

I've read this thread also : rf2401 problem with mega 2560 - Networking, Protocols, and Devices - Arduino Forum

it seems that the power from arduino is the first thing I'll have to look at. I'll put 2 caps in every nRF24L01+ and run GettingStarted right away.

First arduino with nRF24L01+

RF24/examples/GettingStarted/

ROLE: Pong back

*** PRESS 'T' to begin transmitting to the other node

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xf0f0f0f0d2 0xf0f0f0f0d2
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0xf0f0f0f0d2
RX_PW_P0-6	 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
EN_RXADDR	 = 0x03
RF_CH		 = 0x4c
RF_SETUP	 = 0x07
CONFIG		 = 0x0f
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01+
CRC Length	 = 16 bits
PA Power	 = PA_HIGH

Second one

RF24/examples/GettingStarted/

ROLE: Pong back

*** PRESS 'T' to begin transmitting to the other node

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xe7e7e7e7e7 0xf0f0f0f0d2
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0xe7e7e7e7e7
RX_PW_P0-6	 = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
EN_RXADDR	 = 0x03
RF_CH		 = 0x4c
RF_SETUP	 = 0x07
CONFIG		 = 0x0f
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01+
CRC Length	 = 16 bits
PA Power	 = PA_HIGH

what is returned

*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK

Now sending 36667...failed.

Failed, response timed out.

Now sending 37943...failed.

Failed, response timed out.

Now sending 39216...failed.

Failed, response timed out.

Now sending 40488...failed.

Failed, response timed out.

Now sending 41761...failed.

Failed, response timed out.

Now sending 43034...failed.

Failed, response timed out.

Now sending 44307...failed.

Failed, response timed out.

Now sending 45581...failed

with a 100nF cap in both ends

I think they were meaning more like 100 uF than nF.

Also, why does your data rate keep saying 1 Mbps? You may have a different
library. I think there may be multiple versions, and possibly forks with the
exact same names. This seems to be a bad fact of life with 3rd party
libraries. Drives me nuts.

I tried with 4.7uF and it worked ! successfully sent some packets... and then after 5 minutes it times out again.

I've reset both nodes, checked the soldering etc. ... maybe I must decrease the speed of connection to <1Mbps ?

with 10cm distance between them :

Now sending 21819...failed.

Failed, response timed out.

Now sending 23094...ok...Got response 23094, round-trip delay: 26

Now sending 24121...ok...Got response 24121, round-trip delay: 54

Now sending 25176...ok...Got response 25176, round-trip delay: 22

Now sending 26200...ok...Got response 26200, round-trip delay: 58

Now sending 27258...failed.

Failed, response timed out.

Now sending 28532...ok...Got response 28532, round-trip delay: 36

Now sending 29569...ok...Got response 29569, round-trip delay: 49

Now sending 30619...ok...Got response 30619, round-trip delay: 27

Now sending 31646...ok...Got response 31646, round-trip delay: 37

Now sending 32684...ok...Got response 32684, round-trip delay: 22

Now sending 33707...ok...Got response 33707, round-trip delay: 36

Now sending 34744...failed.

Failed, response timed out.

Now sending 36019...failed.

Failed, response timed out.

Now sending 37292...ok...Got response 37292, round-trip delay: 22

Now sending 38315...failed.

Failed, response timed out.

Now sending 39588...ok...Got response 39588, round-trip delay: 23

Now sending 40611...ok...Got response 40611, round-trip delay: 23

Now sending 41634...ok...Got response 41634, round-trip delay: 41

I think it's a forked one. But it seems working and arduino's 3v3 was the problem...

I am trying to test with RF24: pingpair.pde example. Do you know how can I send an int instead of an unsigned int so I can test with numbers ?

The only way I could figure out what it's doing is to go in and analyze the original
source code. I find I usually have to do this to figure out what the author really did.

hyp3rkyd:
I think it's a forked one. But it seems working and arduino's 3v3 was the problem...

I am trying to test with RF24: pingpair.pde example. Do you know how can I send an int instead of an unsigned int so I can test with numbers ?

You shd choose any of the latest RF24 forks... look at the graphs below on github...

BTW, I got RF24/nRF24L01 working for Arduino UNO, Raspberry Pi, attiny85 and Electric Imp.. all no issues with the 3.3V .. I got my radios from e-bay from 3 sources... see here Arduino for Beginners: Setup Nordic nRF24L01 RF modules to both Arduino UNO and Raspberry Pi

Any questions or issues, just post it here...

To add to the pot of info...

I have problems with MIRF and RF24 libraries as well - only occasional send/receive successes and not more than 14" apart.

I got maniacbugs to work straight away but have some issues. All 'systems' are straight forward in so much that the is nrf24 plugged straight in with no capacitors and nothing else going on except the examples.

maniacbugs interrupt example has defeated me so far :frowning:

Also I have replaced the the sending/returning of millis() with a simple counter and, hey ho, I don't like what I find.

I'm often receiving back one or two ackPayloads behind the message that has been sent.

I have also simulated loading the sender and receiver with delay()s in the code and it shows that another layer of validation needs to be added to your own sketches (in my opinion) in order to know what is going on and ensure that your server is returning the correct data to go with the request... I am still working on this as I write...

Which specific interrupt example? The basic Getting Started example sketch does not use interrupts.

pingpair_irq.pde