Help with NRF24l01

Hello,

so i have been working on a project that is radio controlled for that i am using the NRF24l01 modules for the transmitter i have the one with antenna and the reveiver has the one without the antenna.
but right now the receiving end isn't working (so i think) because the TX led on my transmitter is blinking so i assume it is transmiting. but when i move a joystick nothing happens and that the same for the other 3 joysticks. the thing that is supposed to happen is that a servo needs to start moving.

here are some specs:
-transmitter:
-arduino nano
-4 joysticks
-power by 3 li-ion battery's with a doide for 12v or less
-2 leds attached

  • 3.3v used for NRF24l01 (with antenna)

receiver:

  • arduino mega
  • pins are correct ( i know that different arduino's have different miso, mosi etc. pins)
  • 12v power
  • servo pins are 2-5
  • 3.3v pin used for NRF24l01 (no antenna)
  • there are more things attached to it but i temporairly unplugged the other 3.3 volts

here are the codes:

transmitter:

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

RF24 radio(6, 7);
const byte direccion[5] = "00001";
 
void setup() {

  radio.begin();
  Serial.begin(9600);
   radio.openWritingPipe(direccion);
   radio.setPALevel(RF24_PA_MIN);
   radio.stopListening();
}
 
void loop() {
  
  int lecturaADC = analogRead(A2);
  int angle = map(lecturaADC,0, 1023, 0,180);
  Serial.println(angle);
  radio.write(&angle, sizeof(angle));
  delay(50); 
  
}

receiver:

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

RF24 radio(48, 49);
const byte direccion[5] = "00001";

Servo myservo;
int angle =90;

void setup()
{
  Serial.begin(9600);
  myservo.attach(4);
  radio.begin();
  radio.openReadingPipe(0, direccion);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
 
void loop() {
  if (radio.available()){
      radio.read(&angle, sizeof(angle));
      Serial.println(angle);
      myservo.write(angle);
      
  }
 
}

i have tested if the servo's work and they work.
i hope this is enough information.

As a first suggestion, put all your Tx and Rx code to one side for the moment.

Have a read of the excellent nRF24L01 tutorial here:

Read the first post to see how the module is wired up.

Then scroll down to post #30 and run the checkconnection sketch on your Tx setup and Rx setup. Post the results of those test here - you can copy and paste the IDE Serial Monitor output (not a screenshot please!) - if you are unsure if the connection check is working correctly.

Then go back to post #2 and try the SimpleTx and SimpleRx sketches.

Report back here how you get on.

Thank you, i will try that and be back with te information within 48hrs i hope.

here i am with some data!

it is not the data i thought i was gonna give but it is stil very usefull.

so i read the entire thread didin't understand all of it but i think i understood enough, and i also read another small thread of 15 posts.

so i added a 10 mirco farad capacitor to my transmitter ( i haven't done it to the receiver yet because it is tucked away so i isnt easy to reach with a soldering iron).
and what i did after that is i added

pinMode(10, OUTPUT);

to the void setup () { of both codes.
then i uploaded the codes and of course nothing visually happend, but what i did get was some usefull digital information. i check the serial of the receiver and it said:
0
0
0
etc.

so that means it works and when i checked the transmitter it said:
89
89
89
89
180 ( i moved the joystick up)
0 (i moved the joystick down)

so the arduino are now reading the data but not propperly transmitting or receiving.

that is it for now, i will try to add the capacitor for the receiver and see what difference that makes.

added the capacitor for the receiver still nothting happens (as expected).

so i though!
i just checked the serial for the receiver and i saw this:
it doesn't seem to be affected by the transmitter.

don't really know what to do with such high and low numbers

Note: this only seems to be happening when i only plug in the USB. when i add the battery (that will be powering it eventually). it disappears.
so i think it is just a glitch or sum

What was the outcome when you followed these steps I suggested?

i may or may not have forgotten those steps, i am currently busy but i will try those steps as soon as possible.

Hi,
Can you please post circuit diagrams of your Tx and Rx ends?
A copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, component names and pin labels.

Can you please post some images of your project so we can see your component layout?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

sure!
i think i will upload it somewhere around this evening (19.00 London time).

Hi,
No problem, its now 9:42am UTC today, or 20:24 AEDT today here.

Tom.. :smiley: :+1: :coffee: :australia:

just a quick side quest,
so my friend just introduced me to chat.openai.com. and i asked it to make a C++ transmitter code with 1 joystick using the NRF24l01 module where the csn and ce pins are 48 and 49 on the arduio MEGA.
and it came with this:

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

const uint64_t pipe = 0xE8E8F0F0E1LL; // Set the transmit pipe
const int csnPin = 48; // Set the CSN pin
const int cePin = 49; // Set the CE pin

RF24 radio(cePin, csnPin); // Create an RF24 object

void setup() {
  radio.begin(); // Initialize the radio
  radio.openWritingPipe(pipe); // Open the transmit pipe
  radio.setPALevel(RF24_PA_MAX); // Set the power level
  radio.stopListening(); // Stop listening
}

void loop() {
  int joystickX = // read the X axis of the joystick
  int joystickY = // read the Y axis of the joystick

  // Create a struct to hold the joystick data
  struct joystickData {
    int x;
    int y;
  };

  joystickData data; // Create a joystickData object
  data.x = joystickX; // Set the X axis data
  data.y = joystickY; // Set the Y axis data

  radio.write(&data, sizeof(data)); // Transmit the joystick data
}

this is correct right?

If you are having problems, then the forum users that have experience of the nRF24L01 modules are very likely to ask you to take a look at Robins tutorials first (see the link I gave you back in post #2).

You are less likely to get assistance if you've not done so.

here are the result form post #30

receiver(arduino mega):

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		= 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	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0


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

SPI Speedz	= 10 Mhz
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	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0

transmitter (arduino nano):

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		= 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	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0


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

SPI Speedz	= 10 Mhz
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	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0

now for the SimpleTx and SimpleRx sketches.

the arduino mega serial(receiver) goes like this:

data received
data received
data received
data received
data received
data received
data received
data received
data received
data received
data received
data received ```
etc. 

so i think thats a good sign

the scematics and photos will follow in a couple hours i hope

Unfortunately not. If you read the text at the top of the CheckConnection serial output, it says:

You have a lot of zeros which suggests that your connections to the radio module are not right. Recheck your connections

okay, i will recheck my connections but i already checked my connections on my arduino mega like 5 times before that and i did see a problem everything was wired like it supposed to. is used these connections out of a video:

and from what is see all the MOSI, MISO, and SCK pins are correct and the CSN and CE pins are diffrent but that doesnt matter because i read that you can plug them in any digital. as long as you set pin 10 as an output.

(so, it just came to mind that i maybe should've changed the CSN and CE pin in the codes. i will do that tommorow and then i will be back with te correct data) sorry,,

second try:

transmitter:

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

first i had the radio pins at 6, 7 (it gave the same results 0's) switched them and now it gives other numbers!

receiver:

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

same goes for the receiver first had the radio pins on 48, 49 (didn't work) switched them to 49, 48 and it worked. ( i think).

now for the other test:

for this one i had to switch 6 and 7 again in the code and then it gave this:

SimpleTx Starting
Data Sent Message 0  Tx failed
Data Sent Message 0  Acknowledge received
Data Sent Message 1  Tx failed
Data Sent Message 1  Acknowledge received
Data Sent Message 2  Tx failed
Data Sent Message 2  Acknowledge received
Data Sent Message 3  Tx failed
Data Sent Message 3  Acknowledge received
Data Sent Message 4  Tx failed
Data Sent Message 4  Acknowledge received
Data Sent Message 5  Tx failed
Data Sent Message 5  Acknowledge received
Data Sent Message 6  Tx failed
Data Sent Message 6  Acknowledge received
Data Sent Message 7  Tx failed
Data Sent Message 7  Acknowledge received
Data Sent Message 8  Tx failed
Data Sent Message 8  Acknowledge received
Data Sent Message 9  Tx failed
Data Sent Message 9  Acknowledge received

and when i also switch 48 and 49 in the receiver code it says this:

SimpleTx Starting
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed

so i know my pins now.
i hope to have my scematics online today.

Glad that you are making progress. Ask again if you get stuck.

Slow your transmission rate, with a delay, so that you are not sending so often. Try delay(50) o so.

1 Like

just a quick question about the CE and CSN pins before i try some more stuff

does it matter if i put

RF24 radio(6, 7);

or 

RF24 radio(7, 6);

and if so wich side is the CSN and wich is the CE pin?

and another question about pin 10,
i read that if you don't use pin 10 for CSN or CE you still have to put is as an output, is that correct?
because right now i have in both void setups i have

pinMode(10, OUTPUT);