Good evening,
I adapted the code below for negative temperatures
with this code :
code to copy :
let input = msg.payload[4];
var Sign = input.substring(5, 6); // to know if the temperature is \u003c 0
var Neg = 0; // digit to add at the start if temperature \u003c 0
var Temp = input.substring(5, 9);
var TempNeg = input.substring(6, 9); // we only take the relevant digits
// Handling negative temperatures
if (Sign == 8) {
var CreationTempNeg = Neg.toString() + TempNeg;
var NouvelleTempNeg = parseInt(CreationTempNeg, 16);
msg.payload = -1 * (NouvelleTempNeg / 10);
}
// Handling positive temperatures
if (Sign == 0) {
Temp = parseInt(Temp, 16);
msg.payload = Temp / 10;
}
return msg;
msg.payload[4] corresponds to entry no. 4 of the array ; the first being no. 0
This therefore corresponds to TEMP=0010
Here, the temperature is therefore \u003e 0
["20","26","Oregon TempHygro","2D6D","TEMP=0010","HUM=61","HSTATUS=0","BAT=LOW","\\r\\n"]