Go Down

Topic: NRF24L01 works with UNO but not MEGA (Read 58 times) previous topic - next topic


May 15, 2019, 08:50 pm Last Edit: May 16, 2019, 06:17 pm by neeev
So I followed this tutorial to get two UNOs transmitting data to eachother. This works perfectly fine with both UNOs.

However I want to set up a MEGA 2560 to work as a receiver instead of one of the UNOs. I know my UNO transmitter is working correctly because when using another UNO as a receiver it works fine.
For my PIN layout on my MEGA, I have:

nRF24L01+        MEGA

MISO                 ICSP1
MOSI                 ICSP4
SCK                   ICSP3
VCC                   3.3V
GND                   GND
CSN                   53
CE                     49

My code which for the MEGA is here, and is only slightly modified from the working UNO receiver code with CE pin changed and CSN pin changed:

Code: [Select]

// SimpleRx - the slave or the receiver

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

#define CE_PIN 49
#define CSN_PIN 53

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

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


void setup() {


    Serial.println("SimpleRx Starting");
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);


void loop() {


void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    Serial.println("radio unavailable");

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        newData = false;

Finally, when running the checkConnection code on the thread mentioned above (post #29) for the UNO working as a receiver I have the following data (shown in the attachment work.PNG).

When running the same code with the pins changed to correspond to where they go on the MEGA I have this, shown in the attachment nowork.png

If I make PIN 9 to CE and PIN 10 to CSN it also doesn't work.

Not working means that the radio.available() function in the code always returns false, and I cannot get any data reading.


May 15, 2019, 09:10 pm Last Edit: May 15, 2019, 09:12 pm by Robin2
I have a Mega on the desk beside me that is working with my Tutorial code.

I'm not familiar with the ICSP pins but according to the SPI library documentation your connections are correct.

Treble check your connections. Quadruple check your connections - I still get them wrong quite often, especially mixing up CE and CSN.

If the wiring is correct a common cause of failure is an inadequate 3.3v power supply. My Genuine Mega provides enough 3,3v current but my Mega clones do not.

Have you tried on an Uno the nRF24 that is attached to the Mega - just in case the nRF24 is faulty.

Please don't post pictures of text - just copy and paste the text. If the pictures are NOT text then please make them visible in your Post so we don't have to download them. See this  Simple Image Guide

Two or three hours spent thinking and reading documentation solves most programming problems.


May 16, 2019, 06:12 pm Last Edit: May 16, 2019, 06:28 pm by neeev
Hm... I beleive the pins are alright.
I've attached a picture that attempt at showing the pinouts (sorry about how bad it is).
Some of my wires change color halfway thru, but as the picture shows the purple is MISO, black is SCK, and white is MOSI.

For power I have brown/ orange into GND, and red/ yellow in 3.3V.

What do you think could be the issue?

For my working UNO receiver I have the same setup with MISO in the top left for ICSP, SCK right below that, and MOSI on SCK's right (basically like I have setup in the MEGA) and it works...

Thanks in advance!

So I switched the transceiver, (from the working receiving uno to nonworking mega) and using the same pin layout described above I get the really fast scrolling with the radio unavailable and then very rarely a working signal for one line...

I'm not sure what's causing this.

Code: [Select]
o unavailable
radio unavailable
radio unavailable
radio unavailable
radio unavailable
Data received Message 9
radio unavailable
radio unavailable
radio unavailable
radio unavailable


Okay, so with my edit it actually works. When it wasn't working I added a bunch of radio unavailable print-lines which I think threw it off. To get there I made sure that my ICSP pins where in correctly, my CSN and CE pins where correctly defined in code and that my GND and 3.3V where in correctly too

Go Up