TODO: review and fix the javascript nodered node, it looks like we have a signed/unsigned problem.
I only noticed because this days temperatures dropped below 0ºC
parseInt()<----yes im talking to you
Edit: i found out javascript is expecting us to add the "-0001" character for negative hex values (instead of translating the int16_t 2's complement "ffff" so we need to parse it ourselves)
https://stackoverflow.com/questions/13468474/javascript-convert-a-hex-signed-integer-to-a-javascript-value
msg.temperatura = parseInt(msg.temperatura, 16);
if ((msg.temperatura & 0x8000) > 0) {
msg.temperatura = msg.temperatura - 0x10000;
}
msg.temperatura=msg.temperatura/100;
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.