Number of decimals in sketches
-
I don't want the emperature humidity to be as precise as in the sketch which has 2 decimal points.
So for the humidity i rewrote the sketch as such
float hum_floa = dht.getHumidity(); float humidity = round (hum_floa);
It works but the data is still sent as yy.xx
Is there a simple way to make it as yy only?
-
There are probably better ways but:
hum_floa.remove(temp.indexOf('.') + 2)
Dont know the dht lib, maybe you can set some settings there to recieve without decimals.
This will not round but just cut/remove the last digits after "."
-
If you use Set to send your temp/hum you can define how many decimals you want:
MyMessage& set(float value, uint8_t decimals);
For example:
gw.send(msgTemp.set(temperature, 1));
will send you the value with 1 decimal.
Reference: here
1 out of 3
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
is this project dead?
General Discussion • 12 days ago • perfectom 3 days ago -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 4 Mar 2025, 00:29 -
Why is the output of ACS712 current measurement module unchanged?
General Discussion • 19 Jul 2021, 09:09 • Tessie T 24 days ago -
Email notifications received twice
General Discussion • 6 Feb 2023, 16:15 • Jodaille 26 days ago -
Which device I have to use to connect with accelerometer before connecting to my pc?
General Discussion • 24 Jan 2023, 17:16 • Yada Kijsathan 16 Mar 2025, 20:17