Problem with NRF24L01 and Arduino DUE

Hi to everybody.
I am here to ask help for my little project.
I am trying to send a structure package (that contain only a integer and a float) from an arduino due and a mega.

I am using this library (i think it is the newest one):https://github.com/TMRh20/RF24

The problem is that the arduino due send the package to the Mega but only the first vale is usable (only the integer).

Example:

Arduino 2 send this values: ID=67
Temperature=8.0

Arduino Mega recive values: ID=67
Temperature=0.0;

i can’t undertand the reason.
I also tryed with 2 arduino mega at the both side (sender and reciever)and it works fine!

I attach the code of the sender (Nuovo_Volo.ino)

#include <RF24.h>
#include <SPI.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>


typedef struct     //prototipo pachetto contentente i dati in arrivo dal velivolo
{
  int id=0;
  float temperature = 0.0;  
}info_pack;

info_pack out_data;

RF24 radio(7,9);

const uint64_t pipe = 0xE8E8F0F0E1LL;

LiquidCrystal_I2C lcd(0x3F,16,2);

void setup() {
  Serial.begin(9600);
  lcd.init(); 
  lcd.backlight();
  radio.begin();
  radio.openWritingPipe(pipe);
  delay(100);
  out_data.id=67;
  out_data.temperature=8.0;
}

void loop() {

    radio.write(&out_data,sizeof(out_data));
    delay(100);
  
}

and the receiver (Nuovo_Terra.ino)

#include <RF24.h>
#include <SPI.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

typedef struct     //prototipo pachetto contentente i dati in arrivo dal velivolo
{
  int id=0;
  float temperature = 0.0;  
}info_pack;

info_pack in_data;

RF24 radio(7,9);

const uint64_t pipe = 0xE8E8F0F0E1LL;

LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {
  Serial.begin(9600);
  lcd.init();                      // initialize the lcd  
  lcd.backlight();
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}

void loop() {
 if (radio.available()){
    radio.read(&in_data, sizeof(in_data));
    Serial.println(in_data.id);   
    Serial.println(in_data.temperature);
    delay(100);
 }

}

Note: the lcd crystal is only initialized but not used

Someone know where is the problem?

Thank you

I am not familiar with the DUE. Is there a possibility that its data sizes are not the same as the Mega. Check how many bytes are in the struct in each device. The nRF24 just sends and receives bytes.

...R Simple nRF24L01+ Tutorial

Robin2: I am not familiar with the DUE. Is there a possibility that its data sizes are not the same as the Mega. Check how many bytes are in the struct in each device. The nRF24 just sends and receives bytes.

...R Simple nRF24L01+ Tutorial

Thank you for your answer!

I tried to check the size of the struct with the "sizeof" instrucion.

Tha strange fact is that the struct on the receiver (mega) is of 6 Byte and it isright (2 byte for the integer and 4 for the float). But on the sender (DUE) the same struct have 8 byte of dimension...

I dont know why

Most Arduino boards have a 2 byte int. The Due is a 4 byte int. Most Arduino boards, the double is 4 bytes. The Due is 8 bytes.

Can you send the numbers as human readable text?

That would avoid the incompatibility of datatypes at the expense of a slightly longer message.

...R

SurferTim: Most Arduino boards have a 2 byte int. The Due is a 4 byte int. Most Arduino boards, the double is 4 bytes. The Due is 8 bytes.

Thank you for your help.

Now the code works! In the sender code(due) i use the integer type(4 byte for arduino due). In the receiver code (mega) i replaced the integer type with long type(4 byte on mega)

so it works ! The problem was the size of the payload that was different from Due to Mega.

Thank you again!