nRF24L01 receiving a different number?

I currently have two Arduino Micros connected to nRF25L01 modules. The receiver spits out the number 255 while I'm trying to send 1023 (The number sent through the transmitter is connected to a pot, but I've left the pot at the max rotation.).

Here my wiring & code:

Transmitter:
Wiring
RF24 Arduino
Gnd Gnd
VCC 3v
CE 9
CSN 10
SCK 13
MOSI 11
MISO 12
IRQ 2

Pot A0

Code:

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

int val;

void setup () {
  Serial.begin(9600);

  Mirf.csnPin = 10;
  Mirf.cePin = 9;
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.payload = sizeof(int);
  Mirf.config();
  Mirf.setTADDR((byte *)"roarm");

  while (!Serial);
  
  Serial.println("Starting Transmitter");
}

void loop () {
  val = analogRead(0);

  Mirf.send((byte *)&val);

  while (Mirf.isSending()) {
    Serial.println(val);
  }
}

Receiver:
Wiring:
RF24 Arduino
Gnd Gnd
VCC 3v
CE 9
CSN 10
SCK 13
MOSI 11
MISO 12
IRQ 2

Code:

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup () {
  // Start Serial stream
  Serial. begin(9600);

  // Setup Mirf
  Mirf.csnPin = 10;
  Mirf.cePin = 9;
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.payload = sizeof(int);
  Mirf.config();
  Mirf.setRADDR((byte *)"roarm");
  
  // Checks to see if Serial stream is open. If not, do nothing.
  while(!Serial);
  
  Serial.print("Starting Receiver");
}

 void loop () {
  byte data[Mirf.payload]; //data[0]
  
  if (!Mirf.isSending() && Mirf.dataReady()) {
    Mirf.getData(data);
    
    Serial.println(data[0]);
  } else {
    Serial.println("No data is being received.");
  }
 }

It does seem to be sending as the code in the while isSending loop is running and the code in the if dataReady loop is receiving but the receiver shows in the serial stream 255, while the transmitter is showing 1023. Did I do something wrong?

What happen when you try to transmit 253, I am new in this but still 255 is 2^8 could be maximum no your variable or register can store so what if your no is less than this?

superhb:
I currently have two Arduino Micros connected to nRF25L01 modules. The receiver spits out the number 255 while I'm trying to send 1023

I don't know the MIRF library but my guess is that this line

Mirf.send((byte *)&val);

only sends one byte.

I am a C/C++ philistine so I would create

int val[0];

and later

val[0] = analogRead();

and

Mirf.send(val, sizeof(val)); // I may have the syntax wrong here - but you should get the idea

...R

Robin2:
I don't know the MIRF library but my guess is that this line

Mirf.send((byte *)&val);

only sends one byte.

I am a C/C++ philistine so I would create

int val[0];

and later

val[0] = analogRead();

and

Mirf.send(val, sizeof(val)); // I may have the syntax wrong here - but you should get the idea

...R

Hi, I tried out your suggestion (Except for the "Mirf.send" part as that is incorrect) but I still get the same thing... 255 coming out of the Receiver and 1023 out of the Transmitter Serial streams.

yatin:
What happen when you try to transmit 253, I am new in this but still 255 is 2^8 could be maximum no your variable or register can store so what if your no is less than this?

Tried this, but i still receive 255.

Just a quick question how do I tell if the nRF is working?