Arduino UNO and Arduino Pro Mini and NRF24L01+ not working

I have already tried possibly all the libraries (RF24, RF24(maniacbug), RadioHead, Mirf) available to with the NRF24L01+, to no avail. I might end up returning the modules I bought or getting them replaced, but before resorting to that possibility, I want to make sure I’m not doing anything wrong. Can anyone point out if there’s an error in my setup or code, or tell me how to solve this problem? It’s driving me nuts.

  1. My wiring on the UNO and the Pro Mini are the same:
NRF24L01+     Arduino
       CE --- 9
      CSN --- 10
      SCK --- 13
     MOSI --- 11
     MISO --- 12
  1. I am using a 10uF electrolytic capacitor between the VCC and GND lines that power the NRF24L01+ modules.

  2. I am running the pingpair.pde sketch from the maniacbug’s RF24 library examples. I changed the lines 68-69 so one Arduino is the ping_out and the other one is the pong_back.

Here’s lines 68-69:

pinMode(role_pin, INPUT);
digitalWrite(role_pin,LOW); // I change this to HIGH in one of the Arduinos

And here’s the pingpair.pde code:

/*
 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 RF Radio Ping Pair
 *
 * This is an example of how to use the RF24 class.  Write this sketch to two different nodes,
 * connect the role_pin to ground on one.  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);

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

//
// 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 hardware itself specifies
// which node it is.
//
// This is done through the role_pin
//

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

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

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

  // read the address pin, establish our role
  if ( ! digitalRead(role_pin) ) {
    Serial.println("This is pingout");
    role = role_ping_out;
  } else {
    Serial.println("This is pongback");
    role = role_pong_back;
  }

  //
  // Print preamble
  //

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

  //
  // 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 );
  radio.setPALevel(RF24_PA_MIN); 
  //
  // 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();
    }
  }
}
  1. Yet, it doesn’t work. These are my outputs for printDetails() for both Arduinos.

Arduino pro mini:

RF24/examples/pingpair/
ROLE: Ping out
STATUS        = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1  = 0xf0f0f0f0e1    0xf0f0f0f0f0
RX_ADDR_P2-5  = 0xc3 0xc4 0xc5 0xc6
TX_ADDR       = 0xf0f0f0f0e1
RX_PW_P0-6    = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA         = 0x3f
EN_RXADDR     = 0x03
RF_CH         = 0x4c
RF_SETUP      = 0x40
CONFIG        = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate     = 1MBPS
Model         = nRF24L01+
CRC Length    = 16 bits
PA Power      = PA_MIN
Now sending 87...failed.
Failed, response timed out.
Now sending 1374...failed.
Failed, response timed out.

Arduino UNO:

RF24/examples/pingpair/
ROLE: Pong back
STATUS        = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1  = 0xf0f0f0f0d2    0xf0f0f0f0f0
RX_ADDR_P2-5  = 0xc3 0xc4 0xc5 0xc6
TX_ADDR       = 0xf0f0f0f0d2
RX_PW_P0-6    = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA         = 0x3f
EN_RXADDR     = 0x03
RF_CH         = 0x4c
RF_SETUP      = 0x40
CONFIG        = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate     = 1MBPS
Model         = nRF24L01+
CRC Length    = 16 bits
PA Power      = PA_MIN

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo was the tutorial I used to try out my modules.

I have Arduino Uno R3 clones.

Please edit your post, and add code tags ("</>" button).

Your post title mentions an Arduino Pro Mini but your text talks about Nanos - very different items. Can you clarify?

I changed the code formatting and replaced "nano" for "pro mini." I'm actually using a pro mini, I just confused the names for a second.

The role is selected by a switch connected to role-pin, not via digitalWrite on the INPUT pin.

Even with a switch, it still doesn't work. Did you see the RX_ADDR_P0-1 part for both arduinos? Does that look correct? Because in the code, the pipes in the array are different. Do the pipes have to do with the RX_ADDR_P0-1 part?

claines:
Even with a switch, it still doesn’t work.

Did you try the tutorial linked in Reply #1

If so post the code from the tutorial as you have uploaded it to YOUR Arduinos.

…R

I did exactly as it’s told in the Bare Minimum example (http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-ExampleSketches#bm1), and I had already ran the GettingStarted example from TMRH20’s RF24 library.

The wiring is done exactly like this. And I also added a 10uF capacitor to VCC and GND as recommended. The modules are about 150cm apart.

1 - GND
2 - VCC 3.3V !!! NOT 5V
3 - CE to Arduino pin 7
4 - CSN to Arduino pin 8
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
8 - UNUSED

The code I have uploaded is the SimpleTransmit in UNO and SimpleReceive in Pro Mini.

SimpleTransmit

/* YourDuinoStarter Example: Simple nRF24L01 Transmit
  - WHAT IT DOES: Transmits simple fixed data with nRF24L01 radio
  - SEE the comments after "//" on each line below
   Start with radios about 4 feet apart.
  - SEE the comments after "//" on each line below
  - CONNECTIONS: nRF24L01 Modules See:
  http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
  Uses the RF24 Library by TMRH2o here:
  https://github.com/TMRh20/RF24
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 7
   4 - CSN to Arduino pin 8
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED

   V1.02 02/06/2016
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
/*-----( Declare Constants and Pin Numbers )-----*/
//None yet
/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
int dataTransmitted;  // Data that will be Transmitted from the transmitter

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24/Simple Transmit data Test"));
  Serial.println(F("Questions: terry@yourduino.com"));
  dataTransmitted = 100; // Arbitrary known data to transmit. Change it to test...
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // 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.
  myRadio.setPALevel(RF24_PA_MIN);
  //  myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power

  myRadio.openWritingPipe( addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  delay(1000);
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  myRadio.write( &dataTransmitted, sizeof(dataTransmitted) ); //  Transmit the data

  Serial.print(F("Data Transmitted = "));
  Serial.print(dataTransmitted);
  Serial.println(F(" No Acknowledge expected"));
  dataTransmitted = dataTransmitted + 1;  // Send different data next time
  delay(500);

}//--(end main loop )---

SimpleReceive

/* YourDuinoStarter Example: Simple nRF24L01 Receive
  - WHAT IT DOES: Receives simple fixed data with nRF24L01 radio
  - SEE the comments after "//" on each line below
   Start with radios about 4 feet apart.
  - SEE the comments after "//" on each line below
  - CONNECTIONS: nRF24L01 Modules See:
  http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
  Uses the RF24 Library by TMRH2o here:
  https://github.com/TMRh20/RF24
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 7
   4 - CSN to Arduino pin 8
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED

   V1.02 02/06/2016
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
/*-----( Declare Constants and Pin Numbers )-----*/
//None yet
/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
int dataReceived;  // Data that will be received from the transmitter

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24/Simple Receive data Test"));
  Serial.println(F("Questions: terry@yourduino.com"));

  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // 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.
  myRadio.setPALevel(RF24_PA_MIN);
  //  myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power

  myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  myRadio.startListening();

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{

  if ( myRadio.available()) // Check for incoming data from transmitter
  {
    while (myRadio.available())  // While there is data ready
    {
      myRadio.read( &dataReceived, sizeof(dataReceived) ); // Get the data payload (You must have defined that already!)
    }
    // DO something with the data, like print it
    Serial.print("Data received = ");
    Serial.println(dataReceived);
  } //END Radio available

}//--(end main loop )---

I don’t know what else I should do. Could this be happening because I’m not using an external power source, and using Arduino’s 3.3V output instead?

I have tried those 2 programs on my Mega and Uno. On the Uno I used pins 9 and 10 because of the way I have the nRF24 connected and on the Mega I used 7 and 8 as in your code.

In both cases the nRF24 is powered from the 3,3v pin and without any capacitor across the power supply. When I built a breadboard version with an Atmega 328 I found that a 10µF capacitor between the nRF24 3v and GND was essential.

I used 9600 baud because my miniterm is setup for that. I can't see the baudrate making any difference.

Everything worked as expected.

I don't have a Pro-Mini - only a Pro-Micro and I have had not trouble with that.

Do you get any output on the Serial Monitor from either program?

...R

Yes, I got output. The sender showed the messages it was sending. The receiver showed nothing but the text it's supposed to show when you initialize.

I don't believe I should be running into problems after trying correctly so many tutorials. Maybe the problem is in the modules. I'll return the modules I bought, and but other ones from another source. I'll post the update in a few days when I get to test the new modules. Thank you for you attention so far.

i know it's a 2 years topic ... google index bring here many new ppl. - answer is : CE to Arduino pin 2
CSN to Arduino pin 3 and will work fine with RF24 radio(2, 3); . Pro Mini has SDA,SCL on pin 2 and 3.