 # Bugs on device connector

Hi all, there is a problem on parser of negative temperature for MCF88 devices, I think is a sign issue on parser for MCF-LW12TERWP on negative temperature (and I suppose the same for MCF-LW12TER, MCF-LW12CO2, MCF-LW12VOC).

Instead to have negative temperature, the parsed temperature has high values (over 600°C).

This is an example:
044A716B2769FF89AE88018D726B277BFF85A58801CF736B2781FF85A3880164
04 -> type Temperature/Pressure/Humidity
First measure
4A716B27 -> date/time
69FF - > temperature -> LSB became FF69 -> SIGNED INTEGER if 32 bit is FFFFFF69 -> -151 hundreds of degrees -> -1,51°C
89 -> humidity
AE8801 -> pressure
Second measure
8D726B27 -> date/time
7BFF - > temperature -> LSB became FF7B -> SIGNED INTEGER if 32 bit is FFFFFF7B -> -133 hundreds of degrees -> -1,33°C
85 -> humidity
A58801 -> pressure
Third measure
CF736B27 -> date/time
81FF - > temperature -> LSB became FF81 -> SIGNED INTEGER if 32 bit is FFFFFF81 -> -127 hundreds of degrees -> -1,27°C
85 -> humidity
A38801 -> pressure
64 -> battery

I think there is a wrong handling of 2 bytes signed integer value.

This is about a bug, so I’m going to open support for you.
I’ll be in touch soon.

See you! Solved, many thanks!

1 Like

Hello,

I don’t know if it’s piece of code could help you a bit but here this an example of how convert hex values to decimal and manage also negative number.

``````  const hexAccX = `0x\${payload.substring(48,52)}`;

// Convert the hex values into decimal and apply the calculations

const altitude = Number(hexAlt) / 100;

x = parseInt( hexAccX, 16);
if (( x & 0x8000) > 0) {
x =  x - 0x10000;
}
const accelerometerX = Number(x) / 1;

y = parseInt( hexAccY, 16);
if (( y & 0x8000) > 0) {
y =  y - 0x10000;
}
const accelerometerY = Number(y) / 1;

z = parseInt( hexAccZ, 16);
if (( z & 0x8000) > 0) {
z =  z - 0x10000;
}
const accelerometerZ = Number(z) / 100;``````
1 Like