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
2 out of 3
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
Which device I have to use to connect with accelerometer before connecting to my pc?
General Discussion • 24 Jan 2023, 17:16 • Yada Kijsathan 13 days ago -
Why is the output of ACS712 current measurement module unchanged?
General Discussion • 19 Jul 2021, 09:09 • Tessie T about 14 hours ago -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 26 days ago -
No merge into master in the last 5 years, should we use development?
General Discussion • 23 Sept 2024, 17:48 • kiesel 5 days ago -
ESP-NOW
General Discussion • 22 Apr 2018, 05:58 • NeverDie 17 Feb 2025, 22:24