Having issue with the nRF24L01+ - Remote code

Hey all, first time here. I read through a couple other forum posts on similar problem, but they seem to be a failure to communicate at all and sending timeouts. My issue isn't with the ping/pong, which worked just fine. I am trying the led_remote code that came with the MIRF download, but when I click the button, it says "Now Sending...failed."

For the code, the only mods I made were to
role_pin = 4; (pin 4 on the Arduino controlling the LED is grounded),
const uint8_t button_pins[] = {5};
const uint8 led_pins[] = {3};

Everything else was left alone. Any help would be greatly appreciated!!

Here is the serial printout of COM3 (remote):

RF24/examples/led_remote/

ROLE: Remote

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

p.s. not sure how to post the serial output into those nice code boxes I see elsewhere on the forums, sorry!

Edit - I am actually using the RF24 library/download and examples (See led_remote sketch below). Updated the pins and set up a second button and led just to try it out. At one point I got an led to turn off, once, and then all subsequent button clicks still failed to send. I've reset both Arduinos, I've swapped them (and swapped the pins/buttons/etc). In the serial monitor the one thats supposed to send is listed as Role: Remote at the top, and the led is listed as Role: Led.

Every click = Now sending...failed. No timeouts or pauses.

#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);

// sets the role of this unit in hardware.  Connect to GND to be the 'led' board receiver
// Leave open to be the 'remote' transmitter
const int role_pin = 7;

// Pins on the remote for buttons
const uint8_t button_pins[] = { 2,3 };
const uint8_t num_button_pins = sizeof(button_pins);

// Pins on the LED board for LED's
const uint8_t led_pins[] = { 2,6 };
const uint8_t num_led_pins = sizeof(led_pins);

//
// Topology
//

// Single radio pipe address for the 2 nodes to communicate.
const uint64_t pipe = 0xF0F0F0F0E1LL;

//
// Role management
//
// Set up role.  This sketch uses the same software for all the nodes in this
// system.  Doing so greatly simplifies testing.  The hardware itself specifies
// which node it is.
//
// This is done through the role_pin
//

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

// The debug-friendly names of those roles
const char* role_friendly_name[] = { "invalid", "Remote", "LED Board"};

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

//
// Payload
//

uint8_t button_states[num_button_pins];
uint8_t led_states[num_led_pins];

//
// Setup
//

void setup(void)
{
  //
  // Role
  //

  // set up the role pin
  pinMode(role_pin, INPUT);
  digitalWrite(role_pin,HIGH);
  delay(20); // Just to get a solid reading on the role pin

  // read the address pin, establish our role
  if ( digitalRead(role_pin) )
    role = role_remote;
  else
    role = role_led;

  //
  // Print preamble
  //

  Serial.begin(57600);
  printf_begin();
  printf("\n\rRF24/examples/led_remote/\n\r");
  printf("ROLE: %s\n\r",role_friendly_name[role]);

  //
  // Setup and configure rf radio
  //

  radio.begin();

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

  // This simple sketch opens a single pipes for these two nodes to communicate
  // back and forth.  One listens on it, the other talks to it.

  if ( role == role_remote )
  {
    radio.openWritingPipe(pipe);
  }
  else
  {
    radio.openReadingPipe(1,pipe);
  }

  //
  // Start listening
  //

  if ( role == role_led )
    radio.startListening();

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

  radio.printDetails();

  //
  // Set up buttons / LED's
  //

  // Set pull-up resistors for all buttons
  if ( role == role_remote )
  {
    int i = num_button_pins;
    while(i--)
    {
      pinMode(button_pins[i],INPUT);
      digitalWrite(button_pins[i],HIGH);
    }
  }

  // Turn LED's ON until we start getting keys
  if ( role == role_led )
  {
    int i = num_led_pins;
    while(i--)
    {
      pinMode(led_pins[i],OUTPUT);
      led_states[i] = HIGH;
      digitalWrite(led_pins[i],led_states[i]);
    }
  }

}

//
// Loop
//

void loop(void)
{
  //
  // Remote role.  If the state of any button has changed, send the whole state of
  // all buttons.
  //

  if ( role == role_remote )
  {
    // Get the current state of buttons, and
    // Test if the current state is different from the last state we sent
    int i = num_button_pins;
    bool different = false;
    while(i--)
    {
      uint8_t state = ! digitalRead(button_pins[i]);
      if ( state != button_states[i] )
      {
        different = true;
        button_states[i] = state;
      }
    }

    // Send the state of the buttons to the LED board
    if ( different )
    {
      printf("Now sending...");
      bool ok = radio.write( button_states, num_button_pins );
      if (ok)
        printf("ok\n\r");
      else
        printf("failed\n\r");
    }

    // Try again in a short while
    delay(20);
  }

  //
  // LED role.  Receive the state of all buttons, and reflect that in the LEDs
  //

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

        // Spew it
        printf("Got buttons\n\r");

        // For each button, if the button now on, then toggle the LED
        int i = num_led_pins;
        while(i--)
        {
          if ( button_states[i] )
          {
            led_states[i] ^= HIGH;
            digitalWrite(led_pins[i],led_states[i]);
          }
        }
      }
    }
  }
}

And on a whim, following with other people having issues with timeouts, I soldered a 2.2uf capacitor on the module accross GND and VCC. Still not fixing the issue, still getting "Now sending...failed".

Sigh

Make sure you use no more than 3.3V for VCC.
(Since you are getting some output that looks valid from the nRF24L01+ device, I assume you are already doing this.)

Verify the TX/RX address (pipe). In your printout below, you use TX_ADDR= 0xe8e8f0f0e1 (and the same address will show up in RX pipe 0 using this library; RX_ADDR_P0-1 = 0xe8e8f0f0e1 0xc2c2c2c2c2).
While your code indicates a different address. (On the receiver side it will be in address pipe 1.)

const uint64_t pipe = 0xF0F0F0F0E1LL;

Lower the transmit power if your devices are close together.
Add the following to your setup(), somewhere after begin(), so that it is executed for all roles.

radio.setPALevel( RF24_PA_LOW ) ;

Hey, thanks for the reply.

  1. Yes, they are hooked up to the 3.3V line on each arduino. Also I know that can be testy, but the ping/pong works just fine (22ms latency), but I did try the capacitor from VCC to GND and it didn't affect anything.

  2. The address was originally 0xe8e8f0f01, then I changed it to a different one from another code just to test.

I have since reset it back to 0xE8E8F0F0E1LL.

I now see this on the Remote serial monitor:

RX_ADDR_P0-1	= 0xe8e8f0f0e1 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR	        = 0xe8e8f0f0e1
RX_PW_P0-6      = 0x20 0x00 0x00 0x00 0x00 0x00

and on the LED serial monitor:

RX_ADDR_P0-1  = 0xe7e7e7e7e7 0xe8e8f0f0e1
RX_ADDR_P2-5  = 0xc3 0xc4 0xc5 0xc6
TX_ADDR              = 0xe7e7e7e7e7
RX_PW_P0-6      = 0x00 0x20 0x00 0x00 0x00 0x00

Does that look right?

I also tried the PA_LOW, and it is showing it on the monitor as such, but still just getting a "Now sending...failed" notice.

Having the same issue. Very new to nRF24L01 and Arduino in general. I have been able to get the simple ping pong code runningwith same standard delay of 22ms just fine, but can not get the LED remote working at all. Have tried some variants, and simplified the code to run for a single button and single LED and nothing has worked so far. I was initially using the original RF24 library and then tried using the updated RF24 library but neither has worked.

I'm simply just trying to get a single button to work wirelessly. Any help is greatly appreciated!!

I have still not had any success with this. I ordered a small batch of new NRF24L01+'s from Amazon, so I am hoping I can get at least 1 pair to work.

Hi All
Ive been playing with these for some time now and have exactly the same issues, but if i breadboard the 328,s then i have flawless switching operation.

My setup is 2 nrfs in elechouse sheilds on the unos for Rx and a Mega for the Tx, after extensive manipulation of all aspects ie power/smoothing etc etc im convinced its how the switching is applied that is the issue.

Essef 8)

Just to add ive moved ide to Mariamole as i found it a bloody nightmare running 3 boards and got confused and frustrated having to switch serial/usb ports and setups every time i made even smalla code changes, since you cant open multiple ide/usb ports !.

Heres link to the nrf/sheilds
http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=74&products_id=2245

Mariamole
http://dalpix.com/mariamole-download

Essef :grin: