NRF24L01+ not working on Leonardo

I'm trying to set up a connection between NRF24L01+ modules, with a Nano transmitting and a Leonardo on the receiving side. I have been following the Simple nRF24L01+ 2.4GHz transceiver demo, I've wired everything up according to the first post, and I'm trying the code on reply #30 as suggested. The problem I'm having is that there is absolutely no serial monitor output given.

I have checked all my connections 4 times, and individually checked every single wire connection to make sure it's not a hardware problem. I even swapped out the module for another one that I know is working and there still isn't anything printed in the serial monitor. I've also tried to use a capacitor to make sure the voltage is steady. I also tried to move the MOSI, SCK and MISO pins to the ones on the ICSP header instead but still no serial monitor output.

However when I tried this exact arrangement on a Uno, it worked exactly as shown in the guide and I was able to get a serial monitor output.

Is there some extra code I need to put in that I don't know about for the Leonardo? I also tried this on my Pro Micro, after looking up the SPI pins and making sure everything is wired up properly - still absolutely no serial monitor output.

Note: I don't have any error messages to provide because the serial monitor is literally blank and absolutely nothing is printing, including the Serial.println() lines.

Pins 11/12/13 on the Leonardo are not the SPI pins; you'll need to use the pins on the 6-pin header.

The Leonardo has a habit of changing its com port whenever it reboots , so you need to check for this on the ports menu , that could be why you have no print .

At the start of your sketch it’s worth a short print to check that side is ok
( I print “go!”) , helps to spot problems .

Welcome! Post an annotated schematic showing exactly how you have wired this. Be sure to show ALL power connections and power sources.

using a NRF24L01 with a Leonardo I used the following connections

//  Leonardo > NRF24L01 transmitter test using a text string

// Leonardo connections 
// 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

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

#define CE_PIN 9
#define CSN_PIN 10

bool radioNumber = 0;
RF24 radio(CE_PIN, CSN_PIN);

byte addresses[][6] = { "1Node", "2Node" };

void setup() {
  Serial.begin(115200);
  delay(2000);
  Serial.println("\n\nLeonardo > NRF24L01 transmit text");
  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Transmitter NF24 connected to SPI");
  else Serial.println("NF24 is NOT connected to SPI");

the ICSP pins are
image

when run serial monitor displays

Leonardo > NRF24L01 transmit text
Transmitter NF24 connected to SPI
transmit text 0
transmit text 1
transmit text 2
transmit text 3
transmit text 4
transmit text 5

I am in no hurry, I will check back in a day or two to see if the needed information has been posted.

Sorry for the delay, I was quite busy this week. Here is the photo of all the pin connections - it's connected to 3.3V, CE and CSN pins are 9 and 10 respectively, and I connected the MISO, SCK and MOSI pins to their respective pins on the ICSP header.

I'm powering the board using a USB cable, not a battery pack. This exact configuration of wiring and code worked on my UNO board, when it was connected to the same port on my PC.

I'm trying the code from post #30 of Robin2's RF24 demo but I'm still not getting anything from the serial monitor.
image

even if the SPI<>NRF24 connection fails code such as

  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Transmitter NF24 connected to SPI");
  else Serial.println("NF24 is NOT connected to SPI");

should still display some information

horace, I tried your code with my configuration (SPI pins connected to the ICSP header) and it looks like it did kind of work on my Leonardo:

image

I got the first two lines of output but I did not see any of the "transmit text 0" lines.

the code of post 5 was just to test if the SPI connection was working
and from post 9 it looks like your Leonardo is communicating with the NRF24 OK

I should have posted the complete program, e.g.

//  Leonardo > NRF24L01 transmitter test using a text string

// RP2040 connections
// RP2040 SPIO_SCK pin GP18 goes to NRF24L10_pin SCK
// RP2040 SPIO_RX pin GP16 goes to NRF24L10_pin MISO
// RP2040 SPIO_TX pin GP19 goes to NRF24L10_pin MOSI
// RP2040 pin SPIO_CSn GP17 to NRF24L10 CSN
// RP2040 pin GP20 to NRF24L10 CE
// RP2040 GND and 3.3V to NRF24L10  GND and VCC

// Leonardo connections 
// 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

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

#define CE_PIN 9
#define CSN_PIN 10

bool radioNumber = 0;
RF24 radio(CE_PIN, CSN_PIN);

byte addresses[][6] = { "1Node", "2Node" };

void setup() {
  Serial.begin(115200);
  delay(2000);
  Serial.println("\n\nLeonardo > NRF24L01 transmit text");
  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Transmitter NF24 connected to SPI");
  else Serial.println("NF24 is NOT connected to SPI");
  radio.setChannel(125);
  radio.setPALevel(RF24_PA_MIN);
  radio.powerUp();
  radio.setDataRate(RF24_1MBPS);
  //radio.setDataRate(RF24_250KBPS);
  if (radioNumber) {
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1, addresses[0]);
  } else {
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1, addresses[1]);
  }
  radio.stopListening();
  //radio.setPayloadSize(sizeof(Struct1));
}

// loop transmiting data packet
void loop() {
  static char testString[10] = "text 0";
  radio.write(testString, sizeof(testString));
  Serial.print("transmit ");
  Serial.println(testString);
  delay(1000);
  testString[5]++;
}

the receiver (running on an ESP32)

//  ESP32 > NRF24L01 receiver test using a text string

// UNO/Nano connections
// arduino SCK pin 11 goes to NRF24L10_pin MOSI
// arduino MISO pin 12 goes to NRF24L10_pin MI
// arduino MOSI pin 13 goes to NRF24L10_pin SCK
// NRF24L10 CE to arduino pin 9
// NRF24L10 CSN to arduino pin10

// ESP32 connections
// ESP32 SCK pin GPIO18 goes to NRF24L10_pin SCK
// ESP32 MISO pin GPIO19 goes to NRF24L10_pin MI
// ESP32 MOSI pin GPIO23 goes to NRF24L10_pin MO
// NRF24L10 CE to ESP32 pin GPIO4
// NRF24L10 CSN to ESP32 pin GPIO 5



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

#define CE_PIN 4
#define CSN_PIN 5

bool radioNumber = 1;
const uint8_t pipes[][6] = { "1Node", "2Node" };

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10];  // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("ESP32 > NRF24L01 Receive text");
  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Receiver NF24 connected to SPI");
  else {
    Serial.println("NF24 is NOT connected to SPI");
    while (1)
      ;
  }
  radio.setChannel(125);
  radio.setDataRate(RF24_1MBPS);
  //radio.setDataRate(RF24_250KBPS);
  radio.printDetails();
  if (!radioNumber) {
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1, pipes[1]);
  } else {
    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1, pipes[0]);
  }
  radio.startListening();
  // radio.setPayloadSize(sizeof(Struct1));
}

//=============

void loop() {
  if (radio.available()) {
    char testString[10] = "";
    radio.read(testString, sizeof(testString));
    Serial.print("Test string:      ");
    Serial.println(testString);
  }
}

displays

Nano > NRF24L01 Receive text
Receiver NF24 connected to SPI
SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0xe7e7e7e7e7
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x7d
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 0
Test string:      text T
Test string:      text U
Test string:      text V
Test string:      text W