Hi,
I can’t get my nrf24l01 to work. I am aware that many other people have the same problem and many solutions have been found. I think I have tried all of them:
I have banned long jumper wires and soldered the circuit on perfboard (checked for continuity).
I have added a 100uf capacitor between 3.3v and ground.
I have used a different power source than the Arduino 3.3v pin.
I have tried different nrf24l01 module combinations.
I have tried different codes that seem to work with other people.
I don’t know what to try next. One of the codes I tried is this one:
//transmitter
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// Instantiate RF24 class with CE and CSN values
RF24 radio(7, 8);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;
void setup() {
// Setup serial output
Serial.begin(9600);
// Start RF
radio.begin();
// Setup the channel to work within, number 100
radio.setChannel(100);
// Open wite pipe
radio.openWritingPipe(pipe);
}
void loop() {
// it changes every interval
info = !info;
if (info) {
Serial.print("Sending positive... ");
} else {
Serial.print("Sending negative... ");
}
// Send info over RF
bool success = radio.write(&info, sizeof(boolean));
if (success) {
Serial.println("sent!");
} else {
Serial.println("fail!");
}
// Wait 2 seconds and repeat
delay(2000);
}
//receiver
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// Instantiate RF24 class with CE and CSN values
RF24 radio(8, 7);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;
void setup() {
// Setup serial output
Serial.begin(9600);
// Start RF
radio.begin();
// Setup the channel to work within, number 100
radio.setChannel(100);
// Open recept pipe
radio.openReadingPipe(1, pipe);
// Start to listen
radio.startListening();
}
void loop() {
// Wait until some data
if (radio.available()) {
// Read payload, and check if it finished
radio.read(&info, sizeof(info));
// Manage info
if (info) {
Serial.println("We received positive!");
} else {
Serial.println("We received negative!");
}
}
// Wait a bit
delay(50);
}
The transmitter keeps posting sent. The receiver keeps posting received positive. Same thing when I don’t connect a module at all. When I connect a different module to the receiver side, it posts nothing.
What should I try next?
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.
Hi,
I have used the test code to check the connection between the nrf24l01 and the Arduino. One of my modules is broken. With the other two I got these results.
I used the test code you provided. I changed the CE an CSN to pin 7 and 8. I added the line: pinMode(10, OUTPUT);. (Does this mean I can’t use pin 10 in later projects?). This is the output I got.
It looks like there is at least some connection between the two. Is this because there is something wrong with the feedback?
Rutger13:
I used the test code you provided. I changed the CE an CSN to pin 7 and 8. I added the line: pinMode(10, OUTPUT);. (Does this mean I can’t use pin 10 in later projects?).
Until you get things working don't change anything.
Pin 10 must be set as OUTPUT but it does not have to be used for SS (CSN).
Hi,
With the test code you provided I am able to send data from the transmitter to the receiver. The problem I have is that radio.write() keeps returning false even though the message was received. I tried version 1.17 and 1.3.11 of the library. 1.3.11 comes with test code with which the acknowledgement did work (AcknowledgementPayloads). I don't have enough experience to replicate what they are doing and I have no idea why the other test code did not work for me.
I am not able to post the code, because it is too long.