Issue with nRF24L01+

Hi Folks,

I’m trying to establish comm between 2 Nano, using some nRF24L01+

I found this example:

http://starter-kit.nettigo.eu/2014/connecting-and-programming-nrf24l01-with-arduino-and-other-boards/

it works …and does not work. When I start it, nothing happens…serial monitor is enabled, but nothing seems to make it to the receiver…until minutes later, then one message will make it thru …

a few minute later, another will make it …

I have added a Push-Button and an LED to decide when to initiate comm and make sure my code was activated, but no luck…

here is the code in place:

Transmitter

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

RF24 radio(9, 10); // CE & CSN

const byte rxAddr[6] = "00001";

void setup()
{
  pinMode(8, OUTPUT);
  pinMode(A0, INPUT);
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  if (digitalRead(A0) == HIGH)
  {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  while (digitalRead(A0) == HIGH)
    {
          digitalWrite(8, HIGH);
    }
  }
  //delay(1000);
  digitalWrite(8, LOW);
}

Receiver

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

RF24 radio(9, 10); // CE & CSN

const byte rxAddr[6] = "00001";

void setup()
{
  while (!Serial);
  Serial.begin(9600);
  
  radio.begin();
  radio.openReadingPipe(0, rxAddr);
  
  radio.startListening();
}

void loop()
{
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    
    Serial.println(text);
  }
}

push button is connected to A0 (14) and LED to pin 6. the push-button and LED works fine.

any ideas ?

Your description of seemingly random times before sends makes me think you have a floating input being used to make a decision on. How is the push button wired? I would do this, in setup(): pinMode(A0, INPUT_PULLUP); // A0, wire with switch that connects to Gnd when pressed

in loop(): if (digitalRead(A0) == LOW){ // button/switch pressed?

CrossRoad:

The behaviour was when the original code (from the provided link) was in place. the code was :

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

RF24 radio(7, 8);

const byte rxAddr[6] = "00001";

void setup()
{
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();
}

void loop()
{
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  
  delay(1000);
}

As you can see it is “time-based” only. I was expecting transmission to occur every second, but for whatever reason, it’s not the case

Right now, with the modification that send only (in theory) when the button is pressed, nothing is happening “nRF24L01-wise”…

My PB has a 10K to ground, and is connected to +5v

Hi,

Go back to the site you linked and read the comments below the article. You may have some interference blocking the reciever.

Tom....... :)

I have only done a little (successful) testing with my NRF24s.

I can't remember what is the default for retries, but my TX code (which works) does not have this line radio.setRetries(15, 15);

What happens if you comment it out ?

Actually my TX code does not have any delay() either - but I can't see that causing a problem.

...R