Author Topic: NRF24L01 working intermittently  (Read 408 times)

0 Members and 1 Guest are viewing this topic.

Offline pwnellTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: ca
NRF24L01 working intermittently
« on: December 26, 2024, 07:01:24 pm »
Hi,

I know this is a n00b mistake I have made, please be gentle.  I have designed my own PCB for a simple ESP 8266 based temperature sensor.  It has an ESP8266 DEV board, ADS1115 ADC board and an NRF24L01 2.4GHz board that plugs in to the PCB I designed - along with an DHT20 and LM35.  This design works with an NRF24L01 board I purchased 2 years ago from Amazon.  It does NOT work with a similar board I purchased a couple of weeks ago.  The boards are very similar, caps are different physical sizes and the chip has a different number, though the same model.

The idea is that every 30 seconds I transmit the temperature and humidity to another device that listens using a NRF24L01.  The problem is, the radio gets configured properly in my code (no error), but sending results in radio.write() failing (radio is an instance of RF24 in my code).  The issue is not code - the issue is my PCB design.  Here is the board:



If I raise the NRF24L01 board by about 1", it works.  If I plug it directly in to the socket, it fails.  If I plug it in to the socket and place a thick metal sheet between the NRF24L01 and the PCB, it works mostly.  If I connect the NRF24L01 using jumper wires and have it 20cm away from the PCB, it always works.

This tells me that either the VCC line I have running underneath the NRF24L01's antenna, or the ground plane I have on the bottom of the 2 layer PCB, is causing the issue with the antenna.

Since this works 100% reliable with the NRF24L01 off of the PCB using jumpers, I know it is not related to bypass capacitors.

Is it the VCC line, the ground plane or something else that is causing this?  How do I fix it?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10376
  • Country: nz
Re: NRF24L01 working intermittently
« Reply #1 on: December 26, 2024, 07:53:29 pm »
Since this works 100% reliable with the NRF24L01 off of the PCB using jumpers, I know it is not related to bypass capacitors.

With the NRF24L01 off the PCB the current flowing through the ground/VCC traces is less and switching noise is less, so less filtering is needed, without any bypass caps as soon as you add the module the ground/power quality gets worse and that maybe crashing or glitching things.
Currently you have no bypass caps. And adding them is one of the primary rules, "Thou must add decoupling caps on VCC to GND near power pins for any IC/Modules"
Add a 1uF or similar between the VCC/GND pins for both NRF module and ADS module. should be able to solder it between the two through hole pins.

Another issue I noticed is that you have the temp sensor powered by VIN on the ESP, pretty sure that VIN is a 5V input pin to power the ESP, not output.
If your temp sensor is working its probably getting powered from leakage current through diodes, not from an actual power rail.
(If VIN is also USB5V output then the temp sensor will only work correctly when USB is connected, but i think it's an input only.)

You don't seem to have any I2C pullups on your PCB, do any of your devices/modules that use I2C have their own i2c pullups? They are required for I2C to work correctly.

If it still doesn't work, try adding a 100ms startup delay in the ESP code, perhaps the NRF or ADS module is on the verge of not being ready for communication at boot and the ESP is trying to communicate with it a bit too soon and causing intermittent glitches at startup.
« Last Edit: December 26, 2024, 08:10:26 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline pwnellTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: ca
Re: NRF24L01 working intermittently
« Reply #2 on: December 26, 2024, 09:48:25 pm »
Thank you for the input. 

The DHL20 has internal pullup resistors as per the component's datasheet:

Quote
To avoid signal conflicts, the microprocessor (MCU) must only drive SDA and SCL at low level. An external pull-up
resistor (for example: 4.7kΩ) is required to pull the signal to a high level. The pull-up resistor has been included in
the I/O circuit of the DHT20 microprocessor

The ADS1115 also seems to have pullups on SCL and SDA.  They both function well.

Why do you say current is less when the NRF is off the PCB? Due to increased wire resistance?  Or reduced coupling to the ground plane?

Quote
"Thou must add decoupling caps on VCC to GND near power pins for any IC/Modules

:) I am very familiar with that dictum.  That said I did not follow it here (my bad, but I thought the two bypass caps on the board was sufficient) - when I did add a bypass cap during testing it did not seem to make a difference, though I tried a 10µF cap and not 1µF.  I added a 1µF tantalum capacitor directly to the pins 1 and 2 of the NRF module and it works now. That said, it is not 100% reliable, but works mostly.

Here are the two bypass caps that are standard on the board:

 

I measured them combined in parallel as 560nF, though I measured in circuit...  They are connected between VCC and GND.

The LM35 draws very little current and I am powering the device using USB.  I believe the protection diode between USB+ and VIn has enough current carrying capability to support this one device that draws about 50µA according to its datasheet.

Thanks again.
« Last Edit: December 26, 2024, 10:11:34 pm by pwnell »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10376
  • Country: nz
Re: NRF24L01 working intermittently
« Reply #3 on: December 26, 2024, 10:40:23 pm »
Why do you say current is less when the NRF is off the PCB? Due to increased wire resistance?  Or reduced coupling to the ground plane?

Because the NRF draws additional current on your PCB when connected and makes any powersupply issues worse.
So that maybe why it works "100% reliable with the NRF24L01 off of the PCB"



« Last Edit: December 26, 2024, 10:46:18 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline pwnellTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: ca
Re: NRF24L01 working intermittently
« Reply #4 on: December 26, 2024, 10:43:40 pm »
Maybe I did not explain myself well enough when I said "off of PCB". I meant: I used 2" jumper wires from the PIN header on the PCB to the NRF and then it works reliably.  So exactly the same electrical connections and power supply.  Just moved physically further from the PCB.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10376
  • Country: nz
Re: NRF24L01 working intermittently
« Reply #5 on: December 26, 2024, 10:45:54 pm »
ah, i thought it was on pin headers and unpluggable.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10376
  • Country: nz
Re: NRF24L01 working intermittently
« Reply #6 on: December 26, 2024, 10:46:29 pm »
Another thing you should check is that you're not having issues due to using 'special' GPIO.
The ESP8266 has some IO pins that behave in odd ways due to being 'special' Like you cannot hold them in some starts at power up. Or they don't have pullups etc..

https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

D3 and D4 look to stop it booting if held low at startup.
and D0 is high at startup
« Last Edit: December 26, 2024, 10:49:35 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 543
  • Country: ie
    • LinkedIn
Re: NRF24L01 working intermittently
« Reply #7 on: December 27, 2024, 12:54:36 pm »
Did you use ESP WiFi ? If yes, it can interfere with NRF
 

Offline pwnellTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: ca
Re: NRF24L01 working intermittently
« Reply #8 on: December 27, 2024, 04:07:34 pm »
I do but wifi and NRF are never on at the same time.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf