Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point rounding error in status #142

Closed
tomkooij opened this issue Jan 15, 2023 · 2 comments
Closed

Floating point rounding error in status #142

tomkooij opened this issue Jan 15, 2023 · 2 comments
Labels
stale closed No reaction on issue for a long time

Comments

@tomkooij
Copy link
Contributor

Describe the bug
Zero not zero:
image

WPU 5G: Status values that are 0 and "float" (divide by 100) can be some small number instead of 0.
The correspoding statusvalue is 0x0000 datatype 0x92 (2 byte, divide by 100).
0000 is cast to float and divided by 100 and some floating point rounding error occurs.
Solution: round / limit floats to 2 decimal places. Other datatype 0x92 values are rounded to 2 decimal places.
(See screenshots)

Also in MQTT:

"CV pressure (Bar)":2.26,"Compressor current (A)":3.62,"Current e-element (A)":0.000489009,

Expected behaviour
0 is displayed as 0 or 0.00

Screenshots
image

Device information

  • Firmware version 2.4.4-beta6
  • Hardware revision non-cve 2
  • Type/model number Itho WPU 5G v37

This is a very minor issue. It's just my OCD. I might fix it sometime.

@tomkooij
Copy link
Contributor Author

tomkooij commented Mar 4, 2023

This is a "feature" of ArduinoJson...
https://arduinojson.org/v6/how-to/configure-the-serialization-of-floats/

Adding a round2() function as per the docs, would fix this.

@stale
Copy link

stale bot commented May 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale closed No reaction on issue for a long time label May 3, 2023
@stale stale bot closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale closed No reaction on issue for a long time
Projects
None yet
Development

No branches or pull requests

1 participant