Help With The NRF24L01 Module

I am building an rc car and I am trying to use a remote control but I can’t even get basic code for the NRF onto my board.

Materials:

  • 2 Arduino Unos
  • 2 NRF24L01 Modules
  • A Funduino Shield

Any help would be appreciated. I am just trying to get the two to connect at the moment but the error is saying “sketch\RF24.h:18:25: fatal error: RF24_config.h: No such file or directory”

Pictures of the folder and the error code can be viewed in the images below.

The code I am using is from a youtube video by Kevin Darrah: http://www.kevindarrah.com/wp-content/uploads/2014/03/NRFMaster_V2.txt

Thank You In Advance,
Brian

Images from Original Post so we don’t have to download them. See this Image Guide

9f15336b2fe8c4f775eb05f9d50b26e71461434c.jpg

5dfdc1ee80881ee4c3337bfc53dfd2351595ff6b.png

484e153f5404b8085c5e4c3c7dbc929cce468d7c.png

…R

Please post error message and code as text rather than pictures. I cannot read those images.

This Simple nRF24L01+ Tutorial may be helpful. I am using the second example (using ackPayload) to control model trains.

...R

C:\Users\Owner\Desktop\NRF-Test-1\NRF-Test-1.ino:6:22: fatal error: nRF24L01.h: No such file or directory
#include <nRF24L01.h>
** ^**
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.

I try and remove the
#inclue <nRF24L01.h>
but it says the next #include is not in the directory either so I don’t know.

Also thank you for the response, I really appreciate it.

Hi,
You do not have the nRF library installed correctly. See THIS: about libraries.

Lots of nRF24L01 How-To HERE:

Realise it’s an old post but same problems here.

When I go to one of the links it says " NOTE! If you get a Library that is labelled “Master”, like “RF24-Master.zip” you must RENAME the Zip file AND the folder inside it to remove the “-Master” part! "

Well, I tried that, but does not work. One can change the name of the zip folder but not the one inside it.
Do we have to unzip, then rename, then zip it up again.

Anyhow, the ide when compiling says it cannot find the file yet, when I check the library, it is already there.

Do not know why it is looking for the file in the folder where I downloaded the code either.

Arduino: 1.8.5 (Windows 7), Board: “Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)”

C:\Users\bob\Desktop\iForce2D Programs\temp_tester_new\temp_tester_new.ino:22:22: fatal error: nRF24L01.h: No such file or directory

#include <nRF24L01.h>

^

compilation terminated.

exit status 1
Error compiling for board Arduino Pro or Pro Mini.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

/*
 
 Connections for nRF24L01 pins
 1 - GND
 2 - VCC 3.3V !!! NOT 5V
 3 - CE to Arduino pin 9
 4 - CSN to Arduino pin 10
 5 - SCK to Arduino pin 13
 6 - MOSI to Arduino pin 11
 7 - MISO to Arduino pin 12
 8 - UNUSED
 
 Connections for OLED screen pins
 GND - GND
 VCC - VCC (mine seems to work with both 5V and 3.3V
 SDA - arduino analog pin 4
 SCL - arduino analog pin 5 
 
 */

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

const uint64_t pipeIn =  0xE8E8F0F0E1LL; // match this on both sides!

RF24 radio(9, 10);

// The sizeof this struct should not exceed 32 bytes
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte dial1;
  byte dial2;
  byte switches; // bitflag
};

MyData data;

unsigned long packetsRead = 0;
unsigned long lastUpdate = 0;
int packetsSec = 0;
unsigned long lastRecvTime = 0;
unsigned long drops = 0;

/**************************************************/

// writes a single line of formatted text to the screen at the current cursor position - keep it short!
void displayln(const char* format, ...)
{
  char buffer[64];
  
  va_list args;
  va_start(args, format);
  vsprintf(buffer, format, args);
  va_end(args);
  
  int len = strlen(buffer);
  for (uint8_t i = 0; i < len; i++) {
    display.write(buffer[i]);
  }
}

/**************************************************/

void setup()
{
  radio.begin();
  radio.setDataRate(RF24_250KBPS); // Both endpoints must have this set the same
  radio.setAutoAck(false); // Both endpoints must have this set the same

  radio.openReadingPipe(1,pipeIn);
  radio.startListening();

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.clearDisplay();
    
  memset(&data, 0, sizeof(MyData));

}

/**************************************************/

void recvData()
{  
  while ( radio.available() ) {        
    radio.read(&data, sizeof(MyData));
    packetsRead++;
    lastRecvTime = millis();
  }
  
  unsigned long now = millis();
  if ( now - lastRecvTime > 1000 ) {
    drops++;
  }
}

/**************************************************/

void displayBits(byte b, int howManyBits)
{
  for (int i = 0; i < howManyBits; i++) {
    int mask = 1 << i;
    if ( b & mask )
      display.write('*');
    else
      display.write('-');
  }
}

/**************************************************/

void updateScreen()
{
  unsigned long now = millis();
  if ( now - lastUpdate > 1000 ) {
    packetsSec = packetsRead;
    packetsRead = 0;
    lastUpdate = now;
  }
      
  char buf[16];
    
  display.clearDisplay();
  display.setCursor(0,0);
  displayln("Packets = %d\n", packetsSec);
  
  displayln("%d\n", data.throttle);
  displayln("%d\n", data.yaw);
  displayln("%d\n", data.pitch);
  displayln("%d\n", data.roll);
  displayln("%d\n", data.dial1);
  displayln("%d\n", data.dial2);
  
  // draw rectangle for joystick outline
  display.drawRect(30,12, 40,40, 1);
  display.drawRect(75,12, 40,40, 1);
  
  int d1 = map(data.throttle, 0, 255, 0, 100);
  int d2 = map(data.yaw,      0, 255, 0, 100);
  int d3 = map(data.pitch,    0, 255, 0, 100);
  int d4 = map(data.roll,     0, 255, 0, 100);
  
  // draw dot for current joystick position
  display.fillRect(30+40*(d2/100.0)-3, 52-40*(d1/100.0)-3, 6,6, 1);
  display.fillRect(75+40*(d4/100.0)-3, 52-40*(d3/100.0)-3, 6,6, 1);
  
  display.setCursor(0,7*8);
    
  displayBits(data.switches, 8);
  display.write(' ');
  
  displayln("%ld drops\n", drops);
    
  display.display();
}

/**************************************************/

void loop()
{
  recvData();
  updateScreen();
}

What is the full path to the location where you have installed the RF24 library?

What version of the RF24 library have you installed?

...R

Hi Robin,

I managed to get it up and running. Seems either the library was old or perhaps not even installed.

How I rectified the problem was to go to the "sketch" ....."include library" ...."manage libraries" and did a search for RF24. Scrolled down until I found it and hit "more info" ...program pretty much took care of it from there.

Apologies for the vacant brain cells.

I did read about the location having to be directly in the arduino/libraries/...xxx

When you have a directory named with something like "RF24-master", then changing the name to just "RF24" would help solve the issue of 'no such file or directory'.

Also,make sure that the newly obtained "RF24" library is present inside the libraries folder of the Arduino folder.