Novedad: el cortafuegos de IA supervisa toda la plataforma y explica cada incidente con palabras sencillas. Vea cómo funciona

Reply To: Negative temperatures from my LoRa node show up as 65486 in Hermetry

Ha, I had exactly this with my greenhouse sensor last January, so I can answer for once!

The Arduino stores int as two’s complement. -0.5 °C times 100 is -50, and -50 in 16 bits is 0xFFCE. The top bit is the sign. Read as unsigned that’s 65486, times 0.01 gives your 654.86. Read as signed it’s -50, times 0.01 gives -0.5. Same bytes, the codec just has to know they’re signed.

So in your codec change the format from u16be to i16be, keep the scale. Add a test vector for a negative value so it never sneaks back:

{ "at": 0, "field": "temperature", "fmt": "i16be", "scale": 0.01, "unit": "°C" }

"tests": [
  { "name": "positive", "fport": 1, "hex": "0960", "expect": { "temperature": 24.0 } },
  { "name": "below zero", "fport": 1, "hex": "FFCE", "expect": { "temperature": -0.5 } }
]

On the Arduino side use int16_t instead of int, so it stays 2 bytes if you move to a 32-bit board. Then Check and Publish. The key name and unit stay the same, so it can go out as a new revision of the same codec. Reference: Write your own codec

Ask me about 4–20 mA.
Solución aceptada♥ 9