arduino + nRF24L01+

hello there, i m working on a project which includes me to send data from one arduino to another through wireless transmission. so i was given the nRF24L0+ rf transceiver whith a antenna chip module from sparkfun.

For the sending side i m using the arduino pro mini, and the nRF24L01+ module. For the receiving side i m using the arduino mega and the nRF24L01+ module.

well the thing is i found some codes on this forum to do this transmission, but i do not know if im doing it right or not.

these are the codes:

the receiving side:

#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

void setup(){
  Serial.begin(9600);
  Mirf.init();
  Mirf.setRADDR((byte *)"clie1");
  Mirf.config();
  Mirf.payload = sizeof(int);
}

void loop(){
  //byte data[Mirf.payload];
  Mirf.setTADDR((byte *)"serv1");
  
  Mirf.send((byte *)"hello");
  
  while(Mirf.isSending()){
  }
  Serial.println("Finished sending");
  delay(10);
}

the receiving side:

#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

void setup(){
  Serial.begin(9600);
  Mirf.init();
  Mirf.setRADDR((byte *)"serv1");
  Mirf.config();
  Mirf.payload = sizeof(int);
}

void loop(){
  byte data[Mirf.payload];

  if(Mirf.dataReady()){
    
    do{
      Serial.println("Got packet");
    
      Mirf.getData(data);
      
      Serial.println(data[0]);
      
    }while(!Mirf.rxFifoEmpty());
  }
}

well the thing is, when i upload and run the programmes, i open the serial monitor and i do see wad i m supposed to see.

meaning for the sending side " finished sending " appears on the serial monitor. for the receiving side " got packet " appears on the serial monitor.

the data i m trying to send is " hello ". i dont see that appearing on the serial monitor. what am i missing here?

please do help me.

aslam...

Hi there,

Serial.println(data[0]);

I think you're only printing 1 byte of the received data.

so how do i rectify it. i am supposed to be seeing " hello " but instead i see "got packet " again and again... and it goes on forever.

so how do i rectify this?

thank you for ur response... much appreciated...

does anyone else have any solution to this?

is it cos of the:

Serial.println((* byte) data[0]);

please do help me out here... much appreciated...