nRF24L01+

I have been working for about 2 weeks on and off using the nRF24L01+ modules. After using every library I can find out there, different sketches of code, my own code, different modules, different arduinos, I cannot find any thing that works. For my setup I am using an arduino nano (https://www.amazon.com/gp/product/B019SXNBQY/ref=oh_aui_detailpage_o01_s03?ie=UTF8&psc=1) connected directly to the module via female to female ribbon cable. I have 10uf capacitors soldered directly to the pins of the module and there is no power problems. I have even tried using an external voltage regulator with the capacitor also... The two main websites I were using were: https://forum.arduino.cc/index.php?topic=217865.0 and http://randomnerdtutorials.com/nrf24l01-2-4ghz-rf-transceiver-module-with-arduino/

I also watched Julian Ilett's "tutorial" on them which was technically a "one day project"

I've viewed many different tutorials and forums explaining code problems but the most I ever get is a random stream of data that doesn't change whether the transmitting arduino is on or off.

Any help on this would be much appreciated. Also any help over skype, google hangout, or even by phone will be 100% appreciated.

Thank you -Jacob

Hi, Welcome to the forum.

Can you post some code that you have tried and explain what does not work. Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png? Also a picture of your project so we can see your layout.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :)

I got a small piece of code finally to work from this website:

I am now trying to understand the code. Would you mind breaking it down for me?

// nrf24_server

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()
{
Serial.begin(9600);
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println(“init failed”);
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println(“setChannel failed”);
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println(“setRF failed”);
}

void loop()
{
if (nrf24.available())
{
// Should be a message for us now
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf24.recv(buf, &len))
{
// NRF24::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);

// Send a reply
uint8_t data = “And hello back to you”;
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
Serial.println(“Sent a reply”);
}
else
{
Serial.println(“recv failed”);
}
}
}

// nrf24_client

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println(“init failed”);
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println(“setChannel failed”);
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println(“setRF failed”);
}

void loop()
{
Serial.println(“Sending to nrf24_server”);
// Send a message to nrf24_server
uint8_t data = “Hello World!”;
nrf24.send(data, sizeof(data));

nrf24.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);

if (nrf24.waitAvailableTimeout(500))
{
// Should be a reply message for us now
if (nrf24.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
Serial.println(“recv failed”);
}
}
else
{
Serial.println(“No reply, is nrf24_server running?”);
}
delay(400);
}

More specifically I dont understand the uint_8 buf
I understand that uint_8 means that its an 8 bit unassigned intiger but im not sure what “buf” is.

Also confused when the term “sizeof”…

Any help would be extremely appreciated!

-Jacob

It is good that you had success with the NRF24L01 module and the supplied examples. I'll make a quick attempt to answer the specific questions you've asked but it looks like you are jumping into c/c++ programming at the deep end and you should have a look at some online tutorials to get an idea of the main concepts of the language like how data is represented, manipulated and used. Knowing a few basic concepts would make it much easier for you.

buf is a variable (actually here an array) of data type unsigned (that is no plus or minus) integer of size 8 bit. sizeof() can be regarded in this case as a function which returns the size of the argument given to it in bytes.

Have a look at this Simple nRF24L01+ Tutorial. It works.

And I have kept the examples as simple as possible soI hope they can be understood.

...R

Hi jkkicks

I note your comment about no problems with power supply. This appears to be important with the nRF24L01, see Terry King's page. I couldn't get Terry's power supplys but I did find these and they made a difference.

Also, connect the Gnd on your power supply to Gnd on the Arduino PCB.

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.... :)