I have a few DHT11 sensors that I purchased last year. I have tested them with my Arduino to determine precision among the group. I found that there is noticeable variation from one sensor to the next in both temperature and humidity. I am considering upgrading these modules to a better sensor. Does anyone know if the DHT22 is better from one unit to the next in reporting the same values of temperature and humidity? I was originally looking at the SHT75, but I need 3 and the prices I was finding last year were pretty steep especially compared to the DHT11.
Background:
The goal of these sensors is to act as a set of sensors for an attic fan controller. I need to know the temperature and humidity of the attic and the outside air. If there is a delta from one sensor to the next, it will be very difficult to determine what the delta in my humidity and temperature readings are. I know the DHT11 is a bottom end sensor, but I was expecting the inaccuracy to be consistent from sensor to sensor in the same environment. If this is simply an offset, I could apply an offset in the code. If the error varies dramatically and it's not based on temperature/humidity then the sensor won't work.
DHT11 versus DHT22
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
Variation between two sensors of the same type is not unusual. In practice, all sensors require calibration for maximum accuracy. Once calibrated ( it should just require an offset ), the DHT sensors should give you repeatable results.
- bkenobi69
- Posts: 18
- Joined: Mon Jan 07, 2013 11:53 am
Re: DHT11 versus DHT22
If that's the case, then I guess I should build a database of values for all sensors so I can determine offset values.
Oh, one other question. I just grabbed a few resistors for my pull-up resistors. 3 are the same, but the other . Were different values. Since this is a digital sensor, I assume the value of the pull-up resistor will not affect the readings from the sensor. Is that a good assumption?
Oh, one other question. I just grabbed a few resistors for my pull-up resistors. 3 are the same, but the other . Were different values. Since this is a digital sensor, I assume the value of the pull-up resistor will not affect the readings from the sensor. Is that a good assumption?
- arctic_eddie
- Posts: 233
- Joined: Tue Feb 28, 2012 6:01 pm
Re: DHT11 versus DHT22
I have a similar project using four of the DHT22 sensors to determine dew shield design for telescopes. Since it may not be practical to calibrate each sensor, I've decided to create a matching scheme. Each sensors is monitored in a sketch through a range of values in unison and under the same conditions. One is selected as the reference. It could be the one closest to the average value or one that is deemed to be the most accurate. You could also select the readings from an independent sensor that is judged accurate. The data from the reference and the others are entered as #define values for high and low readings in the range of interest. Next, the map() is re-written as fmap() by just changing the input values to float(). The fmap() function and the #define data are used in the application sketch to make each sensor look identical to the reference item. I'm now testing the sketch with a set of 10K epoxy thermistors. After I get my four DHT22's(out of stock), I'll post the sketch and procedure in this forum.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
Pull up value can vary a bit. Too low a value will be too strong of a pull up & the sensor won't be able to overcome it. Somewhere in the 4.7K-20K ohm range should be fine.
- bkenobi69
- Posts: 18
- Joined: Mon Jan 07, 2013 11:53 am
Re: DHT11 versus DHT22
So even the DHT22 has some variance from sensor to sensor? In that case, the only difference between the DHT11 and DHT22 is the accuracy and range specs. The DHT11 works for me as long as unit to unit is close, so I'll definitely need to generate calibration tables. Thanks for the input!
I'll check my resistors and replace if out of that range. Thanks!
I'll check my resistors and replace if out of that range. Thanks!
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
All types of sensor have variance. If you buy enough of them you can test them all and hand-pick a matched set. But in practice, it is easier to just add the offset.
- bkenobi69
- Posts: 18
- Joined: Mon Jan 07, 2013 11:53 am
Re: DHT11 versus DHT22
How long do sensors generally take to reach equilibrium? I've just tested all 6 of my sensors in 5 locations for up to 5 minutes per location. I didn't expect the sensors to react instantly, but I am a little taken aback by the fact that going from inside at ~68 degF to outside at ~50 degF the sensors didn't level out after 5 minutes. If I run the attic fan for 15 minutes to exhaust the air 2-3x, I don't know if the sensors would see a new humidity and be accurate. My goal was to run the fan for say 15 minutes per hour when the humidity delta is high enough and above a threshold. I don't know if these sensors will get me where I need to be with the delay. Perhaps moving air will allow the sensor to react quicker than stagnant air.
Code: Select all
DHT calibration
DHT1 DHT2 DHT3 DHT4 DHT5 DHT6 DHT1 DHT2 DHT3 DHT4 DHT5 DHT6
Time T T T T T T H H H H H H
0 64.4 64.4 60.8 64.4 62.6 66.2 59 58 55 59 46 45
2 64.4 62.6 60.8 64.4 62.6 66.2 59 58 55 59 46 45
4 64.4 62.6 60.8 62.6 62.6 64.4 59 58 55 59 46 46
6 64.4 62.6 59 62.6 62.6 64.4 60 58 56 59 45 46
8 64.4 62.6 59 62.6 62.6 64.4 60 58 57 60 45 46
10 64.4 62.6 59 62.6 60.8 64.4 60 59 57 60 47 45
12 62.6 62.6 59 62.6 60.8 64.4 60 59 58 60 47 45
14 62.6 60.8 59 62.6 60.8 62.6 60 60 58 60 46 45
16 62.6 60.8 59 62.6 60.8 62.6 60 60 59 60 46 45
18 62.6 60.8 59 62.6 60.8 62.6 60 60 59 60 46 45
20 62.6 64.4 57.2 62.6 60.8 62.6 61 60 60 60 46 45
22 62.6 60.8 57.2 60.8 59 62.6 61 61 60 62 46 45
24 62.6 62.6 57.2 60.8 59 62.6 61 61 61 62 46 45
26 62.6 62.6 57.2 60.8 59 60.8 61 61 61 62 46 46
28 60.8 62.6 57.2 60.8 59 60.8 62 61 61 62 46 46
30 60.8 62.6 57.2 60.8 59 60.8 62 61 62 62 46 46
32 60.8 62.6 57.2 60.8 59 60.8 62 61 62 62 46 46
34 60.8 62.6 57.2 60.8 59 60.8 63 61 62 62 46 46
36 60.8 62.6 57.2 60.8 57.2 59 63 61 62 62 47 46
38 60.8 62.6 57.2 60.8 57.2 59 63 62 62 63 47 46
40 60.8 62.6 57.2 60.8 57.2 59 63 62 63 63 47 46
42 60.8 62.6 57.2 60.8 57.2 59 63 62 63 63 47 46
44 60.8 60.8 57.2 59 57.2 59 63 63 63 63 47 46
46 59 60.8 55.4 59 57.2 59 63 63 63 63 47 46
48 59 60.8 55.4 59 57.2 59 64 63 63 63 47 46
50 59 60.8 55.4 59 57.2 59 64 63 64 63 47 46
52 59 60.8 55.4 59 57.2 59 64 64 64 63 47 46
54 59 60.8 55.4 59 57.2 59 64 64 64 64 47 46
56 59 60.8 55.4 59 55.4 57.2 64 64 64 64 48 47
58 59 60.8 55.4 59 55.4 57.2 64 64 65 64 48 47
60 59 60.8 55.4 59 55.4 59 65 64 65 64 48 48
62 59 60.8 55.4 59 55.4 59 65 64 65 64 48 47
64 59 60.8 55.4 59 55.4 59 65 65 65 64 48 48
66 59 60.8 55.4 59 55.4 59 65 65 65 64 48 48
68 59 59 55.4 59 57.2 59 65 65 66 64 49 48
70 59 59 55.4 59 57.2 59 65 65 66 65 49 48
72 57.2 59 53.6 59 57.2 59 67 65 67 65 49 48
74 57.2 59 53.6 59 57.2 59 67 65 67 65 49 48
76 57.2 59 53.6 57.2 57.2 59 67 66 67 66 50 48
78 57.2 59 53.6 57.2 57.2 59 67 66 68 66 50 48
80 57.2 59 53.6 57.2 57.2 59 67 66 68 66 50 48
82 57.2 59 53.6 57.2 57.2 59 68 66 68 66 50 48
84 57.2 59 53.6 57.2 57.2 59 68 66 68 67 50 48
86 57.2 59 53.6 57.2 55.4 57.2 68 66 69 67 50 49
88 57.2 59 53.6 57.2 55.4 57.2 68 67 69 67 50 49
90 57.2 59 53.6 57.2 55.4 57.2 68 67 69 67 50 49
92 57.2 59 53.6 57.2 55.4 57.2 68 67 69 67 50 49
94 57.2 59 53.6 57.2 55.4 57.2 69 67 69 67 50 49
96 57.2 59 53.6 57.2 55.4 57.2 69 67 70 68 50 50
98 57.2 59 53.6 57.2 55.4 57.2 69 67 70 68 50 50
100 57.2 59 53.6 57.2 55.4 57.2 69 67 70 68 51 50
102 57.2 59 53.6 57.2 55.4 57.2 69 68 70 68 51 50
104 57.2 59 53.6 57.2 55.4 57.2 69 68 70 68 51 50
106 57.2 59 53.6 57.2 55.4 57.2 70 68 71 68 51 50
108 55.4 57.2 53.6 57.2 55.4 57.2 70 69 71 68 51 50
110 55.4 57.2 53.6 57.2 55.4 57.2 70 69 71 69 51 50
112 55.4 57.2 53.6 57.2 55.4 57.2 70 69 71 69 51 50
114 55.4 57.2 53.6 57.2 55.4 57.2 70 69 71 69 51 50
116 55.4 57.2 51.8 57.2 55.4 57.2 70 70 71 69 51 50
118 55.4 57.2 53.6 55.4 55.4 57.2 71 70 72 69 51 50
120 55.4 57.2 51.8 55.4 55.4 57.2 71 70 72 69 51 50
122 55.4 57.2 51.8 55.4 55.4 57.2 71 70 72 69 51 50
124 55.4 57.2 51.8 55.4 59 55.4 71 70 72 69 53 51
126 55.4 57.2 51.8 55.4 53.6 55.4 71 70 72 70 52 51
128 55.4 57.2 51.8 55.4 59 55.4 71 70 73 70 53 51
130 55.4 57.2 51.8 55.4 59 55.4 72 70 73 70 53 51
132 55.4 57.2 51.8 55.4 59 55.4 72 71 73 70 53 51
134 55.4 57.2 51.8 55.4 59 55.4 72 71 73 70 53 51
136 55.4 57.2 51.8 55.4 59 55.4 72 71 73 70 53 51
138 55.4 57.2 51.8 55.4 59 55.4 72 71 73 70 53 51
140 55.4 57.2 51.8 55.4 59 55.4 72 71 74 70 53 51
142 55.4 57.2 51.8 55.4 57.2 55.4 73 71 74 70 54 51
144 55.4 57.2 51.8 55.4 57.2 55.4 73 71 74 71 54 52
146 55.4 57.2 51.8 55.4 57.2 55.4 73 71 74 71 54 51
148 55.4 57.2 51.8 55.4 57.2 55.4 73 71 74 71 54 52
150 55.4 57.2 51.8 55.4 57.2 55.4 73 72 74 71 54 52
152 53.6 57.2 51.8 55.4 57.2 55.4 74 72 74 71 54 52
154 53.6 57.2 51.8 55.4 57.2 55.4 74 72 75 71 54 52
156 53.6 57.2 51.8 55.4 57.2 55.4 74 72 75 71 55 52
158 53.6 57.2 51.8 55.4 57.2 55.4 75 72 75 72 55 52
160 53.6 57.2 51.8 55.4 57.2 55.4 75 72 75 72 55 52
162 53.6 57.2 51.8 55.4 57.2 55.4 75 72 75 72 55 52
164 53.6 57.2 51.8 55.4 57.2 55.4 75 72 75 72 55 52
166 53.6 57.2 51.8 55.4 57.2 55.4 75 73 75 72 55 52
168 53.6 55.4 51.8 55.4 57.2 55.4 75 73 75 72 55 53
170 53.6 57.2 51.8 55.4 57.2 55.4 75 73 76 72 55 52
172 53.6 55.4 51.8 55.4 57.2 55.4 75 73 76 72 55 53
174 53.6 55.4 51.8 55.4 57.2 55.4 75 73 76 72 55 53
176 53.6 55.4 51.8 55.4 57.2 55.4 76 73 76 72 55 53
178 53.6 55.4 51.8 55.4 57.2 55.4 76 73 76 72 55 53
180 53.6 55.4 51.8 55.4 57.2 55.4 76 73 76 73 55 53
182 53.6 55.4 51.8 55.4 57.2 55.4 76 73 76 73 55 53
184 53.6 55.4 51.8 55.4 57.2 55.4 76 73 76 73 55 53
188 53.6 55.4 51.8 55.4 57.2 55.4 76 74 76 73 55 53
190 53.6 55.4 51.8 55.4 57.2 55.4 76 74 76 73 55 53
192 53.6 55.4 51.8 55.4 57.2 55.4 76 74 76 73 55 53
194 53.6 55.4 51.8 55.4 57.2 55.4 77 74 77 73 56 54
196 53.6 55.4 51.8 55.4 57.2 55.4 77 74 77 73 56 54
198 53.6 55.4 51.8 55.4 57.2 55.4 77 74 77 74 56 54
200 53.6 55.4 51.8 55.4 57.2 55.4 77 74 77 74 56 54
202 53.6 55.4 50 55.4 57.2 55.4 77 74 78 74 56 54
204 53.6 55.4 51.8 55.4 57.2 55.4 77 74 77 74 56 54
206 53.6 55.4 50 55.4 57.2 53.6 77 74 78 74 56 55
208 53.6 55.4 50 53.6 57.2 55.4 77 74 78 75 56 54
210 53.6 55.4 50 53.6 55.4 53.6 77 74 78 75 56 55
212 53.6 55.4 50 55.4 55.4 53.6 77 75 78 74 56 55
214 53.6 55.4 50 53.6 55.4 53.6 77 75 79 75 56 55
216 53.6 55.4 50 53.6 55.4 53.6 77 75 79 75 56 55
218 53.6 55.4 50 53.6 55.4 53.6 77 75 79 75 56 56
220 53.6 55.4 50 53.6 55.4 53.6 77 75 79 75 56 56
222 53.6 55.4 50 53.6 55.4 53.6 78 75 79 75 56 56
224 53.6 55.4 50 53.6 55.4 53.6 78 75 79 76 57 56
226 51.8 55.4 50 53.6 55.4 53.6 78 75 79 76 56 56
228 51.8 55.4 50 53.6 55.4 53.6 78 75 79 76 57 56
230 51.8 55.4 50 53.6 55.4 53.6 78 75 79 76 57 56
232 53.6 55.4 50 53.6 55.4 53.6 78 75 79 76 57 56
234 51.8 55.4 50 53.6 55.4 53.6 78 75 79 76 57 56
236 51.8 55.4 50 53.6 55.4 53.6 78 76 79 76 57 56
238 51.8 55.4 50 53.6 55.4 53.6 78 76 80 76 57 56
240 51.8 55.4 50 53.6 55.4 53.6 78 76 80 76 57 56
242 51.8 55.4 50 53.6 55.4 53.6 78 76 80 76 57 56
244 51.8 55.4 50 53.6 55.4 53.6 79 76 80 76 57 57
246 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
248 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
250 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
252 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
254 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
256 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
258 51.8 55.4 50 53.6 55.4 53.6 79 76 80 77 58 57
260 51.8 53.6 50 53.6 55.4 53.6 79 77 80 77 58 57
262 51.8 53.6 50 53.6 55.4 53.6 79 77 80 77 59 57
264 51.8 53.6 50 53.6 55.4 53.6 79 77 80 77 59 58
266 51.8 53.6 50 53.6 55.4 53.6 79 77 80 77 60 58
268 51.8 53.6 50 53.6 55.4 53.6 79 78 80 77 60 58
270 51.8 53.6 50 53.6 55.4 53.6 79 78 81 77 60 58
272 51.8 53.6 50 53.6 55.4 53.6 79 78 81 78 60 58
274 51.8 53.6 50 53.6 55.4 53.6 79 78 81 78 60 58
276 51.8 53.6 50 53.6 55.4 53.6 79 78 81 78 60 58
278 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 60 58
280 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 61 59
282 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 61 59
284 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 61 59
286 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 62 59
288 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 62 59
290 51.8 53.6 50 53.6 55.4 53.6 80 78 81 78 62 59
292 51.8 53.6 50 53.6 55.4 53.6 80 79 81 78 62 59
294 51.8 53.6 50 53.6 55.4 53.6 80 79 81 79 62 60
296 51.8 53.6 50 53.6 55.4 53.6 80 79 81 79 62 60
298 51.8 53.6 50 53.6 55.4 53.6 80 79 81 79 62 60
300 51.8 53.6 50 53.6 55.4 53.6 80 79 81 79 63 61
302 51.8 53.6 50 53.6 55.4 53.6 80 79 81 79 63 61
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
Temperature sensor reaction time is largely related to the thermal mass of the sensor and whatever it is attached to. Air flow will improve the thermal transfer to the surrounding air. The DHTs are rather 'chunky' as temperature sensors go. But I haven't done any in-depth testing on reaction times with them.
- bkenobi69
- Posts: 18
- Joined: Mon Jan 07, 2013 11:53 am
Re: DHT11 versus DHT22
I'll rerun my calibration test with a fan blowing over the sensors. In practice, the sensor would likely be installed in a location where the attic fan would draw flow across it anyway, so this would be a good check.
-
- Posts: 2
- Joined: Sat Jan 19, 2013 10:52 am
Re: DHT11 versus DHT22
bkenobi,
I have several DHT11 sensors that I am trying to use but have been having trouble figuring out how to modify the code to poll multiple sensors.
Would you be willing to share your code for this?
Thanks,
Jim
I have several DHT11 sensors that I am trying to use but have been having trouble figuring out how to modify the code to poll multiple sensors.
Would you be willing to share your code for this?
Thanks,
Jim
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
Just declare one for each sensor and give them different names:
Then you can read from them by name:
Code: Select all
DHT_1 dht(2, DHT11);
DHT_2 dht(3, DHT11);
DHT_3 dht(4, DHT11);
DHT_4 dht(5, DHT11);
Code: Select all
float h_1 = dht_1.readHumidity();
float t_1 = dht_1.readTemperature();
float h_2 = dht_2.readHumidity();
float t_2 = dht_2.readTemperature();
float h_3 = dht_3.readHumidity();
float t_3 = dht_3.readTemperature();
etc...
-
- Posts: 2
- Joined: Sat Jan 19, 2013 10:52 am
Re: DHT11 versus DHT22
Thanks for the quick response!
So does that mean I should leave out:
"#define DHTPIN 2"
which is in the example on github?
Thanks,
Jim
So does that mean I should leave out:
"#define DHTPIN 2"
which is in the example on github?
Thanks,
Jim
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: DHT11 versus DHT22
Yes. Instead of passing DHTPIN in the constructor, use the actual pin number for that sensor.
- bkenobi69
- Posts: 18
- Joined: Mon Jan 07, 2013 11:53 am
Re: DHT11 versus DHT22
In my code I just created DHTPIN1, DHTPIN2, etc.
I reran a couple more scenarios using the fan. One was sitting inside with the fan blowing across the sensors. I wanted to make sure that the fan wouldn't create funny results which it did not. Next, I put the fan, arduino, sensors and laptop outside for a few minutes. I forgot to bring the data with me and now I'm out of town. I can say that the laptop was covered in condensation and at least one reading indicated 95%.
I am planning on writing some code that will run once at power up that will calibrate all used sensors automatically. I believe I have come up with an approach and will poat it here when I finish.
I reran a couple more scenarios using the fan. One was sitting inside with the fan blowing across the sensors. I wanted to make sure that the fan wouldn't create funny results which it did not. Next, I put the fan, arduino, sensors and laptop outside for a few minutes. I forgot to bring the data with me and now I'm out of town. I can say that the laptop was covered in condensation and at least one reading indicated 95%.
I am planning on writing some code that will run once at power up that will calibrate all used sensors automatically. I believe I have come up with an approach and will poat it here when I finish.
Please be positive and constructive with your questions and comments.