An nRF24L01 C library everyone can use

After a few weeks of development, I have rewritten a large chunk of my include library for the nRF24L01 chip. All of the old SPI functions are gone now, and there is only one SPI function you must write. It simply takes one byte as an argument and sends it over the SPI bus to the 24L01. It then waits for the response from the 24L01 and returns that value. It doesn’t get much simpler than that. You still have to implement the microsecond delay function that takes the number of microseconds as the argument. You also have to set up the registers and pin masks in the .h file. (All of this is extremely well-documented in the .h file.)

Another thing that I changed in this code version was the elimination of the 130 uS delay. The one time this is necessary is when a receiver goes from standby mode (CE = 0) to RX mode (CE = 1). The function should not be added to the receiving device, but to the transmitter such that it waits the necessary 130 uS for the receiver to get into RX mode. Without using this delay, you may miss packets at the receiver until it gets fully into RX mode.

I have two tutorials that are totally written right now code-wise, and I have to make write-ups for explaining them. I also have a sort of “everything you need to know” document almost ready describing just about everything about the 24L01 and the MiRF-v2 breakout. Watch for these to be posted in the coming few weeks.

As for the links to the code, they are the same as they always are: [nrf24l01.h and [nrf24l01.c.](http://filebox.vt.edu/users/stball1/code/nrf24l01.c)](http://filebox.vt.edu/users/stball1/code/nrf24l01.h)

Thank you, brennen, for your kindness for sharing the code with us. I have a few nRF24L01 modules and I want to try them out. I will use your code as a starting point for a low level driver.

This is actually a really dated post. If you’re gonna try out the 24L01, I would recommend you reading the tutorials on my website, which can be found below in my tag line. I have implementations for ARM (LPC2148) and PIC (18F452) at the current moment, so enjoy! 8)

Yes, I have seen your site and it is great ! I’ve read the four tutorials about PIC and nRF24L01 and I plan to develop my own code for a low level driver. If anything should go wrong, I will take a look at your code to see where I’m mistaking. It’s good to know you have a very clear written code available if you need it.

hi, people following this thread should also check out this one: http://www.arduino.cc/cgi-bin/yabb2/YaB … 1289089043 seems like a good idea to link such things together, given how much time it can take to find stuf.

-mike :slight_smile:

Hi brennen, can you please put a new links for the libraries, the links are brokens now :frowning:

Just click the link in my signature. http://www.diyembedded.com

Ok, brennen, thanks for the web page, i will check it, and i hope some help if is possible, tks

Yeah, I’m more than willing to help out if you need it.

sorry man, i visited your tutorials on your web page but i dont watch the links of the code for the nRF24L01

sorry again man, i already watched your .zip tutorials, i will check it, tks

hi Brennen…where can I find the nrf24l01.h and nrf24l01.c code?..i’ve been looking on your page and nothing…can you share the updated code?..thanks in advance…

If you click on any of the tutorials at http://www.diyembedded.com, you will get the nrf24l01.h and .c files.