I know how to find temperature by dividing High Byte by two (-63 to 63°C with step 0.5)
I would to know how to use Low Byte (4 bits at left) : 0.0625° x Value… but should I add it to first Value (High byte) ???
Thanks
David
I know how to find temperature by dividing High Byte by two (-63 to 63°C with step 0.5)
I would to know how to use Low Byte (4 bits at left) : 0.0625° x Value… but should I add it to first Value (High byte) ???
Thanks
David
Forget the low byte
If you receive command E6, take the first data byte after the command and run it through this code:
function ParseTemperature(Value: Byte): Double;
begin
Result := Value;
if Result >= $80 then
Result := ($FF - Result + 1) * -1;
Result := Result / 2;
end;
Numbers prefixed by the dollar sign “$” are hexadecimal numbers.
The “Result > $80” condition is for negative temperatures
Temperature precision is 0.5°C
After many tests and some help, here is a JavaScript code, to calculate temperature with decimal :
// Function to calculate temperature with high precision
function TempCurrentCalculation(msg) {
// E6 (Transmit Temp) or EA (Sensor status)
switch (msg[4]) {
case 0xE6:
return msg[5] / 2 - Math.round(((4 - msg[6]) >> 5) * 0.0625 * 10) / 10
case 0xEA:
return msg[8] / 2 - Math.round(((4 - msg[9]) >> 5) * 0.0625 * 10) / 10
default:
console.error("ERROR with TempCalculation", msg)
return undefined
}
}
Hope this will help other coders.