I'm using the DHT11 sensor in my project. Before integrating the sensor and code, I tried out the sample code. Seems like even through the readtemperature function is a float, it is returning integer values for temp (working in degrees C). Is this the way the sensor is designed to work, or due to the library the sample code uses, or just the nature of the beast? I understand that the sensor itself isn't that accurate or that responsive, and that's OK. I'm looking for relative changes, but would really like to see finer values than 1 degree C from it.
One more thing: I know I could use a thermistor and probably get more accurate and maybe more responsive readings (and my final build might actually go that way), but I'm also trying to learn the environment and its capabilities, so this is really a general question about the DHT11 and its support library.
The DHT does return in 1 degree steps, but you can always interpolate that value with the previous value by a so called low pass filter to reduce "noise"
void loop()
{
t = DHT.getTemperature();
value = (t + value)/2.0;
Serial.println(value,1);
delay(1000);
}
I did add some averaging (interpolating) code as suggested. At least I know I'm not missing something about the sensor - 1.8 degree F jumps aren't really going to work, so I'll either move to the DHT22 or a thermistor. The thermistor does give what appears to be great resolution, but I will have to calibrate it (at least roughly).
The resolution of the thermistor depends on the ADC converter used.
The Arduino is 10 bit = 1024 values for a range from MIN to MAX ==> (MAX-MIN)/1024 degrees per step.
An DHT22 with one decimal for the (operating) range (-40.. 80 =120 degrees with 0.1 degree accuracy is more than 1024 values.
A better sensor might be the DS18B20 - use the Dallas Temperature COntrol Library - which has a range from -55 - 125 C
at 12 bits this sensor has 4 bits decimal = 0.0625 C step size..