DHT 11 can report decimals?
-
I'm running several sketches. DHT22 reports just fine values like xx.xx
But DHT11 reports 0 decimals. So it is always like xx.00
Is that standart for dht11?
-
According to the data sheet, the accuracy of DHT11 is ±2℃. So reporting with decimals doesn't make sense. If the sensor is reporting 22 degrees the temperature might be anywhere between 20 and 24.
The accuracy of the DHT22 (again, from datasheet) is ±0.2C. So for the DHT22 it makes sense to report one decimal, but be aware that if the sensor reports 22.4 degrees the real temperature can be anywhere between 22.2 and 22.6.
See also http://forum.mysensors.org/topic/2686/improve-ds18b20-resolution
-
@moskovskiy82 if it's allways reporting x.0 than you store the result of the reading in a double of long. If you want to get rid of the decimals. You only have to cast the value to an int. This will truncate the value.
long x = 2.3;
Serial.println( (int)x );
will result in 2
Suggested Topics
-
Over the air updates
General Discussion • 23 Mar 2014, 21:38 • ToSa 1 Mar 2015, 11:21 -
Sleep mode for bmp280
Hardware • 20 Feb 2018, 13:24 • fishermans 5 Feb 2024, 18:30 -
"Remote Irrigation with LoRaWAN: LM27313 Challenges and PCB Design"
Hardware • 24 Jan 2024, 23:06 • wrendral 3 Feb 2024, 07:13 -
Sensor to detect marijuana vape/smoke
Hardware • 21 Jan 2025, 06:36 • Hellmark 25 Feb 2025, 20:56 -
Newbie questions
Hardware • 14 Feb 2025, 20:03 • magwas 14 Feb 2025, 20:03 -
Arduino Nano Every problem
Hardware • 1 Feb 2020, 09:18 • hakha4 5 Dec 2023, 02:21