NRF24L01 works intermittently, some messages are lost

My question is NRF24L01 and it seems it's both specific to Arduino.

I'm using two nrf24l01 running on Arduino Micro. One sends messages once every 500ms, the other receives them. The issue is; about 2% of messages are dropped.

The transmitter has a "sent" counter that is augmented every time a message is sent. This counter is part of the message that is sent to the receiver.

The receiver also has a counter, it is augmented every time it detects new data that is available in the RX pipe and it displays this counter along with the message that is received from the transmitter (the number of sent messages)

This, these two numbers should be always the same but over time they tend to deviate and I'm noticing a loss of about 2% of messages where messages appear to be sent but not received.

I'm not sure how to troubleshoot this. When sending, I do check if the register has been emptied and I am not getting any errors there, on the sending side everything looks A-OK once the message is picked up.

I have a 50uF capacitor on the nrf24l01 AC. I also checked it with different nrf24l01's thinking maybe one of them is defective. The two devices are with centimeters of each other.

I implemented the following code for both tr as well as rx: GitHub - controllerstech/NRF24L01: How to Write NRF24L01 Library using the Datasheet

Note, the code above is for STM32, not Arduino specifically. I implemented it using STM32 first (both RX and TX) then I refactored the code to make it work on Arduino, I am getting the exact same result. It works, but intermittently.

Sending and receiving on Arduino works well when using the NRFLite library but I want to know why this is not working with the code I included.

Any ideas?

Thanks.

The problem may, of course, be in your code

Do you think that it might help if you posted it ?

It sounds like a code and power problem, post an annotated schematic showing how it is wired. Also post links to technical information on any additional information and the power sources.

For anyone who doesnt know what that is ...

Yes, I agree, definitely code issue as this is working with the NRFLite Arduino library. I posted the Github repo from where I got the code, that's basically what I am using although for Arduino I refactored it a bit for teh SPI communications and all. But, as I mentioned, Arduino or STM32, I am getting the same result.

I would guess your transmit code increments its counter on failed sends also,
and sometimes a transmission fails.

From my experience, the return code of write is rarely used.

Hi, @higgenkreuz_007

Separate them, you could be overloading their receivers.

Place them 1m apart.

Can you please post some images of your project?
So we can see your component layout.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I think I narrowed down the issue. I'm using a NRF24 mini as an SMD and the code is running on a device that I assembled on a custom PCB. If I load the same code to its breadboard equivalent, the one I based my PCB design on, it works and there's no dropped messages at all. The only difference between the two setups are:

Breadboard version (working):
Shunt capacitor: 10uF 50V electrolytic
Radio: NRF24L01

PCB version (not working, drops messages):
Shunt capacitor: 100uF 6.3V ceramic
Radio: NRF24L01 mini (smd version)

I have a couple of devices that I already soldered for the PCB version and they all have the exact same issue so it doesn't seem to be a soldering issue.

I 'm also thinking maybe the placement of the antenna is not ideal and there's some interference from nearby devices like the STM32 board.

This is the receiver running Arduino Micro

This are the top and bottoms of my PCB running the NRF24L01 mini with STM32 Bluepill

And this is the breadboard version, identical wiring, STM32 Bluepill:

Hi,
Thanks for the pictures.
You must keep the antennas of the NRF away from other conducting surfaces.
The top image is probably the best layout, the antenna on the NRF board has no wiring or conductive surfaces near it.

The third image down, is probably the worst for good operation, the antenna is amongst other components.

If you have anything close to the antenna, you will detune it and the performance will drop.

Thanks Tom.. :smiley: :+1: :coffee: :australia:

Hi Tom,

Thanks for your feedback. I agree, I think I didn't pay too much attention to the antenna placement when designing the PCB. Back to the drawing board I guess... :slight_smile:

Just to close this in case anybody else is facing a problem like this down the road, the issue WAS antenna placement. I removed the NRF24L01 mini from the PCB and placed it elsewhere with everything else remaining the same and the problem disappeared.

Thank you all for your help.

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