Comments (5)
This is not a bug, but is to be expected. A 32-bit floating point datatype can not store exact representations of all numbers, and therefore it will be stored as the closest binary representation.
See this calculator to play around with this effect:
https://www.binaryconvert.com/convert_float.html
One way to resolve this is to add a new option into the JSON that specifies the number of decimals that should be shown in the interface, and to which the numbers should be rounded. I think that could be a nice addition, so for that reason I will leave this issue open. If anyone wants to create a pull request for this functionality that would be more than welcome.
from esp8266-iot-framework.
I learning a lot of things from you.
from esp8266-iot-framework.
Hello friend, it's me again and I think what the solution would be instead of converting to pass a string in websoket and maybe in api dash set of json format with only the name and value of each object { name: dumyFloat, value: 2.1},{...} etc. example or maybe to reduce characters {dumy: {value: 2.2}, input {value: true}, etc}. to pass the data in real values ββand not go through the conversion and it is already an ArduinoJSON dependency of some libs of the project. sorry for my bad English
from esp8266-iot-framework.
Thanks for your input. I can agree that this makes sense from a front-end and web point of view, but it does not make sense from the embedded side of things. Parsing JSON on the ESP8266 is much more expensive than converting JSON to binary in the front-end. In the second case, which is how it is implemented now, the conversion to binary is done by your computer or smartphone, which has more than enough resources to do this simple conversion from JavaScript object to binary format.
If we would choose to send JSON data over the Websocket, the ESP8266 would need to parse this JSON data and store it in a C structure. This will cost more memory and computational power on the ESP8266, where it is much more limited. With the current implementation, all that the ESP8266 needs to do is a single memory copy action.
from esp8266-iot-framework.
Added this functionality in 13988ca :)
from esp8266-iot-framework.
Related Issues (20)
- ESPAsyncWebServer.h not found HOT 3
- projectVersion example HOT 1
- Adding "type": "password" in configuration HOT 5
- ESP32 Support... HOT 32
- nice will have a look HOT 1
- Holding connections open for long periods of time HOT 4
- Event on Dashboard Change HOT 12
- Detect if captive portal is running and WiFi is in Ad-hoc mode HOT 3
- Separator and titol in config page HOT 1
- Enhancement: Adding "label" in dashboard HOT 4
- mDNS not working HOT 1
- Error when run "npm ci" HOT 7
- Failing at Step 9. HOT 3
- WiFi passwords including "+" not working HOT 3
- 403 Forbidden response to GET request HOT 1
- Dependency issues in library HOT 4
- Request: click button in dashboard HOT 1
- WIFI reconnect HOT 1
- The cipher AES128-SHA is not supported for TLSv1.2. HOT 5
- Import issue Arduino IDE 2.1.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp8266-iot-framework.