nRF24L01 not communicating

Hi forum!
Before I start, I want to apologize if this post is unspecific or hard to read. It's my first post on the forum :).
I'm having a problem using the nRF24L01 module. In my project, I will be sending mapped coordinates over the nRF that will then be put into an sg90 servo. I am using two Arduino Unos. Before I start sending the coordinates over the nRF, wanted to test if the modules were working. I tested both of the nRFs using the radio.isChipConnected() function, and both are connected to the Arduinos. When I run the same test using the radio.available() function, the two modules do not seem to be connected to each other. I have tried using 10uf and 100uf capacitors, but it does not change the outcome.
Here is the code that I am using for the radio.available() test:

**TRANSMITTER**
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7,8);

const byte address[] = "00002";

void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_LOW);
radio.stopListening();
}

void loop() {
  if(radio.available()== true) {
    Serial.write("NRF24L01 is connected");
    }
     if(radio.available()== false) {
    Serial.write("NRF24L01 is not connected");
    }
}
**RECEIVER**
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int input1 = 0;
RF24 radio(7,8);

const byte address[] = "00002";

void setup() {
Serial.begin(9600);

radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_LOW);
radio.startListening();
}

void loop() {
  if(radio.available()== true) {
    Serial.write("NRF24L01 is connected");
    }
     if(radio.available()== false) {
    Serial.write("NRF24L01 is not connected");
    }
}

If anyone has any tips/advice on this topic, I would really appreciate it.
Thanks!

This is probably not what you want. You tested if radio.available() == TRUE and if it is TRUE you then test if it is FALSE, which it will never be because you already determined that it is TRUE.

I haven't used this exact library, but usually, available is only true if something has been received into the buffer. As you are only writing to the Serial (sending something to the other side) if the other side has already sent something to you, neither the transmitter nor receiver is ever sending anything and so available will never be true anywhere (except maybe at the very beginning if some trash characters are in the buffer which often occurs). In short, available is not true because the other side "is available", it will only be true if the other side has actually sent something. Available speaks to incoming characters, not the port itself.

Your transmitter does not transmit,
but tries to misinterpret the availability of a received packet as a sign for a nonexistent connection.

Ok, thank you!
As i understand, i would have to test if the radio is available by actually sending something. I'll try to send a message and put it in the serial monitor.
Again, thank you so much!

Things that I found while getting my radios to work:

If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. Run the CheckConnection.ino (look in reply #30) to verify the physical wiring between the radio module and its processor (Arduino).

Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.

If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings.

Reset the radios by cycling power to them after uploading new code. I have found that to help. They do not reset with the Arduino.

Switch to 1MB data rate to catch the not so cloned clones.

'radio.setDataRate( RF24_1MBPS );'

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.