nRF24L01 help

So Im new here and still learning arduino and i have this problem with my nrf24L01 with adpter board where the transmitter wont transmit the data if i dont add Serial.println on the transmitter void loop. I was testing if the values from the potentiometer connected in the transmitter will be sent to the receiver and to the serial monitor. Is there something wrong with the code?. Thank you

Transmiter code

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

RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";

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

void loop() {
  int pot = analogRead(A0);
  radio.write(&pot, sizeof(pot));
  Serial.println (pot);
}

Receiver code

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

RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    int pot;
    radio.read(&pot, sizeof(pot));
    Serial.println(pot);
  } 
}

Your sender code is in a very tight loop. The serial.println might be causing just enough delay that it is not overwhelming the transmitter or receiver. Do you really need to send that packet as fast and as frequently as you are?

What do you mean by very tight loop? sorry im still learning

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

I forgot to say that the nRF24 works fine when I used it for my rc car and it’s working well but then after a while it stopped working, so i tried to upload a simple program which is on the post and i found out that it’s not transmitting any data

This loop is running full-out as fast as it can. I am suspecting that this could be the cause. you indicate that when you add the Serial.println the program works. I am suspecting that this is the cause of your issue. The Serial.println is changing the timing enough that it works.

So for a simple experiment, you should not leave the code this way, take the Serial.println out and add delay(5).

I suspect that the code will work better, however now it will be blocking.

void loop() {
  int pot = analogRead(A0);
  radio.write(&pot, sizeof(pot));
  Serial.println (pot);
}

Tope00:
I forgot to say that the nRF24 works fine when I used it for my rc car and it’s working well but then after a while it stopped working, so i tried to upload a simple program which is on the post and i found out that it’s not transmitting any data

Try putting delay(200); into loop() in your Tx program.

...R

adding delays did not work. Whatever value i put in the Tx serial.print will be printed in the Rx serial monitor and i also noticed that when i add the Serial.print in the transmitter ,the Tx led blinks and it doesn't blinks anymore if i remove the serial.print

Tope00:
adding delays did not work.

Post the version of your programs that tries that and also post a sample of the output from the two programs.

...R

Robin2:
Post the version of your programs that tries that and also post a sample of the output from the two programs.

...R

there’s no output even if i add the delay. There’s nothing being printed at the rx serial monitor

Tope00:
there’s no output even if i add the delay.

If you refuse to post your pair of programs I'm not able to help.

...R

Robin2:
If you refuse to post your pair of programs I’m not able to help.

…R

sorry i wasn’t able to send the program earlier coz im not at home but here it is

TX program

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

RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";

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

void loop() {
  int pot = analogRead(A0);
  radio.write(&pot, sizeof(pot));
  delay (200);
}

RX Program

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

RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    int pot;
    radio.read(&pot, sizeof(pot));
    Serial.println (pot);
  } 
}

Ive tried to check the connection between the arduino and the nRF24L01 and this is the result

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN

The pair of programs in Reply #11 work fine on my two genuine Unos.

Your connection test suggests that there is a faulty connection between your Uno and the nRF24 it is attached to.

...R

Robin2:
Your connection test suggests that there is a faulty connection between your Uno and the nRF24 it is attached to.

...R

How could i fix it?

Also, try setting

radio.setPALevel(RF24_PA_MIN);

to

radio.setPALevel(RF24_PA_MAX);

Steve

Still doesn't work

Tope00:
How could i fix it?

As I don't know what the problem is I can't give advice.

Disconnect EVERYTHING and then reconnect things one by one sticking closely to the instructions.

Then if it still does not work draw a simple pencil diagram showing how YOU have everything connected and post a photo of the drawing. See this Simple Image Guide

If everything is connected correctly there is still the possibility of a loose connection or a broken wire.

And it is quite pointless trying anything else if the connection test program will not work.

...R

Robin2:
As I don't know what the problem is I can't give advice.

Disconnect EVERYTHING and then reconnect things one by one sticking closely to the instructions.

Then if it still does not work draw a simple pencil diagram showing how YOU have everything connected and post a photo of the drawing. See this Simple Image Guide

If everything is connected correctly there is still the possibility of a loose connection or a broken wire.

And it is quite pointless trying anything else if the connection test program will not work.

...R

is there any chance that my nrf24 is actually broken or damaged?

While it is possible that the device is damaged, it is more probable that the issue is related to bad wiring.

What I did not see mentioned, is what voltage are you providing, and where is this voltage coming from?