Need help with testing nrf24l01+

I'm writing code for an rc plane and using an arduino uno as the transmitter and a pro micro as the receiver on the plane, I connected an nrf24l01+ to the uno using a schematic i found online
and connected the pro micro like this, but I am using a 5V version, so I stepped the voltage down to about 3V with a voltage divider.
image

I tried to write my own code, tried to take code from the internet but nothing seems to work, this is some test code I ran, maybe one of you can point out why it wouldn't work. I checked that i connected everything correctly and both of the boards run any other code just fine. I'm starting to think that one or both of the nrf24l01+ are damaged.

Receiver code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
Servo ch;
const uint64_t pipeIn = 0xE9E8F0F0E1LL;
int val = 107.5;
RF24 radio(9, 10);
void setup() {
  radio.begin();
  radio.openReadingPipe(1, pipeIn);
  radio.startListening();
  ch.attach(2);
}
void recvData()
{
  while ( radio.available() ) 
  {
    radio.read(&val, sizeof(val));
    Serial.println(val);
  }
  if(radio.available() == false)
  {
    Serial.println("Radio unavailable");
  }
}
void loop() {
  recvData();
  ch.write(val);
}

Transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

const uint64_t pipeOut = 0xE9E8F0F0E1LL;
RF24 radio(9, 10);
int val = 0;
void setup()
{
  radio.begin();
  radio.openWritingPipe(pipeOut);
  radio.stopListening();
}
void loop() {
  val = map(analogRead(A1), 0, 1023, 35, 180);
  Serial.print(analogRead(A1));//doesnt print
  radio.write(&val, sizeof(val));
}

Welcome to the forum

Try the examples in this topic. They are known to work

Simple nRF24L01+ 2.4GHz transceiver demo

I don't see a voltage divider in your diagram. And more importantly, voltage dividers can't be used to reduce Vcc.

Assume you have a 1k/2k divider; the current will me severely limited and can't power the nRF.

Hi, @vilius20
Welcome to the forum.

Can you post schematics of both your circuits, do not use Fritzy pictures?
A image(s) of hand drawn schematics will be fine, please use component names and pin lables as well as you power supplies.

If you are using a potential divider to drop 5V to 3V3 supply for the NRF, that will not work as you have no voltage regulation.

Are you really using the NRF24l01 + units, the ones with antenna and power amplifier on the same PCB?

Can you please post some pictures of your project?

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

Hi @Vilius20,

The first observation is that your code shows that you have the CE pin of the NRF24l01 assigned to pin 9 of the Pro Micro. Yet your diagram shows that you have the CE pin of the NRF24l01 connected to pin 8 of the Pro Micro. This certainly prevents the NRF24l01 from working

The second observation the Vcc pin of the Pro Micro can be either 3.3V for an 8MHz version or 5v for a 16MHz version. Do you know which version you are using?
The NRF24l01 designed operating voltage range is between 1.9 - 3.6 volts. If you have a 16Mhz version of the Pro Micro this is outputting 5V on the Vcc pin you will destroy the NRF24l01.

A good explanation of how the NRF24l01 works together with some simple test code including some very useful troubleshooting tips can be seen at https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/

I've also found using the following settings within the Setup improved reliability considerably -

radio.setDataRate(RF24_2MBPS); // Set the speed of the transmission to the quickest available
radio.setChannel(124); // Use a channel unlikely to be used by Wifi, Microwave ovens etc
radio.setPALevel(RF24_PA_MAX); // Set radio Tx power to MAX

HTH?

Sorry, my bad I did have the CE connected to the 9th pin, but missed it when including the schematic. I do have the 5v version of the Pro Micro, but used one 2K and one 1K resistor in a voltage divider to step it down to about 3.01v which I confirmed with a mutimeter.

If this is for the 3V3 supply to the NRF are you measuring it while testing your project, what happens do you think when the NRF needs current to transmit, what will the potential divider currents and value be?

Some schematics please..

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

I switched out the voltage divider for a LD1086V33 regulator, but the code still didn't work. I also tried the code from here https://forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/405123I, but also no success. I have attached both of the circuits

Although your potential divider using a 2K connected to Vcc & 1K connected to the GND pin will provide a 3.01voltage source, it will not provide a current of up to 15mA max that the NRF24l01 requires to operate in a Tx mode.
Using Ohms law, your potential divider will only provide up to a max of 2.5mA

You would do better to use a 5v to 3.3v voltage regulator such as a Microchip TC1262-3.3VDB for example.

HTH?

I switched it out for a LD1086V33 regulator, still didn't work. I attached both of the circuits in the 8th post.

Have run the test programs shown in https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/ ??

Also, it would benefit the fitment of a capacitor to the transmitter 3.3v line as close to the NRF24l01 as suggested in the link above.

The first thing I would do is run the connection test code that is in post #30 of the thread that @UKHeliBob gave you in post #2.

I ran the test code on both of them the uno worked fine and displayed all the data while the Pro Micro doesn't print anything at all, the console just remains empty. Other code runs on the Pro Micro when I tested servos and motors. Why could this happen?

Which pins are you using on the Pro Micro ?

I am using these pins.
CSN-10
MOSI- 16
CE-9
SCK-15
MISO-14

I just discovered that the Pro Micro doesn't execute any code in the void setup other than pin mode. If I put the same code in the void loop the Pro Micro runs it and it showed me the data from the nRF and it looked good. How do i make it run code in the setup?

Which sketch are you basing this observation on as it seems extremely unlikely ?

@UKHeliBob, The test code @markd833 suggested to try. It will not print or execute any other code I tried in the void setup while if i put the exact same code in the void loop it works. The same code worked perfectly in the arduino uno. Is there any way to get around it so the code in the loop only runs once?

Leave the code in setup() and add delay(1000); after the printf.begin();

Does anything print then ?

@UKHeliBob it works, could this also be the reason why the actual code doesn't work? If so, then what do I do now? I want to first run the simple reciever/transmitter code you sent in message #2.