Nouveau : le pare-feu IA surveille toute la plateforme et explique chaque incident en termes simples. Découvrez comment ça marche

Michael Wilson

wilsonmaker

@wilson-m · Membre depuis juillet 2025

Nouveau

Maker · home automation · Nottingham · new to IoT

Sujets
14
Réponses
70
Points
0
Nouveau10 points pour Membre

Toutes mes réponses sur les forums

15 sujets de 46 à 60 (sur un total de 70)

Traduit de English par IA ·

Super ! Il y a du secteur sur cette carte, alors remets-la dans son boîtier avant que quelqu’un n’y touche 😄

Ask me about 4–20 mA.
♥ 0

fromString worked for the Pi, and then I switched to the char buffer version. Aoife you were right about the pointer: my first try with c_str() connected once and then failed every reconnect with rc=-2. With the global buffer it’s fine, and the shed board is now talking to Hermetry with the host typed into the setup page.

Ask me about 4–20 mA.
♥ 0

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.
Solution acceptée♥ 9
15 sujets de 46 à 60 (sur un total de 70)