-
Notifications
You must be signed in to change notification settings - Fork 46
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
cJSON floating point issue #4
Comments
The problem is the format specified in the sprintf. Our printf doesn't process the %.0f. |
I've just pushed a commit that should fix it. Thank you. |
Hi, The javascript removes the waste but it's not the best solution i think. |
Can you check if changing
to
solves the problem? |
Hi, |
Hi,
i tried your code today and its working very well but cJSON is not converting a float number correctly.
You hit the problem if you try to read the dht22. The output looks like this:
{
"temp": %.0f,
"hum": %.0f
}
My current fix is to typecast the values like this:
cJSON_AddNumberToObject(root,"temp",(int8_t)data.dht22.temp);
cJSON_AddNumberToObject(root,"hum",(uint8_t)data.dht22.hum);
Maybe someone know how to fix the cJSON lib easily?!
I am using the esp-open-sdk (espressif lib v1.0.1) to compile the code.
The text was updated successfully, but these errors were encountered: