Issues with Leonardo and NRF24L01

Hi!
I’m currently trying to make two leonardo’s communicate with each other using the RF24L01 modules. I’ve wired them according to this:

I’ve changed the GND pin and added a 10uF bypass capacitor in.

Here is what my version looks like (sorry for the bad photo).

Here is my code for the tx:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  Serial.println("MSG SENT");
  delay(1000);
}

and for the rx:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  } 
}

I’ve tried numerous variations of this code, and different CE/CSN pins and nothing I can do seems to make it work.
I’ve tried two different modules since I was concerned I may have wrecked the first two since I accidentally hooked them up to 5v.

On the console I get my confirmation of “MSG SENT” but nothing on the Rx side.

Any help is greatly appreciated! :slight_smile:

No access to the Leonardo's documentation at this moment. But from memory, the SPI pins are not at the same location as on an Uno.

Try the 6 pin header at the edge of the board for the SPI signals.

Have a look at this Simple nRF24L01+ Tutorial.

I have had it working on my Leonardo, but it was some time ago. I don't think there was anything special about it apart from getting the Mosi Miso and SCK connections correct.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

...R

Thanks for the reply,
I've double checked my connections (changed the CE and CSN over to what you have in your tutorial) changed it over to your code.

When I run it now I get a
"Data Sent Message 0 Tx Failed"
Any troubleshooting tips for this?

Again, I really appreciate the help! :smiley:

mjfanatic:
Any troubleshooting tips for this?

Have your tried the connection test program in my Tutorial on both of your Arduinos? If that does not work, nothing else will.

My Leonardo is now part of another project so I can't test with it on your behalf.

Have you any Arduinos other than the two Leonardos?

...R