nRF24L01 with arduino mega 2650

URGENTLY !! i’m facing a problem when connecting the nrf25l01 module with the arduino mega it doesn’t operate although i changed the SPI connections to be matching the arduino mega 2650 (MOSI,MISO,SCK). However when using the same code with arduino uno it operates fine. Can any one please tell me any idea how to fix this problem, the project is to be submitted in 8 hours from now !!
This is the code of the receiver: (the code is working fine)

// receiver's code
// arduino mega 2650
#include <avr/pgmspace.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(32, 30, 28, 26,24, 22);

/***********************************************************************
************* Set the Node Address *************************************
/***********************************************************************/

// These are the Octal addresses that will be assigned 
const uint16_t node_address_set[3] = { 00, 02, 05};

// 0 = Master
// 1-2 (02,05)   = Children of Master(00)

uint8_t NODE_ADDRESS = 0; //address from the array

RF24 radio(7,8);                              // CE & CSN pins to use (Using 8,7 on Mega)
RF24Network network(radio); 

uint16_t this_node;                           // Our node address

int smomkethreshold = 500;
int soundthreshold = 650;
int buzzer1=38;
int buzzer2=40;

const short max_active_nodes =3 ;            // Array of nodes we are aware of
uint16_t active_nodes[max_active_nodes];
short num_active_nodes = 0;
short next_ping_node_index = 0;


void handle_T(RF24NetworkHeader& header);
void handle_N(RF24NetworkHeader& header);
void add_node(uint16_t node);

void setup(){
  
  Serial.begin(9600);
  Serial.println("The Receiver is On");
  delay(100);
   lcd.begin(16, 4);
   lcd.setCursor(5,0);
   lcd.print("ZAB");
   lcd.print((char)223);
   lcd.setCursor(2,2);
   lcd.print("Because your");
   lcd.setCursor(0,3);
   lcd.print("Security Matters");
   delay(3000);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Node Readings: ");
   lcd.setCursor(0,1);
   lcd.print("Noise and Smoke");
   lcd.setCursor(0,2);
   lcd.print("Node 1: X,Y");
   lcd.setCursor(0,3);
   lcd.print("Node 2: A,B");
   delay(3000);
   lcd.clear();
   pinMode(buzzer1,OUTPUT);
   pinMode(buzzer2,OUTPUT);
  this_node = node_address_set[NODE_ADDRESS];            // Which node are we?
  SPI.begin();                                           // Bring up the RF network
  radio.begin();
  radio.setPALevel(RF24_PA_HIGH);
  network.begin(/*channel*/ 100, /*node address*/ this_node );
}

void loop(){
    
   network.update();   // Pump the network regularly
   while ( network.available() )  {                      // Is there anything ready for us?
     
    RF24NetworkHeader header;                            // If so, take a look at it
    network.peek(header);

    
      switch (header.type){                              // Dispatch the message to the correct handler.
        case 'T': handle_T(header); break;
        case 'N': handle_N(header); break;
        default:  //Serial.println("Failed To Receive");
                  /*lcd.setCursor(0,0);
                  lcd.print("Failed To Receive");
                  delay(1000);
                  lcd.clear();*/
                  network.read(header,0,0);
                  break;
      };
    }
}

void handle_T(RF24NetworkHeader& header){

  int data[2];                                                                      // The 'T' message is just a ulong, containing the time
  network.read(header,data,sizeof(data));
  if(header.from_node == 02)
  {
     Serial.print(F("X = "));
      Serial.print(data[0]);
      Serial.print(F(" Y = "));
      Serial.println(data[1]);
      /*lcd.setCursor(0,1);
      lcd.print("X= ");
      lcd.print(data[0]);
      lcd.print(" , Y= ");
      lcd.print(data[1]);
      delay(100);*/
    }
    else  // only two pipes, no other checks needed
    {
     /* lcd.setCursor(0,2);
      lcd.print("A= ");
      lcd.print(data[0]);
      lcd.print(" , B= ");
      lcd.print(data[1]);
      delay(100); */
     Serial.print(("A= "));
      Serial.print(data[0]);
      Serial.print((" B= "));
      Serial.println(data[1]);
      delay(1000);
    }
  

  if ( header.from_node != this_node || header.from_node > 00 )                                // If this message is from ourselves or the base, don't bother adding it to the active nodes.
    add_node(header.from_node);
}

void handle_N(RF24NetworkHeader& header)
{
  static uint16_t incoming_nodes[max_active_nodes];

  network.read(header,&incoming_nodes,sizeof(incoming_nodes));
      lcd.setCursor(0,3);
      lcd.print("Received from ");
      lcd.print(header.from_node);
 /*Serial.print("Received from");
 Serial.println(header.from_node);*/

  int i = 0;
  while ( i < max_active_nodes && incoming_nodes[i] > 00 )
    add_node(incoming_nodes[i++]);
}

void add_node(uint16_t node){
  
  short i = num_active_nodes;                                    // Do we already know about this node?
  while (i--)  {
    if ( active_nodes[i] == node )
        break;
  }
  
  if ( i == -1 && num_active_nodes < max_active_nodes ){         // If not, add it to the table
      active_nodes[num_active_nodes++] = node; 
     lcd.setCursor(0,3);
      lcd.print(node);
      lcd.print(" was added to active nodes");
      /*Serial.print(node);
      Serial.println(" was added to active nodes");*/
  }
}

I think the problem is the 3.3v on the mega. you need to add a capacitor at least 50uf+ maybe even pair it with a 0.1 capacitor.

When I use my nRF24L01+ on my Mega I connect to SCK, MOSI and MISO in the 6-pin ICSP header. That works on all Arduino boards.

I have not needed a capacitor on my Mega or Uno but one was essential on a stripboard project. I used 10µF.

...R

@sue dude , so i have to connect a capacitor in series with the nrf at 3.3v ?!

@robin2 i tried the ICSP headers and it didnot work also. i think the problem is in the arduino itself

Connect 10uF cap from 3.3V to Gnd (in parallel) close to the RF module pins as possible.

The capacitor is in parallel or across the GND and +3V3 pins and as close to the RF24 board as you can get. I found this interface board on eBay which also solves some problems.

Also, I'm using the same RF board on two Mega2560s successfully with the CE and CSN pins on 49 and 50 respectively. The default for the other three pins appears to be 51, 52, and 53. The SPI header may also work as suggested but I've never tried it.

The SPI header Is connected in parallel to 51, 52, 53.