error while reading sensor modbus rtu rs485

Hi everyone, I´m trying to read the data from a solar sensor, the solarMems MASS60.
To do it I'm using an arduino Mega and the MAX485 conversor.

I save al the data in a vector that I call au16data[22] , the thing is that when I read for example the model, the reference, ot the elevation I obtain values that seems okey. But on the other hand when reading the radiation (au16data[8]) it always shows 0, and also reading the temperatura it shows randomly 3100 and 64917.

I cant understand why if I read some information right I have problem reading others.

This is the code I´m using:

#include <ModbusRtu.h>



// declaracion de variables




uint16_t au16data[22]; // array de datos
uint8_t u8state;  //estado de maquina
uint8_t u8query; //puntero query message


// fin declaracion de variables

// configuracion


/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  u8serno : serial port (use 0 for Serial)
 *  u8txenpin : 0 for RS-232 and USB-FTDI 
 *               or any pin number > 1 for RS-485
 */
 
Modbus master(0,1,10);  //cambio el del medio por1, estaba en 0


//fin configuracion


//this is a structure which contains a query to a slave device

modbus_t telegram;

//fin


unsigned long u32wait; //timer for the modbus


void setup() {

  pinMode(SSerialTxcontrol,OUTPUT);
  
 //telegram 0:read registers
 
 telegram.u8id=1;  //slave address

 telegram.u8fct=3; //function code (registers read)

 telegram.u16RegAdd=1; //start address in slave estaba a cero

 telegram.u16CoilsNo=22; //number of coils or registers to read

 telegram.au16reg=au16data; //pointer to a memory array in the Arduino



 master.begin(19200,SERIAL_8N1); //baud-rate at 19200
 master.setTimeOut(5000); //if there is no anwers roll over
 u32wait=millis()+1000;
 u8state=u8query=0;


 //comunicacion serie

 Serial.begin(19200);

}

void loop() {

  switch(u8state) {
    case 0:
      if(millis()>u32wait) u8state++; //wait state
      break;

    case 1:
      master.query(telegram);//send query only once
      u8state++;
      break;

    case 2:
      master.poll(); //check incoming messages 

      if (master.getState() == COM_IDLE) {
        u8state ++;
        u32wait=millis()+1000;}
        break;

    case 3:
      u8state=0;

      Serial.print("identificador  : ");
      Serial.println(au16data[0]);

      Serial.print("FOV : ");
      Serial.println(au16data[1]);
      
      Serial.print("MODELO : ");
      Serial.println(au16data[2]);

      Serial.print("REF : ");
      Serial.println(au16data[3]);
      
      Serial.print("BIT ");
      Serial.println(au16data[4]);
      
      Serial.print("PARITY: ");
      Serial.println(au16data[5]);
      
      Serial.print("STOP : ");
      Serial.println(au16data[6]);
      
      Serial.print("ADITIONAL ");
      Serial.println(au16data[7]);

      Serial.print("RAD ");
      Serial.println(au16data[8]);
      
      Serial.print("TEMP ");
      Serial.println(au16data[9]);
      
      Serial.print("AZ : ");
      Serial.println(au16data[14]);
      
      Serial.print("ELEV : ");
      Serial.println(au16data[15]);

      Serial.print("ACEL Z");
      Serial.println(au16data[22]);
      
      

      
      Serial.println("_____________________");
      delay(2000);


      break;



  }






}

I attach some other information, as the wiring, datasheets or the values from the sensor I read.

Thank you very much, I hope someone can help me.

MASS_Technical_Specifications.pdf (631 KB)

What values did you expect for the temperature? These might make sense if the datasheet specifies the wrong scale. If the scale is 0.1°C the values would range from -6.1°C to about 3°C. If you reside on the southern hemisphere these might be realistic values.

That is not the case, the temperature should be around 25 so I don´t Know what is the problem.

Thank you.

Did you check on the display that the temperature sensor is working correctly?

if use the original software using a rs485-usb to the laptop, everything works fine, and I receive very data okey.

But when reading it with the arduino the radiation is always 0 and the temperature does that strange thing swaping from 310 to 64917 continously.

You are waiting for the communications to become idle, by the look of the code, rather than for
all the data to have arrived - perhaps the device sends the data with gaps and you end up reading
your data before its been fully populated?

But I'm only guessing what COM_IDLE means... Perhaps there is some way to tell if all the data
you asked for actually came back?

You don't check the result code of master.poll() (may return a ModBus exception) and you also don't check the error code that may be set (master.getLastError(), for example in the case of a timeout). Although it would be quite special that the rest of the information is sent correctly while just in these two values there is always an error. But checking for error conditions may lead you to the actual cause of the problem.