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 -
Why is the output of ACS712 current measurement module unchanged?
General Discussion • 19 Jul 2021, 09:09 • Tessie T 20 Jul 2021, 15:50 -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 26 days ago -
Code Garage to the rescue.
General Discussion • 11 Jan 2025, 11:25 • skywatch 23 Feb 2025, 14:57 -
Email notifications received twice
General Discussion • 6 Feb 2023, 16:15 • Jodaille 3 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