Hello everyone,
I am a beginner with the Arduino. I tried to create a communication between two Arduino Nanos.
I connected my antennas to the two arduinos using the following pins.
Problem:
I don't know if I did anything wrong in the code, but when I run it the transceiver tells me that "connection to receiver is available" and "message was not sent".
I hope you can help me. Thanks
transceiver:
RF24 radio(7,8);
const byte address[6] = "00001";
void setup(){
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.stopListening();
}
void loop(){
if (radio.available()) {
Serial.println("Connecting to receiver is available");
}
const char text[] = "Hello World";
if (radio.write(&text, sizeof(text))) {
Serial.println("Message was sent: ");
Serial.print(text);
} else {
Serial.println("Message was not sent");
}
delay(2000);
}
receiver:
RF24 radio(7,8);
const byte address[6] = "00001";
void setup(){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.startListening();
}
void loop(){
if (radio.available()) {
Serial.println("Connection to transceiver is available");
char receivedText[32] = "";
radio.read(&receivedText, sizeof(receivedText));
Serial.println("Message was received: ");
Serial.print(receivedText);
} else {
Serial.println("Connection to transceiver is not available");
}
}
I hope I have given you all the important information.
The tutorial covers the problems with supplying enough current to the modules. Failure to supply sufficient current is one of the most often problems. I use homemade versions of this adapter on my radios and have no problems with power,
If you are using the higher powered radios (external antennae) they may not communicate if they are too close together. Move them a few meters apart.
The radios do not reset with the Arduino when uploading code. Cycle power to the radios to reset them. after uploading new code to the Arduino.
Thank you both for your quick replies.
I looked at the Robin2 tutorial and tried the code for the one-way transmission and the two-way transmission. In both cases my message was not sent.
I also tried to separate the antennas further. Was a little over a meter.
Do you have any more ideas what I can do?
Here is the package I bought.
Is this maybe because I do not reset correctly? How do I do reset correctly?
You are right and I am stupid. I should have seen that. I have now connected the 5V.
I already swapped the pins for CE and CSN when I saw Robin's tutorial.
I achieved partial success. Now my message is sometimes transmitted. The message is now transmitted very irregularly. Normally it should arrive every 2 seconds, but sometimes it takes 10 seconds or less or more.
Thank you in advance for your answers. You helped me a lot. I've tried so much and it was just because of the great tension. It's very depressing.
Do you have an idea how I can make the transmission constant every 2 seconds?
This is likely to be because you are transmitting exactly the same message and it may be wrongly recognised as a re-transmission and, therefore, dropped. I believe some clone NRF24L01 devices behave strangely under these circumstances.
Hello guys,
I tried a little more. The problem seems to have been that the antennas were still too close to each other. So I put them even further apart.
Now everything works fine.
I would like to thank everyone again, I couldn't go into all of the answers. Thanks