I have been using two nRF24L01 to communicate with each other using a simple Arduino Uno Board. It worked for 5 days and now all of a sudden it is now working. I tried to change the modules and the Arduino boards too, but even if trying a simple example the communication between them is not happening.
I googled everything and tried every option, it is not working.
I used printDetails()
to check the config of the modules. It shows everything is ok but I am not able to understand if the transmitter or the receiver is the problem. Please guide me to solve this problem. Also how to make sure if both are working (any debugging technique)?
I have been trying it for 9 days now, and I badly want it to work.
The code I am using is very simple code. It doesn't have any errors.
Receiver code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
String response;
boolean done = false;
void setup() {
delay(500);
Serial.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(0,0xF0F0F0F0AA);
radio.startListening();
}
void loop() {
if (radio.available()) {
radio.read(&response, sizeof(response));
done = true;
}
if (done) {
Serial.println(response);
}
done = false;
delay(1000);
}
Sender code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
String request;
void setup() {
delay(500);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(0xF0F0F0F0AA);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
while (Serial.available() > 0) {
request = Serial.readString();
Serial.println(request);
radio.write(&request, sizeof(request));
delay(1000);
}
}