Monday, June 4, 2007

nRF24L01 tutorials 1-3 for the PIC completed

Well, I finally got it done! Tutorials 1-3 for the nRF24L01 have been completed with write-ups for the PIC line of processors (PIC18F452 in these). I forgot to change one thing in the project build options though, and it will likely make some weird directories on your machine if you try to compile the source. In MPLAB, click Project->Build Options->Project. Next, click the "Directories" tab and in the "Show directories for:" drop-down box, change "Output Directory" and "Intermediate Directory" to their default values by choosing the appropriate option and hitting the "Suite Defaults" button (you will have to do it for both).

The links to the .zip files for each of the projects can be found here: Tutorial1, Tutorial2, and Tutorial3.

Labels: , ,

18 Comments:

At June 7, 2007 at 9:06 PM , Blogger tim said...

Hi Brennen, What a fantastic resource for using the nRF24L01 with pics. I have had a play with your code and found it most interesting reading through your tutorials. I wonder if you have had any thoughts on how you would use your library with multi-byte payloads using C18. Say I had an array called data with 6 elements, how would you set the array up to be used with nrf24l01_write_tx_payload(); to send the packet of 6 bytes and how would you use nrf24l01_read_rx_payload(); to put the packet back into an array. I would most appreciate any help in this usage. Tim, UK

 
At June 7, 2007 at 9:50 PM , Blogger brennen said...

It's really simple, actually. For a 6 byte payload, you would have an array of size 6 (or greater), say we'll call it unsigned char data[6]. When you call nrf24l01_write_tx_payload(), you would pass it data and then the "len" variable would be 6 (generally, "transmit" would be true, also). Pretty simple, eh?

To receive, you do the exact same thing. Declare the variable the same, and call the function with data as the buffer and 6 as the length.

 
At July 11, 2007 at 10:47 AM , Blogger ullasmann said...

Hi Brennen. Great tutorials on the Rf chips. Where can I buy them and how much do they cost?

Keep up the good work.

Ullasmann

 
At July 11, 2007 at 11:19 AM , Blogger brennen said...

Hi, there ullasmann. I buy my breakout boards for the 24L01 (they're called the MiRF-v2) from Sparkfun Electronics (www.sparkfun.com). They come in two flavors, one with an onboard chip antenna and another with a reverse-polarized SMA coax connector for adding an external antenna. The costs for these two are $30 and $20, respectively. You can get more info on them in Tutorial 0. Thanks for stopping by!

 
At August 22, 2007 at 4:56 AM , Blogger Sheng said...

Hi Brennen,

I am using pic16f877 running at Fosc = 20MHz. I have problem reading back the register value using soft SPI. Example reading reg 0x10.

I used a LA to monitor the SPI line. When sending 0x10, i saw that the clk & MOSI signals are correct and the CE is low. However, when i sent 5 bytes of 0x00 to read from the MISO, the CE pin becomes a clk like signal and i can't get the data in reg 0x10. BTW, the data rate is < 1Mbps. Can you give me some advice??

SW

 
At August 22, 2007 at 7:56 AM , Blogger brennen said...

Hi, Sheng. That's a pretty tough question to answer without being able to get into the details of your hardware and software. It sounds like there may be a possiblity that you haven't changed your #define's for the IO registers in nrf24l01.h to the right values. I haven't ever observed CE not working properly, but I've always used PIC18-series chips, and the C18 compiler. There also may have been some issue with porting it over to whichever compiler you're using (CCS, etc.). Unless you are tied to the 16F877A, I would definitely suggest going for an 18F4520, since it's pin compatible and a big improvement.

 
At September 14, 2007 at 5:37 AM , Blogger Rakesh said...

Wow. That was one nice compilation. Thanks man. Btw, can you comment on the range performance of these chips? How far have you tested that they work properly?

 
At September 14, 2007 at 7:59 AM , Blogger brennen said...

Hi, Rakesh. I think I covered your question in the email you sent me. Check your inbox...

 
At November 12, 2007 at 7:47 AM , Anonymous rene said...

Hi,
I'll like to ask if you know how to play short Wav files using pic 18F452?
if so please guide me at:
oink_soul88@hotmail.com

regards
irene

 
At January 12, 2008 at 10:45 AM , Blogger F_P_G_A said...

hey..
is anybody still there?
I want to play sound too.. from PIc program memory...
can you give me some advise then..
thanks and many...

kingofadmins@gmail.com

 
At January 12, 2008 at 4:28 PM , Blogger brennen said...

Playing a WAV file from a PIC isn't a terribly easy thing to do. First, you have to get the WAV file into the PIC's memory, or an external memory. After that, you have to be able to read that memory and send it to an external audio digital-to-analog converter. There is a lot of research that has to be done to get this done, and it's not a project for beginners to embedded electronics.

 
At February 27, 2008 at 11:26 AM , Anonymous Anonymous said...

Hello , thanks for these tutorials , I have modified the nrf24L01.h to work with 18F8722 (two board with 18F8722) , but when I use the 18F4550 USB chip from microchip , I don't have any error compiler , but the remote board (18F4550) does not work :( ...

anybody have any idea about the software modify on the nrf24l01.h (and the delays function) because now I have the 48Mhz (and not the 40Mhz) ... thanks.

 
At January 15, 2009 at 8:23 PM , Anonymous Aigars said...

Hi Brennen, thank you for this great
tutorial! Everything is working. But could you explain why send-receive works only for few (10~60) haracters.
Then it freezing on while irq_pin loop. It seems like nRF24L01 IRQ stops going low when job is done.

 
At February 3, 2009 at 11:30 AM , Anonymous Anonymous said...

Hi Brennen,

Excellent tutorials. I have a question: have you by any chance have measured the time lapse between sending one byte from the microcontroller throuh SPI to the IRQ activation on the receiver microcontroller? I need to implement a very fast app. (No ack - no pipes - only sender to receiver, one byte).
Thanks in advance.

 
At November 21, 2011 at 3:34 AM , Anonymous Anonymous said...

I seem to have a problem listening then receiving in a while loop.
it appears random, sometimes it works other times if i set nrf24L01 to receiver set_as_rx(true), then set_as_tx(), then write_payload(data,6,true), the chip is unable to confirm a send, the irq and irq_ds are not set.

 
At September 30, 2013 at 6:03 AM , Blogger k13less said...

Hi brennen, i'm using your tutorials in a project, and they are a really good help.
I'm trying to communicate with several nrfs, but my problem is that when i change the rx and tx address it only gets sucessful one or two times. Could you help, please?

 
At November 26, 2014 at 5:54 PM , Anonymous Ikalogic said...

Hi! Nice tutorial. We have developed a decoder for the nrf24l01 protocol. used with our logic analyzers it can be very useful to quickly interpret the SPI signals. Thought it might be interesting to share here: http://www.ikalogic.com/nrf24l01-debugging-piece-cake/

 
At January 6, 2016 at 10:31 PM , Anonymous cyl said...

Hi Brennen. We're making this project using NRF24L01. Is it possible to cater 30TX using only 1RX?

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home