Adding the RF24 Library

Using the Library Manager I have installed this library:
RF24 by TMRh20 version 1.4.2
Using the "Include Library" function for the new RF24 library adds to the sketch:
nRF24L01.h; printf.h; RF24.h and RF24_config.h
but the compile fails with the message:
...\libraries\RF24/RF24_config.h:106:29: fatal error: SPI.h: No such file or directory
#include <SPI.h>
I have not found anyone else with this problem and have searched through the available SPI libaries but cannot spot anything obvious is required for the RF24.
I would appreciate knowing what I need to add in order to start using NRF24L01 devices.
I'm running version 1.6.4, yes, not the latest but last time I updated (from 1.0.3) required all 11 of my sketches to be changed before they would compile!! However, if that is advice, then I will...

Which Arduino board are you compiling for ?

Thank you for your reply.
If I can get wireless communication up and running there are two types of board that we use, the UNO and Mega. I'm attempting the UNO first but not got that far. I've just added the RF24 library to the example script that came with the original software download and attempted the compile, which failed.

Try the examples in Simple nRF24L01+ 2.4GHz transceiver demo

Yes, That is the library I found, though the version 1.4.2.
That is installed and giving the Compile message in my first post.
I've now found and installed the earlier version mentioned in the text, RF24 1.1.7
but the compile still failed with the SPI.h error.
However(!), I've just realised that when I use the "Sketch" and "Include Library" function to include "RF24", and compare it to the examples you gave me, there is some code missing from the generated list, namely #include <SPI.h>. If I type that in to the sketch it does compile!!
I should have noticed the missing code before... Sorry. Thanks for you responses.
Tomorrow I'll add the Transmit and Receive coding. I will need to do better...

In olden times, the main sketch had to #include all of the libraries used so the Arduino IDE would know to add them to the search path. Try adding a "#include <SPI.h>" line to your main sketch so the RF24 library will be able to find SPI.h during the compilation.

Yes, it will compile, thank you. I has assumed (!) that using "Sketch" then "Include Library" and "RF24" would add all the #includes required. I was not helped by using/copying an example I found on the internet which itself didn't include #include SPI.h.

All of the examples in Robin2's simple rf24 tutorial include the SPI library.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.