8000 float serialization · Issue #588 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
float serialization #588
@alex9x

Description

@alex9x

Hi! Please, help with float serialization.

Function to cut one decimal and part of code:
`
float Round1(float tmp) {
return ((int)(tmp * 10)) / 10.0;
}

DynamicJsonBuffer jsonBuffer(200);
JsonObject& log = jsonBuffer.createObject();
tmp_t=24.35141; // float value from sensor
log["dht_t"] = Round1(tmp_t); // cut to one decimal
`
got results in log file:

{"dht_t":24}
{"dht_t":24.1}
{"dht_t":24.2}
{"dht_t":24.29999} - for 24.3
{"dht_t":24.4}
{"dht_t":24.5}
{"dht_t":24.6}
{"dht_t":24.7}
{"dht_t":24.79999} - for 24.8
{"dht_t":24.9}

problem with x.3 and x.8

Any help are welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv5ArduinoJson 5

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0