Hello
I am trying to teach myself how to use the NRF24l01 radio module and am running into issues. I am have set up the device using the guides in the following websites and neither have had success. I also tried the GettingStarted file in the RF24.h library with no luck either. I am also using the adapter for the module.
Basically my problem is I cant send or receive a signal. To start I have added checks in my code to tell is the signal was sent and it always says failure. Weirdly enough when I take the module out of the adapter I get the "message sent" message otherwise its "failure to send". Similarly when removing the ground pin the same problem arises.
When using the GettingStarted file from library, taking the ground pin out seems to actually send a signal although I guess this could be an error. Here is the code that I have been using to test sending capabilities, its pretty much the last minute engineers code with some added checks for send message failure. THanks in advance
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(9, 8); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
//set the address
radio.openWritingPipe(address);
//pinMode(10,OUTPUT); not sure about this. I read somewhere it has to do with SPI
//Set module as transmitter
radio.stopListening();
}
void loop()
{
Serial.println("Monitor Check");
//Send message to receiver
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
const char *message = "Testing Message"; // The message to send
bool result = radio.write(&message, sizeof(message)); // Send the message
if (result) {
Serial.println("Message sent successfully.");
} else {
Serial.println("Failed to send message.");
}
delay(1000);
}
Here are some tips from my time learning to get the rf24 radios to work.
If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. The code in the examples has been proven to work many many times. If it does not work for you, there is likely a hardware problem.
Run the CheckConnection.ino (look in reply #30 in the tutorial) to verify the physical wiring between the radio module and its processor (Arduino). This is especially useful if all you see is “Data received” repeating much more quickly then there is a problem - most likely theArduino is not communicating properly with its nRF24.
Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.
If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings.
Thanks for replies. I am using an Arduino UNO predominantly although have tested with my mega also with no luck.
Using the CheckConnection.ino file from Robin2's tutorial I got the case where the arduino was not communicating with the device. My test results are below. I dont really know what any of it means tho sorry.
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
With this I tried using an external power supply as shown to supply the module with the hope to provide enough current. Still no luck.
Additionally, I update my RF24.h library and still no luck. I am starting to wonder if my module is actually just fried and if I should get a new one.
Here is my set up finally, I don't think the wiring could possibly be wrong, ive reconnected it so many times now that it should have been right on at least one.
In terms of the receiver, I didn't think it was needed just to send a signal so I haven't set one up yet. Does the transmitter need a receiver end to properly transmit data?
AHAH what do you know it works. I think I skipped the part in the information about how there needs to be a receiver on the end to pick up the signal. Just to clarify, this is a quirk of the NRF module itself and not a general radio transmitter thing? For example, a walkie talkies can just send a signal without knowing there is another one on the same channel. I might just sound like an idiot here but its got me thinking
I am no expert on all things radio, but i can tell you that, it depends.
A transmitter will transmit even if there is no receiver. However, in order to see the transmission there must be a receiver. The receiver must be tuned to the same frequency (channel in rf24 case), have the right address (pipe) and speak the same protocol. So, even though a Bluetooth module is the same frequency as rf24, address and protocol are different so Bluetooth will not pick up rf24. Same with WiFi.