I've spent about a day playing/troubleshooting some NRF24L01+ modules and 5v adapter boards and wanted to share my findings so that they may help others in the future but also to understand why I'm seeing the behaviour that I am.
Being fairly new to Arduino and wireless projects, I thought I would save myself some headache by ordering the 5v adapter boards with the NRF24L01+ modules as I had seen that they help regulate the power to an otherwise finicky wireless module. For reference, these are the adapter boards I'm talking about:
So off I go trying to get two modules + adapters to talk to each other using clone Nano boards and I have no luck what so ever. They are returning random readings and generally not making sense. When I use the following testing script:
// Load up the libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
// Set the pins up
#define CE_PIN 7
#define CSN_PIN 8
// A pipe is needed
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
// Create a Radio
RF24 radio(CE_PIN, CSN_PIN);
void setup()
{
// Start Serial
Serial.begin(9600);
while(!Serial);
// Saying hello to you
Serial.println("NRF24L01P test Script starting...");
Serial.println("If you do not see a long message after this line, something is not right!");
// This is needed so that radio.printDetails(); actually works!!!!
printf_begin();
// Start the radio
radio.begin();
// Start the radio, again set ti min & slow as I'm guessing while testing theire really close to each oth
radio.setPALevel(RF24_PA_MIN); // RF24_PA_MIN ,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
radio.setDataRate( RF24_1MBPS ); // RF24_250KBPS, RF24_1MBPS, RF24_2MBPS
// Set the pipe
radio.openReadingPipe(1,pipe);
// Start listening
radio.startListening();
// And cruically print the details
radio.printDetails();
}
void loop()
{
// nothing here on purpose :)
}
I get this output:
NRF24L01P test Script starting...
If you do not see a long message after this line, something is not right!
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 0x0000000070
RX_ADDR_P2-5 = 0x38 0xc4 0x1c 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x20 0x1c 0x20 0x38 0x38 0x20
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x14
CONFIG = 0x0f
DYNPD/FEATURE = 0x38 0x00
Data Rate = 2 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
ARC = 0
Notice the PA_HIGH and 2MBPS data rate, indicating that we are not successfully communicating with the NRF24L01+ module and changing those settings.
Finally, I tried ditching the adapter board and plugging the wireless module up to the 3.3v output of the nano (despite other warnings that this power source might not be stable enough) and sure enough, they work just fine. Output from running the same code sample as above:
NRF24L01P test Script starting...
If you do not see a long message after this line, something is not right!
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 0xe8e8f0f0e1
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 = 0x02
RF_CH = 0x4c
RF_SETUP = 0x01
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN
ARC = 0
Notice the data rate and power are as expected and the address looks better too. I have confirmed that 2 boards hooked up like this will work and reliably transmit data.
So now I'm thinking it is the adapter board that was bad. I ordered 4 of them and all of them caused the same issue and produce the bad debug output shown above. However, I have now determined that this bad output is related to the wire-length running between the module and the arduino nano (being powered by my computer usb).
Let me explain. The wireless module + adapter is connected up to the nano using 20cm M-F dupont cables. When I plug the power and ground of the dupont cables into the breadboard rails, then use jumper wires to connect the rails to 5v and ground from the arduino, I get the bad connection (shown above). If instead, I run them straight to the breadboard lanes for the Arduino 5v and ground pins, I get a working NRF24L01+ using the adapter board:
NRF24L01P test Script starting...
If you do not see a long message after this line, something is not right!
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 0xe8e8f0f0e1
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 = 0x02
RF_CH = 0x4c
RF_SETUP = 0x01
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN
ARC = 0
At this point, it sounds like an issue with my breadboard rails, but I have found that if the 5v rail is connected via jumper wire that is shorter than about 10cm everything works. If I connect the power from Arduino pins to the rails with cables that are 20cm or longer it doesn't work (I have tried multiple known-good short and long jumper wires and the behaviour is consistent).
Can anyone shed some light on what is happening? I suspect it has something to do with the resistance of the little jumper wires but at this point, I don't know enough be sure.