Hello everyone, Im having issues setting up 2 nRF24L01 trancievers. I want to establish a basic "Hello World" connection. Im using an arduino nano. I have read various forums and different articles but i cant find out whats wrong, I dont get any reading in the Serial monitor for the receiver. I have checked the wiring various times and changed the code and digital connections and it still doesnt work.
My connections on both devices are:
Ground-Ground
VCC-3.3v
CE-9
CSN-10
SCK-13
MOSI-11
MISO-12
I would appreciate any help or suggestions on how to make it work.
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
There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.
A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.
If you are using the high-power nRF24s (with the external antenna) it may help to have a distance of about 3 metres between the two nRF24s so that the signal does not overwhelm the receiver. However someone on the Forum has had them working without that separation - I don't have any personal experience with them. If you are new to nRF24s it may be better to start with a pair of low power modules with the pcb antenna.
I measured the output voltage in my arduino nano and i have a reading of 3.2V on both. I also tried using 2 AA to power the nRF24l01 and that also didnt work.
emd56:
I measured the output voltage in my arduino nano and i have a reading of 3.2V on both. I also tried using 2 AA to power the nRF24l01 and that also didnt work.
You are not giving me much to go on.
Have you tried the connection test program that is in my Tutorial? If that does not work then nothing will work.
From what i understand it seems like is communicating with the arduino, however, I tried the simple one way transmission test and i couldnt get that to work.
emd56:
From what i understand it seems like is communicating with the arduino,
Correct. But you need to run the test on both Arduinos.
If the connection test works on both Arduinos but the simpleTx and simpleRx programs don't work then post the actual code that YOU have uploaded to your Arduinos and post a sample of the output from each Arduino.
Do you have some spare nRF24 modules in case one is faulty?
Are you using the high-power modules or the low power modules?
Robin2:
Correct. But you need to run the test on both Arduinos.
If the connection test works on both Arduinos but the simpleTx and simpleRx programs don't work then post the actual code that YOU have uploaded to your Arduinos and post a sample of the output from each Arduino.
Do you have some spare nRF24 modules in case one is faulty?
Are you using the high-power modules or the low power modules?
...R
Following your tutorial, here is the code that i uploaded to the transmitter:
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}
And here is the serial monitor on the Transmitter:
"SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed" and it continues like that
And here is the code for the receiver:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
Serial monitor for the receiver:
"SimpleRx Starting"
Try putting a 10uf capacitor across the +3.3v and gnd of each of the nRF24L01 module.
If that dosen't work, run the nrf24l01 off its own supply, 3.3v but have seen these peak at 1A! sending bursts. and the poor Nano's 3.3V comes from the FT232 chip, only 50mA is available.
Robin2:
There are two questions in Reply #5 that you have not answered.
And a 3rd question ... have you got the required 10µF capacitor across the power supply for the nRF24s?
And a 4th ... what happens when you swap the Tx and Rx programs between the Arduinos?
And a 5th ... can you confirm that you tried the programs without any changes to the hardware after the successful connection test?
...R
Im using the low power modules. And yes i have more nrf24l01 modules.
I do not have the capacitors, i thought i wouldnt need them since i tried powering them with their own power supply. But ill order some and try that.
When i swap the program for the Tx and Rx i get the same resuts as before on the serial monitor:
"SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed" and it continues like that
Serial monitor for the receiver:
"SimpleRx Starting"
And i did not make any changes after the connection test.
It's very hard to know what else to suggest when I can't actually see your work bench.
Make sure to power down the Arduino after uploading the code to ensure that the nRF24 resets. The nRf24 does not reset when you activate an Arduino reset.
I reckon the first thing is to add the capacitors.
If that does not solve the problem then it may be that one or both of the nRF24 modules is faulty. It's impossible to tell which one so it would be good idea to change one for a spare and see if that makes a difference.
Robin2:
It's very hard to know what else to suggest when I can't actually see your work bench.
Make sure to power down the Arduino after uploading the code to ensure that the nRF24 resets. The nRf24 does not reset when you activate an Arduino reset.
I reckon the first thing is to add the capacitors.
If that does not solve the problem then it may be that one or both of the nRF24 modules is faulty. It's impossible to tell which one so it would be good idea to change one for a spare and see if that makes a difference.
...R
Ok, i ordered the capacitors, they will arrive in a couple of days. I will give you an update if that changes anything.
Thank you for your help! Ive been trying to get these to work for weeks.