Having a strange issue with nRF24l01 and nano

Been working on getting a nano to talk via the nRF24 and been coming across a strange issue. After some searching, I thought I would ask here as I have not seen a solution to my exact problem.

If, I upload my sketch with no radio commands, IE: radio.write or radio.read, the nano works fine. It reports and Serial prints the state of the buttons and runs loop after loop.

As soon as I put in a radio command, it starts 1 loop and as soon as it gets to the radio command it locks up. It may run 1 full loop, but never more than 2... unless... I touch the D12 MISO pin. Then it will run several loops and fail again. I touch the pin, and it takes off for 20 or so more loops.

It will do this with or with out the radio wired to the nano. I have 4 nanos, and all behave the same.

Could a capacitor across 3.3V and Gnd solve my problem?

Here is my sketch incase I am missing something... very possible.

#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio (9, 10); // CE, CSN

const byte address[6] = "00001";

String ident = "Radio 1";

int testButton (4);
int testButtonstate;

int resetButton (5);
int resetButtonstate;

int ledRe (7);

int runCounter;

void setup() {

pinMode (testButton, INPUT);
pinMode (resetButton, INPUT);
pinMode (ledRe, OUTPUT);

Serial.begin(9600);
Serial.println("Ready");

radio.begin();
radio.openWritingPipe (address);//00001
radio.setPALevel (RF24_PA_MIN);
radio.stopListening();
Serial.println("Radio Ready");

}

void loop() {

runCounter++;
Serial.println(runCounter);

testButtonstate = digitalRead(testButton);
resetButtonstate = digitalRead(resetButton);

Serial.print("Test "); Serial.println(testButtonstate);
Serial.print("Reset "); Serial.println(resetButtonstate);

//Radio sending

radio.write(&ident, sizeof(ident));
delay(10);
Serial.print("Ident Sent......");

radio.write(&resetButtonstate, sizeof(resetButtonstate));
delay(10);
Serial.println("Reset Sent.....");

}

Nebnorse:
Could a capacitor across 3.3V and Gnd solve my problem?

Possibly, what happened when you tried it ?

Have a look at this Simple nRF24L01+ Tutorial

You may need a separate power supply for the nRF24 - I don't know if the Nano can provide enough current from its 3.3v pin. You could try powering the nRF24 with a pair of AA alkaline cells (3v). Make sure the battery GND is connected to the nano GND. And, yes, use a 10µF capacitor - it can't do any harm.

...R

srnet:
Possibly, what happened when you tried it ?

Got the Caps in yesterday and tried it this morning. No change.

Could the radios be bad? I did get them second hand and who knows what was done to them... but I then wonder why the loop fails to run when the nano is not even plugged into the bread board.

When I upload the sketch to my Elegoo Uno with no radio, it just runs and runs. If I plug a radio into into the Uno, it does run... but slows way, way down... to slow. Like it takes 3 seconds to run a loop when it should only take 1/2 a second.

The things I run into. :slight_smile:

Robin2:
Have a look at this Simple nRF24L01+ Tutorial

You may need a separate power supply for the nRF24 - I don't know if the Nano can provide enough current from its 3.3v pin. You could try powering the nRF24 with a pair of AA alkaline cells (3v). Make sure the battery GND is connected to the nano GND. And, yes, use a 10µF capacitor - it can't do any harm.

...R

Yep, same result. Running a PS board putting 3.3v out on one side, 5v on the other side and the Nano getting power from USB.

I put a 10uf cap across 3.3v + and Gnd. Same results... though I did get it to run 3 loops. :slight_smile:

Nebnorse:
Could the radios be bad?

Sure, I had a lot of failures on some cheap ones I bought on eBay.

Nebnorse:
Could the radios be bad? I did get them second hand and who knows what was done to them... but I then wonder why the loop fails to run when the nano is not even plugged into the bread board.

If you try the code in the first example in my Tutorial link completely unchanged I will be better able to help.

...R

Ok. I surrender.

Last night I was hooking it all back up to try Robin2's Tutorial and thought, "Lets try this one more time."

Wouldn't you know, it all started working. So then I decided to let it run until it failed. 20 loops, 40 loops. Before I went to bed last night it was working in the 4,000 loop range and this morning it is still running. Ran to loop 32767 then started with over with -32768 and is now on loop 682 again.

Robin, I have downloaded you Tutorial and if it acts up again, it will be the first thing i run.

This leads me to another question though. What Nrf24 radios is everyone using? Looking on Amazon, there seems to be quite a few to chose from.

I am told these are Kuman nRF24L01+PA+LNA from Amazon and they look like it.

Nebnorse:
What Nrf24 radios is everyone using? Looking on Amazon, there seems to be quite a few to chose from.

Without links to your alternatives I can't comment.

AFAIK there are two basic variants of the nRF24L01+ module. The low-power versions have PCB antennas and the high-power versions have external antennas. I have only used the low-power version. I believe they are identical as far as software is concerned.

...R

but never more than 2... unless... I touch the D12 MISO pin.

Sounds like you have a wiring problem.

So, it was working. I relaxed a few days, and now they are not working. If I swap the MOSI and the MISO, the sketch runs but as far as I can tell the data is never sent. Also, the guy I got the radios from did admit that he accidentally plugged them in to 5v and not 3.3v I am guessing this maybe a big part of my problem.

I really think the radios are bad. The Nanos work fine for everything else.

I am looking at getting Amazon.com

and

to see if this helps me.

My new question is there a simpler, "easier" and more reliable form of 2 way communication?

Being new, it seems to me the NRF24L01 should be easy and straight forward.

Thank you to everyone!

Nebnorse:
So, it was working. I relaxed a few days, and now they are not working. If I swap the MOSI and the MISO, the sketch runs but as far as I can tell the data is never sent.

That is hardly surprising :slight_smile: Why on earth would you think that connecting it the wrong way would help.

Have you tried the program in Reply #29 in my tutorial to verify that the Arduino can communicate with the nRF24 it is attached to?

Have you got 10µF capacitors across Vcc and GND for the nRF24?

My new question is there a simpler, "easier" and more reliable form of 2 way communication?

Being new, it seems to me the NRF24L01 should be easy and straight forward.

My only experience is with the nRF24 and I have found it very reliable. I did have one faulty device out of about 20. Have you a spare one that you can use to check the others?

...R

Robin2:
That is hardly surprising :slight_smile: Why on earth would you think that connecting it the wrong way would help.

Have you tried the program in Reply #29 in my tutorial to verify that the Arduino can communicate with the nRF24 it is attached to?

Have you got 10µF capacitors across Vcc and GND for the nRF24?

My only experience is with the nRF24 and I have found it very reliable. I did have one faulty device out of about 20. Have you a spare one that you can use to check the others?

...R

Yep. With radio wired:

"Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino
SimpleTxAckPayload Starting"

With radio unplugged:

"Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino
SimpleTxAckPayload Starting
Data Sent Message 0 Acknowledge but no data
Data Sent Message 1 Acknowledge but no data
Data Sent Message 2 Tx failed
Data Sent Message 2 Tx failed
Data Sent Message 2 Tx failed
Data Sent Message 2 Acknowledge but no data
Data Sent Message 3 Acknowledge but no data
Data Sent Message 4 Acknowledge but no data
Data Sent Message 5 Acknowledge but no data
Data Sent Message 6 Acknowledge data 0, 0

Data Sent Message 7 Acknowledge data 0, 0"

ect...

Robin2:
That is hardly surprising :slight_smile: Why on earth would you think that connecting it the wrong way would help.

There comes a point in frustration where madness takes over... not saying I got to that point, but it was close.

Seriously though. I thought maybe that the radio pins were mislabeled or that I was reading the nano pin out wrong and that I was wiring them incorrectly inadvertently.

Nebnorse:

Have you tried the program in Reply #29 in my tutorial to verify that the Arduino can communicate with the nRF24 it is attached to?

Yep. With radio wired:

"Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino
SimpleTxAckPayload Starting"

That output has nothing to do with the piece of my text that you quoted. Have you tried the program in Reply #29?

There comes a point in frustration where madness takes over...

I understand. But, based on lllooooonnng experience I can say that it does no good. :slight_smile:

...R

Sorry, I missed the Reply #29 a few posts back.

I ran the connection test and no communication between the 2.

Below is some pics of the wiring.

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



Photos of the hardware are not suitable for figuring out wiring problems. You need to make a simple pencil drawing with everything clearly labeled and post a photo of the drawing. Often the business of making the drawing shows up the problem.

...R

Hey Robin, I just want to take a second and say thank you for helping me with this. Your input and tutorials have been soooo much more help than I could have ever expected. THANK YOU! ;D

Using your pin address sketch, I ran all 3 radios and the 3 new radios.

4 of the 6 reported addresses. 2 of the old ones did not report anything.

Thank you for this sketch, I will be sure to use it again and again. :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: