Using NRF24l01 for 2 way communication using two arduino megas

I am sure i got the wiring correct for nrf 24l01 and the installed the tmrh20/nrf24 library correctly. But i couldnt communicate with them. Transmitter and Receiver code is attached along with the printDetails from the transmitter Serial Monitor. I dont know the cause for this???

sketch_dec03a.ino (1.97 KB)

sketch_dec03b.ino (2.7 KB)

Untitled.png

Image from Original Post so we don't have to download it. See this Image Guide

Untitled.png

...R

I had hoped your image would have been a wiring schematic.

Have a look at this Simple nRF24L01+ Tutorial but NOTE that on a Mega the pins MOSI MISO and SCK are in a different place.

...R

PS. for the future please don't post pictures of text. Just copy and past the text and place it inside code tags with code button <>

The output shows that the NRF24L01+ SPI communication is not working.

Bad wiring, wiring / software mismatch, ...

MISO 50
MOSI 51
SCK 52
CE 7
CS 8

this is the pin confguration i used

Receiver
STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN

I get this on my receiver serial moniter . But when i remove any cable from wiring it suddenlt print some dump values.What s wrong ???? I did the wiring perfectly fine.

This is the serial moniter output in transmitter

Transmitter
STATUS		 = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1	 = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5	 = 0x00 0x00 0x00 0x00
TX_ADDR		 = 0x0000000000
RX_PW_P0-6	 = 0x00 0x80 0x00 0x80 0x00 0x80
EN_AA		 = 0x00
EN_RXADDR	 = 0x7f
RF_CH		 = 0xff
RF_SETUP	 = 0xff
CONFIG		 = 0xff
DYNPD/FEATURE	 = 0xff 0xff
Data Rate	 = 1MBPS
Model		 = nRF24L01
CRC Length	 = Disabled
PA Power	 = PA_MIN

receiver Code

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


//RF24 object (ce pin,cs pin)
RF24 radio(7,8);
byte addresses[][6] = {"1Node","2Node"};


void setup() {
  Serial.begin(115200);
  Serial.println("Receiver");
  
  radio.begin();
  printf_begin();
  radio.printDetails();
  radio.setChannel(110);

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_MIN);
  
  // Open a writing and reading pipe
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);

  radio.startListening();
}

void loop() {
  unsigned char data;


if (radio.available())  {
  radio.read(&data,sizeof(char));
  }

radio.stopListening();
data++;
radio.write(&data,sizeof(char));

radio.startListening();
Serial.println(data);

} // Loop

Transmitter Code

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



//RF24 object (ce pin,cs pin)
RF24 radio(7,8);
byte addresses[][6] = {"1Node","2Node"};


void setup() {
  Serial.begin(115200);
  Serial.println("Transmitter");
  
  radio.begin();
    printf_begin();
  radio.printDetails();
  radio.setChannel(110);

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_MIN);
  
  // Open a writing and reading pipe
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);

    randomSeed(analogRead(A0));
}

void loop() {
  unsigned char data = random(0,254);
  radio.stopListening();

if (!radio.write(&data,sizeof(unsigned char)))  {
  Serial.println("heeeee");
  }

radio.startListening();
unsigned long waittime = millis();

/****************** Pong Back Role ***************************/

  if ( millis()-waittime>200 )
  {
Serial.println("timeout");
return;
 }

unsigned char dataRx;
radio.read(&dataRx,sizeof(unsigned char));
Serial.print(data);
Serial.print("   ");
Serial.print(dataRx);
Serial.print("\n");
delay(1000);



} // Loop

Don't double post. I have suggested to the Moderator to merge this with your other Thread on the same project

...R

Have you set pin 53 as OUTPUT? (Necessary to make the Arduino act as SPI master)

...R

I tried that too . I tried again with the gettingStarted example in the library example but no progress same results again and again

mahen6513:
I tried that too . I tried again with the gettingStarted example in the library example but no progress same results again and again

Have you tried the examples in my tutorial. They do work and if you have problems it makes it easier for me to help.

If you try them and they don't work for you then please post the programs that you have uploaded to your Megas.

...R

I found the solution. I used the adapters for the nrf24l01 and i powered them with 3.3 V. Then i powered it with 5V and tested with getting started example and it just worked fine (I think there is something wrong with the code i have uploaded because i tested it with 5V supply previously). By the way thanks for your advices. They were very helpful to a beginner like me

Thanks for the update. Glad you have solution.

...R

mahen6513:
Then i powered it with 5V and tested

What's the manufacturer's specifications for nrf24L01+ voltage supply range?