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.
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.
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.
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 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.
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 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...
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.