NRF24L01 configuration

Hello once again, I am trying to use an NRF24L01+pa+lnawith a Leonardo Arduino, but I cannot get the Arduino to detect it. My connections are:

VCC to 3.3V
GND to GND
CE to D9
SCN to D10
SCK to D13
MOSI to D11
MISO to D12

My code is:

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

#define CE_PIN   9
#define CSN_PIN 10

RF24 radio(CE_PIN, CSN_PIN);

void setup() {
  Serial.begin(9600);
  Serial.println("Checking NRF24L01 module connection...");
  
  // Initialize the radio module
  radio.begin();
}

void loop() {
  Serial.println("Waiting...");
  
  // Check NRF24L01 module connection
  if (!radio.begin()) {
    Serial.println("Failed to detect NRF24L01 module.");
  } else {
    Serial.println("Success! NRF24L01 module detected.");
  }

  // Your main code here
}

Any help would be beneficial, thanks

Are you sure that the Leonardo SPI pins are where you think they are and not just on the 6 pin ICSP header ?

I am aware that the pin locations on the Leonardo are different than Arduino's pins. But where would they be? Like I know that the sda and scl are D2 and D3, maybe D6 and D7?

The SPI pins are on the ICSP 6 pin connector

Note that the pin names have changed due to the "woke" generation of today
See https://docs.arduino.cc/learn/communication/spi/

So I only connect the SCK and GND pins? But the other pins are fine?

You need to connect MISO, MOSI and SCK as normal but you use the pins on the ICSP header as in the image instead of pins 11, 12 and 13

I used the Leonardo pinout to connect The Things UNO (which is based on the Leonardo) to connect a RFM95 LoRa module so

// Leonardo connections
// Leonardo ICSP SCK  pin 15  to RFM95 SCK
// Leonardo ICSP MISO pin 14  to RFM95 MISO
// Leonardo ICSP MOSI pin 16   to RFM95 MOSI
// Leonardo pin 2 to RFM95 SS
// Leonardo pin 3 to RFM95 Reset
// Leonardo pin 4 to RFM95 DIO0 
// Leonardo GND and 3.3V to RFM95

Try running the radio on an external power supply, the 3V3 on most Arduinos does not have enough to make it operate properly.

So I should connect the MISO, MOSI, SCK, VCC, GND on the ICSP header of the Leonardo to the NRF24L01?

Is that the ICSP header pins? Plus, isn't the D2 and D3 the SCL and SDA pins? Sorry, I'm new to this....

I have a voltage regulator, I'll try it

yes

my code does not use I2C so pins 2 and 3 work OK
try

#define CE_PIN   9
#define CSN_PIN 10

RF24 radio(CE_PIN, CSN_PIN);

if I change the RFM95 to

  // void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = 
  LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
  LoRa.setPins(9,10, 4);  // for Leonardo

it still works OK

Do i need an additional device?

I am using the RFM95 LoRa device to test the SPI connections

you are using a NRF24L10 - I think the following should work

// Leonardo ICSP SCK  pin 15 to NRF24L10_pin SCK
// Leonardo ICSP MISO pin 14 to NRF24L10_pin MISO
// Leonardo ICSP MOSI pin 16 to NRF24L10_pin MOSI
// Leonardo pin 10 to NRF24L10 CSN
// Leonardo pin 9  to NRF24L10 CE
// Leonardo GND and 3.3V to NRF24L10  GND and VCC

1 Like

That should work assuming it is not powered by the Arduino.

sorry for the late response, I tried to run it through a separate voltage regulator at 3.31V, with no success. I connected the MOSI, MISO, and SCK to ICSP pins, CE to D9, CSN to D10, and GND and VCC to the regulator

What type of regulator is it and where does it gets power from. A link to that and an annotated schematic would help a lot.

It is a DC voltage regulator module from Duinotech. I do not have a schematic sorry, but I just connected the +out and -out from the regulator to the VCC and GND of the device. Also, I connected it to a 9 volt battery, but I did configure it using a voltage sensor to 3.31V.

I do not think that will do it. A 9V battery is shaky at best.

When I was measuring the voltage, it seemed consistent, but I did not have any other battery source. I have the plug from the wall socket to power the Arduino, could I use that instead?