NRF24L01 - Coding

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
I want to start tinkering with these devices, I bought some a year ago but have been too busy to even look at them until now.

I see these devices use SPI, something I've read about but never used or coded for.

I'm going to be using a Nucleo F446RE but also have other boards I could use.

Is there a lot involved here? would anyone write low level code to manage these devices or use some existing library?

The kinds of projects I'm working with are HAL based, I use Visual GDB to program hardware here.

Thanks
 

MrChips

Joined Oct 2, 2009
30,712
I have a couple of projects using nRF24L01+.
SPI is not a problem and I have used it in numerous circumstances.

With any RF communications the problem is more complex. You need to have the right tools and software. There are nRF24 libraries available on GitHub for STM32 and MSP430. I have used both.

The problem is learning how nRF24L01 works. I must have had to read the user manual at least 100 times to figure it out. Also I have an RF spectrum analyzer which allows me to determine that the transmitter is active and sending at the correct frequency.

The other issue here is that communication is done in packets. Packets are sent and confirmation must be received by the sender. You need to set up the protocol properly otherwise you will not know what is going on. This is not a simple serial UART send and receive like 433MHz TX/RX modules.
 

MrChips

Joined Oct 2, 2009
30,712
From my experience, I found that the range of HC-05 Bluetooth is much superior than nRF240L.
You may want to explore ESP8266 and ESP32.
 

Ya’akov

Joined Jan 27, 2019
9,071
From my experience, I found that the range of HC-05 Bluetooth is much superior than nRF240L.
You may want to explore ESP8266 and ESP32.
The nRF24L01+LNA+PA with a good antenna has quite a good range. A version with no preamp or power amp and in onboard antenna doesn't have much range at all.
 

GetDeviceInfo

Joined Jun 7, 2009
2,192
After using this device for several projects, I was surprised to discover Hunter Douglas using this same device (PIC) in their wireless blinds for a number of years. Initially without amp, but then latter with. Mesh networked from an Ethernet hub. I found them reliable, easy to implement (AVR), and of reasonable range. Hunter Douglas supplied repeaters (extenders) to increase range.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
Wow, thank you all for your helpful replies, I need to plow through them later! I can see though that there is a lot of detail and functionality, not to be underestimated...

To do anything meaningful, that is to see or learn much, I would need two devices surely? That is I'll need a another device to listen to/talk to, I doubt there's much one can do - even initially while learning - with a single device?

I have three of them, but will I need two MCUs etc to setup anything even basic, for getting real comms going?
 
Last edited:

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
The nRF24L01+LNA+PA with a good antenna has quite a good range. A version with no preamp or power amp and in onboard antenna doesn't have much range at all.
What exactly does "NRF24L01 + PA + LNA" mean? what are the two terms "PA" and "LNA" separated by the + symbol?
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
Thanks.

Well I need to re-ask my question or rather another question, apologies for any run around.

I'm primarily interested in gaining an understanding of SPI coding and with hindsight the NRF24 is probably too involved for an initial foray into this (I just had them lying around and didn't appreciate how involved they were). I love radio and so on but the sophistication of that device is likely overkill for just getting some understanding if SPI.

So, to that end, if I have a couple of STM32 boards, what gadgets can I get or use to help me get an understanding of SPI?

I have a good scope and logic analyzer upgrades and this is where I want to go, SPI itself; and the choice of NRF (though a fascinating device) is not ideal I think.
 
Last edited:

MrChips

Joined Oct 2, 2009
30,712
You might have a mental block with SPI.
If you can program serial UART communications, you can program SPI.

You need to establish your clock speed, SCLK just as if you are specifying your baud rate.
One end is MASTER, the other end is SLAVE.
The only other important part is to set the phase and polarity, CPHA and CPOL.
After that you are ready to roll.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
Thanks fellas.

I read about SPI last night and it seems pretty clear, it seems that I do not need another device, I could write the code to generate data from some Nucleo board and just observe that, the mechanism does not require a master/slave to be connected in order to just generate data - that's what it seems anyway when reading the docs.
 

MrChips

Joined Oct 2, 2009
30,712
Yes, you can just send SCLK and MOSI and observe the two on an oscilloscope.
Just note that there are four combinations of CPOL and CPHA, mode 0-3. You just need to pick one and stay with it (whichever your slave device requires). Just go along with what the device datasheet says.
CPOL = 0, CPHA = 0 is common.

1666276902863.png

1666277002781.png
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
Many thanks, I want to explore the logic analysis feature of my SIGLENT SDS1204X-E scope, I got the hardware extension yesterday and this is a great way to get to grips with this.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,533
I have a couple of projects using nRF24L01+.
SPI is not a problem and I have used it in numerous circumstances.

With any RF communications the problem is more complex. You need to have the right tools and software. There are nRF24 libraries available on GitHub for STM32 and MSP430. I have used both.

The problem is learning how nRF24L01 works. I must have had to read the user manual at least 100 times to figure it out. Also I have an RF spectrum analyzer which allows me to determine that the transmitter is active and sending at the correct frequency.

The other issue here is that communication is done in packets. Packets are sent and confirmation must be received by the sender. You need to set up the protocol properly otherwise you will not know what is going on. This is not a simple serial UART send and receive like 433MHz TX/RX modules.
May I ask, what kind of rf analyzer do you have? is it some major professional piece of equipment? is there anything comparable out there for a hobbyist so to speak?
 

MrChips

Joined Oct 2, 2009
30,712
May I ask, what kind of rf analyzer do you have? is it some major professional piece of equipment? is there anything comparable out there for a hobbyist so to speak?
This is a professional RF Spectrum Analyzer made by HP and it costs more than an arm and a leg.
I am not aware of any similar equipment at a budget for the hobbyist.
 
Top