Number of decimals in sketches
moskovskiy82 last edited by
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 "."
ericvdb last edited by
If you use Set to send your temp/hum you can define how many decimals you want:
MyMessage& set(float value, uint8_t decimals);
will send you the value with 1 decimal.