Pages: [1] 2   Go Down
Author Topic: Two nRF24L01+/Arduino UNOs don't talk to each other  (Read 2680 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/ and the RF24 library. So far it seems that the wires are connected well because I am getting addresses for both nodes :

Code:
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 http://maniacbug.github.io/RF24/GettingStarted_8pde-example.html 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 :

Code:
// 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 smiley
No sleep today If I do not make them work  smiley-grin
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 48
Posts: 2935
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anyone please ?
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have used the nRF24L01 modules in several projects. Try this: http://www.bajdi.com/sending-structs-with-nrf24l01-modules-and-the-rf24-library/
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Logged

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged


the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2927
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Code:
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.
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 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
« Last Edit: July 06, 2013, 01:08:22 pm by oric_dan » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@oric_dan thank you very much !

I've read this thread also : http://forum.arduino.cc/index.php?topic=82906.0

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First arduino with nRF24L01+



Code:
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



Code:
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

Code:
*** 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
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2927
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

with 10cm distance between them :


Code:
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I am trying to test with http://maniacbug.github.io/RF24/pingpair_8pde-example.html example. Do you know how can I send an int instead of an unsigned int  so I can test with numbers ?
Logged

Pages: [1] 2   Go Up
Jump to: