Hello, I'm trying to interpret the data received from the NPK sensor connected to a Modbus RS485.
Looking at the vendor's datasheet, the data received should have the following format byte.
here is a printout of my received message from sensor:
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
---VV---
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
---VV---
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
---VV---
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
---VV---
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
---VV---
|1|3|4|3|E8|1|3F|3B|C3|FF|FF|FF-----
I can't find where is my temperature information, from my other post in this forum I understood the data info I need is on bytes 4 and 5
BUT:
base on this info if 4 and 5 hold the temp I need it to mean bytes 3E8 = 100/2 = 10degrees (wrong temp)
if bytes 6 and 7 hold temp information => 13F = 319 /2 31.2 deg... my be correct
How do I combine these 2 bytes [6,7] and return the information I need on my code below?
here is my function code:
byte temperature(){
Serial.println("---VV---");
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(20);
Serial.flush();
if(mod.write(msgt,sizeof(msgt))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<12;i++){
values[i] = mod.read();
Serial.print("|");
Serial.print(values[i],HEX);
}
Serial.println("-----");
Serial.flush();
delay(3000);
}
return values[6,7]; //but wrong
}


