nRF24L01 +Arduino UNO+LED Project- Light off Delays

Greetings,

I am very new at this so please be patient with me.

What I am trying to do:
I am using two Arduino Uno's and two nRF24L01 modules to light up an LED on the rx side when a button on the tx side is pressed. I followed the tutorial that you always post in them forms:

http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

as well as many others including this link, which includes that library that I am using as the tmrh20 library has not worked for me
:

Problems:

My main issue right now is that using the library from the instructables tutorial, I get at least a delay of one second for the LED to turn off after the button has been pressed, which I have no idea why. I have done my research and banged my head against this for over two weeks now. The delay is completely unacceptable for the research purposes that I am trying to use this for, and this does not seem to be a common complaint.

As to why the tmrh20 library is not working, I have no idea. It allows the LED to light up randomly when the button is not pressed and does not turn it off sometimes. Also, I am using the latest version of Arduino IDE (ver 1.8.3).

I also don't think that this is a pin connection issue as I am using the following pin connections as shown in this link:

http://shanes.net/simple-nrf24l01-with-arduino-sketch-and-setup/

The tx code that I am using:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int SW1 = 7;

void setup(void){
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);}

void loop(void){
if (digitalRead(SW1) == HIGH){
msg[0] = 111;
radio.write(msg, 1);}}

The rx code that I am using:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int LED1 = 3;

void setup(void){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(LED1, OUTPUT);}

void loop(void){
if (radio.available()){
bool done = false;
while(!done){
done=radio.read(msg, 1);
Serial.println(msg[0]);
if (msg[0] == 111){/delay(10)/;digitalWrite(LED1, HIGH);}
else {digitalWrite(LED1, LOW);}
/delay(10)/;
}}
else{Serial.println("No radio available");}
;}

which as you can see, I commented out the delays in the code as there are none in the libraries, just to see if that fixed my issue. However, this did not change anything.

The one thing that I have seen other people do is to solder on some 10microF capacitors and the only reason that I have not done this is that I do not think this issue is power related. The people that seem to do it, just do it automatically because it is what others suggest doing.

Do you think I should go ahead and order a soldering iron so that I can place capacitors on my modules or do you agree that this issue is not power related? Also have you seen this issue before and what do you suggest I do?

Thank you!

I don't see any pinMode() in your TX setup. What does your switch circuit consist of?

Thank you for responding!

I am using the set up provided in this link:

The button I am using is connected to pin 7 and Vcc-5V, where pin 7 is (I am assuming) the input into the Arduino. However, I did not ground the button as all I have are two pin connections on the button I am using, not four as in schematic in the link. I do not have a datasheet for the buttons I am using but they are these:

https://www.amazon.com/Frentaly-Round-Momentary-Botton-Switch/dp/B017EFQD6S/ref=sr_1_2?ie=UTF8&qid=1498061965&sr=8-2&keywords=momentary+switch+arduino

Have a look at this Simple nRF24L01+ Tutorial. I have deliberately made the examples simple and (I hope) included all the info necessary to get them working. They do work - I was using one of them today.

I can't figure from your description what data you are actually trying to send.

I suggest you get one of my examples working completely unchanged and only after that extend it to deal with your own requirement. If you can't get my example to work it is much easier to help with code I am very familiar with.

...R

I am trying to send 111 or HIGH when the button is pressed so that the receiver will light up the LED and 'No radio available' when the button is not pressed. I have seen this tutorial before, when I first started this project, and I have worked through it. I was having issues withe the tmrh20 library that you included in the tutorial, which is why I experimented with other libraries. I will try out the example code you have provided in the tutorial and let you know my results by tomorrow, however, I will use the library from the inscrutables tutorial as my issues with the tmrh20 library are still present.

aalselwadi:
however, I will use the library from the inscrutables tutorial as my issues with the tmrh20 library are still present.

My code works with the TMRh20 library and probably does not work with the earlier ManiacBug version.

Unfortunately TMRh20 did not think to give his library a separate name which can cause confusion. I suggest you delete all references to any RF24 library and reinstall the TMRh20 version.

...R

I made sure to delete all of the libraries I had and re-downloaded the TMRh20 Library from the link you provided. I then copy and pasted your SimpleTx and Simple Rx code from the example you provided in your tutorial, as this is basically what I need these modules for. However, one the code was uploaded to the Arduino Unos that I am using I got a message on the serial monitor indicating that 'SimpleRx Starting' and only then the message 'Data received Message 0' on a continuous loop. Do you know what might be the issue causing this?

What output did you get from the other Arduino?

What Arduinos are you using?

Please post the code that YOU have uploaded to your Arduinos.

Have you put 10µF capacitors across Vcc and GND for the nRF24s?

Have you treble-checked all your connections?

Sometimes it helps to power down the Arduinos and then restart them to make sure the nRF24 resets.

Have you a 3rd nRF24 that you could use to determine if one of the others is faulty?

...R

What does the other Arduino show?

The Tx Arduino serial monitor was outputting 'Data Sent Message 0 Tx failed'. I have attached a photo displaying both serial monitors side by side so you can see for yourself. However, I found that some times I re-upload the programs I will get some confirmation of data received but it's not reliable as then some of the next transmissions will fail. I have attached a photo of the serial monitors showing this behavior as well.

What Arduinos are you using?

I am using two Arduino Unos, however, they are knock-offs as I bought them from Kuman. I have used them for other projects, and they seem fine.

Please post the code that YOU have uploaded to your Arduinos.

Right now I am using your example as you've suggested.
For the Tx Arduino I am using SimpleTx and for the Rx Arduino I am using SimpleRx (see attachments).

Have you put 10µF capacitors across Vcc and GND for the nRF24s?

No, I asked before if I should do this as many people seem to do so, however, I have not done so as I was not sure it was a power issue.

Have you treble-checked all your connections?

Yes I have checked my connections and I check them every time, they are as follows:
GND-GND (I am using the one below 5V)
VCC-3.3V
CE-PIN 9
CSN-PIN 10
SCK-PIN 13
MOSI-PIN 11
MISO-PIN 12

Sometimes it helps to power down the Arduinos and then restart them to make sure the nRF24 resets.

I have seen this suggestion before, so I do this every time before I upload the programs.

Have you a 3rd nRF24 that you could use to determine if one of the others is faulty?

I have several nRF24's and I have changed them before, which did not change the behavior. Since you asked, I changed them to brand new one that I never used before, and it worked for the example (See successful attach) but not for my issue with the project I want to use this for (the code for which are attachments tx and rx).

Can you help me figure out what is causing my issues here? Using the tx and rx code and TMRh20 library, when the button is pushed the LED is always on and never turns off.

SimpleTx.ino (1.48 KB)

SimpleRx.ino (927 Bytes)

tx.ino (315 Bytes)

rx.ino (645 Bytes)

Images from Reply #8 so we don't have to download them. See this Image Guide

...R

As you can see those pictures are unreadable. Please just copy and paste the output as text.

Sometimes it helps to power down the Arduinos and then restart them to make sure the nRF24 resets.

I have seen this suggestion before, so I do this every time before I upload the programs.

I meant you to do it AFTER you have uploaded the programs.

Since you asked, I changed them to brand new one that I never used before, and it worked for the example

Does this mean that you are able to get my example working properly with those nRF24s?

If so, mark them carefully so you can recognize them and using one of the good ones test all the others. Discard any that don't work.

If this was my project I would evolve from the working programs towards the behaviour that I require. Debugging wireless can be very difficult.

...R

As you can see those pictures are unreadable. Please just copy and paste the output as text.

I can not get it by copy/paste from the serial monitor, which is why I took the screenshot sorry, but you can see them if you download the images.

I meant you to do it AFTER you have uploaded the programs.

I am not using EEPROM, wouldn't powering off the Arduinos after uploading the programs erase the program off of its memory?

Does this mean that you are able to get my example working properly with those nRF24s?

Yes, I have and I have placed the corrupt nRF24s in the trash and the working ones in a clearly marked bag.

If this was my project I would evolve from the working programs towards the behaviour that I require. Debugging wireless can be very difficult.

Yes, I have tried this. The code which I am using for the project (tx and rx) are specifically for the purpose which I am trying to use the modules for. My issue now is that I don't think the TMRh20 library works with this code, despite the fact that I have seen others implement this same project using this library and the tx and rx code. I actually had to adjust the rx code that I attached in post #8 as I was getting a void error with the original code because of the TMRh20 library (I am not sure why but I never had to change the code when I used other libraries). The adjustments I made are displayed in post #12 of this discussion:

https://forum.arduino.cc/index.php?topic=302380.0

I suspect this change might be what is making the LED constantly on, what do you think?

aalselwadi:
I can not get it by copy/paste from the serial monitor,

Very strange. I just copied the following from my SerialMonitor

SimSimpleRxAckPayload Starting
SimpleRxAckPayload Starting
SimpleRxAckPayload Starting

I meant you to do it AFTER you have uploaded the programs.

I am not using EEPROM, wouldn't powering off the Arduinos after uploading the programs erase the program off of its memory?

Of course not. The program stays there indefinitely until you upload another program.

Does this mean that you are able to get my example working properly with those nRF24s?

Yes, I have and I have placed the corrupt nRF24s in the trash and the working ones in a clearly marked bag.

Good news. I would not assume that all the others are faulty without testing each of them

If this was my project I would evolve from the working programs towards the behaviour that I require. Debugging wireless can be very difficult.

Yes, I have tried this. The code which I am using for the project (tx and rx) are specifically for the purpose which I am trying to use the modules for. My issue now is that I don't think the TMRh20 library works with this code,

Post the latest version of your code.

...R

This is the latest version of the code:

tx.ino (315 Bytes)

rx.ino (638 Bytes)

aalselwadi:
This is the latest version of the code:

Neither of those programs looks like they were evolved from my working example.

Chuck those programs in the trash along with the failed nRF24s and start again using the working code as a basis.

...R

Robin2,

These codes seem to be universal for this project as I have seen no other variations. People claim that it works for them and all the variations of the RF24 libraries, including the TMRh20 library. Why should I throw them out? I am just trying to get rid of the delays I see when I use the programs, however, as I have mentioned they do not work with the TMRh20 library for me. This project needs to be completed as soon as possible as the focus of my data collection in my research depends on it, so I can keep spending days trying to troubleshoot this.

I mean I cannot keep wasting time trying to troubleshoot this. My only issue with trying to write new code for all this is the lack of variation I have found in the code regarding this project and the fact that I am not a programmer, the best I can do is just try to throw things in there and hope it works, which is inefficient. Have you seen anyone else have a similar problem like mine? How can you be sure that it is the programs that do not work when it appears to me that the library might be the issue?

Did you install capacitors in the meantime?

Some setups even need a seperate power supply to work.

No I have not, the modules worked running Robin2's example code. Do you think that adding them on will get rid of the delay?

Adding the capacitors often make the difference between sometimes working/partly working and functional.
As I already mentioned, some configurations even need a seperate power supply to work.
From my experience 10% of the setups work without additional capacitors.

Bad power supply (peek current / low capacitance / low induction power rails) is the number two reason for failure.
Number one is bad wiring.