I'm trying to use a NRF24L01+ to do wireless communication. I downloaded this library but when I try to run GettingStarted.ino from the examples directory here: I get the following
Now sending
failed
Failed, response timed out.
Now sending
failed
Failed, response timed out.
I've hooked up the NRF24L01+ to my Arduino Uno like it says in this post. I've also tried the example code from that post which also fails to send.
I've tried adding a 10 uF capacitor but that didn't help.
When I call isChipConnected() it returns true and printDetails() doesn't return a bunch of 0's or FFs:
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.
A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. 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) make sure there is sufficient distance between the two nRF24s so that the signal does not overwhelm the receiver - try 3 metres separation. If you are new to nRF24s it may be better to start with a pair of low power modules with the pcb antenna.
I'm now powering the NRF24L01+ externally but I'm still getting transmission errors.
SimpleTx.ino from your link outputs
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
...
CheckConnection.ino outputs
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
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x4141417852 0x65646f4e32
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x4141417852
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x4141417852 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x4141417852
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x23
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
My final plan is to have 2 arduino pro minis talking with each other but I've been prototyping on the Uno because its easier. Right now, to try and simplify as much as possible, I only have a single RF24 connected to a single arduino.
I've tried using the RF24 with both pro minis and the "check connection" looks the same. I've also tried swapping out the RF24 for a different RF24 with the same result.
At this point, I'm using code that entirely isolates the rf24 sending. It is below.
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte kRadioAddress[6] = "00001";
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
void setup() {
Serial.begin(9600);
if (radio.begin()) {
Serial.println("Radio started successfully");
} else {
Serial.println("Error starting radio");
}
radio.openWritingPipe(kRadioAddress);
radio.stopListening();
}
long prev_send_time = -1;
void loop() {
long now = millis();
if (now - prev_send_time > 1000) {
const char kToSend[] = "Hello World";
if (radio.write(&kToSend, sizeof(kToSend))) {
Serial.println("Send successful");
} else {
Serial.println("Send failed");
}
prev_send_time = now;
}
}
It outputs:
Radio started successfully
Send failed
Send failed
Send failed
Send failed
Send failed
Send failed
I'm an idiot. I thought the write method returned true when a message was sent. Reading the docs it returns true when the other side acks. As you probably already figured out, it will never return true if there is no other side.
One of the complexities of debugging a wireless system is the fact that if nothing is received there is no way to know whether the fault is with the Tx or the Rx