Receiver:
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 8); // CE, CSN
const byte address[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setRetries(0,0);
radio.setChannel(5);
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(0, address);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
Transmiter:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 6); // CE, CSN RF24 radio(9, 8);
const byte address[6] = "00001";
void setup()
{
radio.begin();
radio.setRetries(0,0);
radio.setChannel(5);
radio.setPALevel(RF24_PA_MIN);
radio.openWritingPipe(address);
radio.stopListening();
const char text2[] = "Hello World";
radio.write(&text2, sizeof(text2));
}
void loop()
{
}
I turn on the receiver, then turn on the transmitter and the receiver receives. I turn off the transmitter and after a while I turn it on again. The receiver is no longer receive. From now on, no matter how many times I turn the transmitter on and off, the receiver does not receive data. If I turn the receiver off and on, it receives data once when the transmitter is turned on.
If I send twice:
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
const char text2[] = "Hello World";
radio.write(&text2, sizeof(text2));
the second send is always received by the receiver, but this option does not suit me. Different configuration of the "radio.setRetries (0,0);" function; does not affect.