Temperature probe offset

Hi all.
I use a USB temperature and RH logger that feeds into Node Red. I managed to get as far as getting data but I'm in a pickle over the temperature probe: using the Buffer-parser, I managed to extract the proper message (unsigned 16 bit), and scale it to the proper decimal. But the value requires an offset of 200 and I can't for the life of me figure out how to do that (i.e. 206.5 is 6.5). Suggestions anyone ?

[{"id":"7f7ee85c.310b28","type":"debug","z":"3e29523c.f2b2be","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":660,"wires":[]},{"id":"2f0aa780.499638","type":"buffer-parser","z":"3e29523c.f2b2be","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16le","name":"Temp","offset":1,"length":-1,"offsetbit":0,"scale":"0.1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":150,"y":480,"wires":[["abfdb48d.ee6fb8","e8373125.9d18d","7f7ee85c.310b28"]]},{"id":"9678038a.6fed9","type":"function","z":"3e29523c.f2b2be","name":"Sort Temp","func":"if (msg.payload[0] == 0x3)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":150,"y":400,"wires":[["2f0aa780.499638"]]},{"id":"9d327960.37e128","type":"HIDdevice","z":"3e29523c.f2b2be","connection":"ed0429ef.63b02","name":"ELUSBRT","x":130,"y":320,"wires":[["d2aaee82.b2e62","9678038a.6fed9"],[]]},{"id":"ed0429ef.63b02","type":"HIDConfig","vid":"0x1781","pid":"0x0EC4","name":"USBELRT"}]

You Don't say if it is a number or string. You should be able to parseFloat() and then simply minus 200.
e.g.

[{"id":"7f5869b8.a15148","type":"function","z":"b779de97.b1b46","name":"","func":"msg.payload = parseFloat(msg.payload) - 200;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":4880,"wires":[["3a65d71b.c994d"]]},{"id":"27002dec.65cfa2","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"206.5","payloadType":"str","x":80,"y":4860,"wires":[["7f5869b8.a15148"]]},{"id":"1fbf1bc8.3aee04","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"206.5","payloadType":"num","x":90,"y":4900,"wires":[["7f5869b8.a15148"]]},{"id":"3a65d71b.c994d","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":480,"y":4880,"wires":[]}]

I am dumbfounded by the stupidity of my own question... Thanks for indulging me with an actual, serious answer, it hurts just a bit less :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.