nRF24L01 Problems

Hello,
Firstly, I'm sorry if this is in the wrong topic, but this seemed the most appropriate.

I have recently tried to connect 2 Arduino Nanos using the nRF24L01+ boards. These are the ordinary low power versions without the external antenna. I have been following Robin2's tutorial (Simple nRF24L01+ 2.4GHz transceiver demo - Exhibition / Gallery - Arduino Forum) to set this up and I will refer to the first 2 programs in this thread. I had to change the CSN pin from 10 to 8 for the Tx, but that is the only change I've made in the code and hardware.

When I run this I get only failed transmissions from the Tx output and nothing from the Rx output, unless I press down on or tap the Rx nRF24L01 board. If I do that I get a very quick print-outs but the transmitted data is empty.
I've swapped them over (so the Transmitter becomes the receiver and vice versa), changing the pins in the code as necessary. When I do this I get the data printed from Rx every time but the Tx print-out shows that not all the transmissions are occurring correctly despite the data being received and printed. I think this must be an error with the acknowledge bit but I'm at a loss to how the problem is occurring.

I have been at this now for a total of 3 days, and checked the hardware many times thinking this is the likliest root of the problem but despite correcting a few problems have not solved the problem and I am now convinced the hardware is per the diagram in the tutorial. The library is also correct to the tutorial.

The only thing I can really include that would be of any help is a copy of the print-outs. Things like the code and schematics are the same as those in the tutorial. I will add the print-outs in a future post when I can but if there is anything I have missed please tell me, I have been accused of not including of leaving out details or evidence before on these forums. It is not deliberate but what I think is necessary may not necessarily encompass everything that you think is necessary or I may simply have forgotten something.

I am fed up with this now and am on the verge of chucking the whole thing on the bin but it is key to a project so I really want to get it working.
Thank you in advance for your help.

It is probably worth posting a picture of each setup so that the wiring can be seen (and checked) by others - we all make mistakes that we cannot see ourselves and feel stupid when someone points it out, but we feel even more stupid it we tell everyone it is right and eventually someone spots a problem!

Make sure alt the wires between the devices can be seen especially the ends.

For example the Nano is a 5v device (iirc) and the NRF is a 3.3V device - so show how the different voltages are accommodated.

Thanks for the reply.

I was a little annoyed when I wrote that first message. Consequently, although everything in it is correct, there are a few glaring omissions for which I apologize.

  1. I built the circuit on protoboard because breadboards weren't compatible with the nRF24L01 board and I didn't have any suitable wires. The protoboards I used are a bit different to what I'm used to so I'm afraid the wiring is a little bit messy.
  2. I have spare components, so if I have to abandon my current attempt I will attempt it again, when I can face it, and I will buy some suitable dupont hook-up wires for that attempt to avoid soldering. I am now regretting my decision to charge ahead using permanent methods though I only did so because I read several sites saying this was relatively easy.
  3. The transmitter circuit has 2 SPST buttons; an SPST slide switch; and a voltage regulator in the circuit as well as the RC board. The buttons are connected between their pins and ground and should have no affect on anything whether they are declared in code or not (of course, this may not be true in practice). The voltage regulator is a 5V out step-down converter intended for use with a 9V battery to supply the circuit. It is connected to the 5V pin.

Buttons are connected to A6 & A7
Switch is connected to 5.

It now occurs that maybe the voltage regulator is an unwanted draw on the circuit but I would like to know if anyone agrees with that before I proceed with removing wires.
I have done multi-meter tests across the circuits which show the wires are connected where I want them; the switches are connected correctly; and there are no shorts.

I have done nothing about the 5V to 3V3 difference because I read that the board can handle 5V inputs on the pins. Is this correct?

1/2 - Photos on next post.

These are photos of both sides of the boards. The transmitter is the one with the buttons on, the receiver only has the nano and the nRF24L01. The nanos are not connected in the photos but you can see the headers where they connect.
For those who are interested, the RC boards were original connected by headers but these were causing problems so I soldered the boards directly. And the capacitors are 10uF.

The photos are too large to attach to 1 post so I will attach the transmitter photos on a subsequent post.

P.S. forgot to mention in my previous post, I will draw a circuit diagram for the transmitter and post it here when I'm able.

I'm sorry the photos aren't very clear/the circuit is congested but hopefully it's useful.
The receiver photos:

Transmitter photos:

I'm not really that good at following the wiring, but as far as I can see the transmitter is wired as per Robin's post with the change from pi 10 to pin 8 as you said.

Given that physically pressing on the Rx board makes something work - I think you should recheck your soldering in case you have a dry joint or similar poor connection.

For completeness what version of the IDE are you using and what version of the library (post a link if necessary).

Did you post a copy of your code or are you using the code from the Tutorial code ?

If you can post your code I have a couple of nano's set up with the NRF24L01's on there and I can try them on my set up.

I used Robin2's Tutorial and learnt a lot from it and since then I've made a couple of projects using these and had no problems.

Don't give up keep going and you will get there in the end and it will give the most satisfaction when you do get it working.

Try this some sample code you could try, I know it's working as I've tested on my setup and it's working, On the serial port monitor for the TX code I get the X SENDING and counting up and on the RX coce on the Serial port monitor I get RX RECEIVING counting. The library that I have installed is 1.3.7 looking at the Library manager.
My CE_PIN & CSN_PIN is 9 & 10, So you may need to change these to suit your set up.

TX Code:

/*
  Arduino Wireless Communication Tutorial
      Example 1 - Transmitter Code
  Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN   9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN); // CE, CSN
unsigned long previousMillis = 0;        // will store last time LED was updated
// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)
const byte address[6] = "00001";
typedef struct Data_struct {
  int Counting;
} Data_struct;
Data_struct Data;
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    Data.Counting ++;
    Serial.print("TX SENDING:");
    Serial.println(Data.Counting);
  }
  Send_data();
}
void Send_data() {
  radio.write(&Data, sizeof(Data));
}

RX code:

/*
  Arduino Wireless Communication Tutorial
  Example 1 - Receiver Code
   Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

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

#define CE_PIN   9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN); // CE, CSN
const byte address[6] = "00001";
unsigned long previousMillis = 0;        // will store last time LED was updated
// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)
typedef struct Data_struct {
  int Counting;
} Data_struct;
Data_struct Data;
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  recvData();
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    Serial.print("RX  RECEIVING:");
    Serial.println(Data.Counting);
  }
}
void recvData()
{
  while ( radio.available() ) {
    radio.read( &Data, sizeof(Data) ); // Get the data payload (You must have defined that already!)
  }
}

Thanks Steveiboy, I am using the code on the tutorial with the 1.1.7 library downloaded via the library manager option in the IDE.
I will try your code but unfortunately I'm going to have to do some work this week so I may not get around to it immediately, but I will get back here when I have.

I am using the 1.8.13 IDE version.

Thanks

If you can't compile my code use the library that's linked in the code as I'm not sure if there the same should be.
This one below on the RX code detects no in coming data and if signal is lost and lets you know through the serial monitor.
In the TX code to make sure is worked I just added delay(5000);, So when it stops sending the data for 5 seconds the RX code lets you know. You can easily modify it if you wanted buttons pressed. I got some code that I used in a remote controlled scissor lift for fun where I used buttons and joystick for the movements. Had fun in building and making it, Even more fun driving the scissor lift which are not remoted controlled. I t confused some people at work when they seen it driving it on it's own.
I can dig it out an up load it if needed.

./*
  Arduino Wireless Communication Tutorial
  Example 1 - Receiver Code
   Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

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

#define CE_PIN   9
#define CSN_PIN 10
#define Error_led   13// On board led
RF24 radio(CE_PIN, CSN_PIN); // CE, CSN
const byte address[6] = "00001";
unsigned long previousMillis = 0;        // will store last time LED was updated
bool newData = false;
const long interval = 1000;           // interval at which to blink (milliseconds)
const long TX_interval = 250;  //Error flag timer for not recieving from the tx
unsigned long TX_previousMillis = 0; // stores the last mills
unsigned long lastRecvTime = 0; // escape from recieve data
typedef struct Data_struct {
  int Counting;
} Data_struct;
Data_struct Data;
void resetData()
{
  unsigned long TX_Error = millis();
  newData = false;
  if (TX_Error - TX_previousMillis >= TX_interval) {
    TX_previousMillis = TX_Error;
    digitalWrite(Error_led, !digitalRead(Error_led));
  }
}
void setup() {
  Serial.begin(9600);
  pinMode(Error_led, OUTPUT);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  recvData();
  unsigned long now = millis();
  if ( now - lastRecvTime > 1000) { //if data stops coming turn everything off with a second
    lastRecvTime = now;
    Serial.println("NO DATA BEEN RECEIVED:");
    resetData();
  }
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval && newData == true) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    Serial.print("RX  RECEIVING:");
    Serial.println(Data.Counting);
  }
}
void recvData()
{
  while ( radio.available() ) {
    radio.read( &Data, sizeof(Data) ); // Get the data payload (You must have defined that already!)
    lastRecvTime = millis();
    newData = true;
  }
}

In Robin2's tutorial, on the bottom of the second page, is a program to test the wired connection between a rf24 radio module and its processor.

Hello everyone, I finally found 10 minutes to plug everything in and upload the recommended code.

This is what I got from the wiring test program on Robin2's tutorial:
The transmitter circuit:

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

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0


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

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x27
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 250 KBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0

The receiver module:

For the 

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

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0


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

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x27
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 250 KBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0

That all looks perfectly fine to me (if anyone wants to confirm or disagree with that, please do), so I uploaded Steveiboy's code and got this at the output of the receiver:

RX  RECEIVING:3
RX  RECEIVING:4
RX  RECEIVING:5
RX  RECEIVING:6
RX  RECEIVING:7
RX  RECEIVING:8
RX  RECEIVING:9
RX  RECEIVING:10
RX  RECEIVING:11
RX  RECEIVING:12
RX  RECEIVING:13
RX  RECEIVING:14
RX  RECEIVING:15
RX  RECEIVING:16
RX  RECEIVING:17
RX  RECEIVING:18
RX  RECEIVING:19
RX  RECEIVING:20
RX  RECEIVING:21
RX  RECEIVING:22
RX  RECEIVING:23
RX  RECEIVING:24
RX  RECEIVING:25
RX  RECEIVING:26
RX  RECEIVING:27

Ignoring the initial discrepancy as caused by the time difference between the code uploading to the transmitter and receiver and me opening the terminal, this looks perfectly fine to me.

I then uploaded my own code, with no changes except reordering a couple of the radio setup commands and setting the data rate to 250KBPS (I should explain that this is fundamentally the test code from Robin2's tutorial but with a different message and some additional functionality that not being used).
I get this from the receiver:

Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward
Go forward

Which is perfect.

And this from the transmitter:

1	Go forward
0	Go forward
0	Go forward
1	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
0	Go forward
1	Go forward
1	Go forward
0	Go forward
1	Go forward
0	Go forward
0	Go forward
1	Go forward
1	Go forward
1	Go forward
1	Go forward
0	Go forward

Again, any discrepancy in the number of lines can be ignored. As you can see the acknowledge bit is still a bit temperamental, but the I can confirm the data is being received correctly.

Obviously there is still an issue somewhere, but fundamentally it is working. I have no idea why this is, I have changed absolutely nothing in the last few days, but there you are.

Thanks everyone.

Glad you got it working, what’s with the 1 and 0’s in your going forwards, how are you sending the data ?

Are you using a joystick or buttons?

If you add 5 second delay in my tx code and use the last set of code I posted and you will see no signal lost.

Steve

Sorry about the delayed response, I've been distracted lately.

The digit on the extreme left from the transmitter is the return value from radio.write(etc.).
I think I should correct a mistake I made in that post before I go on though. The code I'm now using (my code) is a combination of the code on this thread, Robin2's code and another tutorial which was useful but I can't find anymore (else I'd link it).
The data is being sent as a 4 element char array.

I am using tactile buttons as inputs (a forward and a backward button).

I don't want to add a 5 second delay because this is too long for what I need. I have added a 500ms delay to my code, and this is about as high as I want to go but I'm not necessary sending data at every loop.

I'm sorry I'm only describing my code rather than including it in the post. I haven't really got time to work on this at the moment, and if I include it here for other people to advise/help me, I think I will compromise that. Furthermore, I want to review the code to make improvements to it generally - at the moment it's little more than a proof of concept and for testing aspects of my circuit that are unrelated to this topic.

Thank you all for your help
I'm sure I will return here if I encounter any more problems or need advice

You miss understood me, When I meant add a 5 second delay. This was in my code for testing lost signal has a safe guard. So if you was to lose the signal you can stop anything happening like running away and stuff like that.

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