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 -
No merge into master in the last 5 years, should we use development?
General Discussion • 23 Sept 2024, 17:48 • kiesel 3 Oct 2024, 14:18 -
How to great variables
General Discussion • 16 May 2024, 14:43 • wint0178 22 Jul 2024, 06:11 -
ESP-NOW
General Discussion • 22 Apr 2018, 05:58 • NeverDie 3 days ago -
What is form factor?
General Discussion • 15 Jan 2025, 07:33 • Luosi 15 Jan 2025, 07:33 -
Combination of networks
General Discussion • 19 days ago • Sniker 17 days ago