Test and Calibrate DHT22 Hygrometers

Page Contents

 

Introduction

This page covers tests of the DHT22 / AM2302 and description of the test methodology. For other types of devices, see the index of all my hygrometer testing.

The DHT22 (a.k.a. AM2302, RHT03) is a popular hygrometer/thermometer in the hobbyist electronics community. It is cheap, easy to use and the specification claims good precision and accuracy. There are several different data sheets floating around the web for what appear to all be the same device, though I cannot be sure they are all from the same factory. Typical advertised specs for AM2302/DHT22 are:

Absolute accuracy ±2%
Repeatability ±1%
Long term stability ±0.5% per year

I searched the web for others' experiences and struggled to find any convincing discussions of whether they really do meet these specifications. Some people report unencouraging experimental results, others simply repeat the specification verbatim. Data sheets typically just say things like "0-100% humidity and ±2% typical accuracy". Data sheets for serious, precision sensors will provide a varying scale of errors as a function of humidity and temperature and normally only claim precision of 2% despite costing ten times as much. The DHT22 may be ±2% near the middle of its range, but can we really believe those errors do not increase near 0 and 100?

UPDATE: Since first writing this page a much improved data sheet has recently appeared which contains both clearer translations to English and more detailed specifications and plots. It still claims a typical accuracy of ±2%, but does now show the accuracy degrading to ±5% at the two extreme limts, <10% and >90%.

Accurately and repeatably measuring relative humidity is notoriously tricky (note the 1–2%RH quoted accuracy even for professional meteorological instruments costing $1000+) so I decided to run some experiments of my own. Objectives were to determine how good these sensors are and if possible derive a correction curve to improve on the factory calibration. The manufacturer's calibration is permanently defined in these devices and not user adjustable so they cannot be re-calibrated in any physical sense. We can however build a look-up correction transformation.

I stress a few points first and hold these in mind when assessing whether you believe and trust my results.

I planned to spend a couple of weeks on this experiment. A year of data logging and two complete rebuilds of the test apparatus later I feel as though I have got a feel for how these devices operate. It has all turned into a far bigger undertaking than I had ever imagined.

Conclusion

I will start with my conclusions for those who do not want to read all the following or you can jump to the numerical answers.

 

Calibrating hygrometers

The method adopted here, purely on the basis of being the only one that is reasonable to attempt using a few common household items, is that of critical relative humidity above a saturated aqueous solution. If you seal pure water in an air-tight vessel, the water will evaporate until the balance of liquid and vapour reach an equilibrium at 100% relative humidity. Water vapour will then evaporate and condense, exchanging between liquid and gaseous phases, but always maintaining a balance at 100% RH. This is in practical terms a definition of what 100% RH means. This gives a method for setting the 100% calibration point of a hygrometer; simply put it is a sealed box with some water. You can set the 0% calibration point by sealing the sensor in the box with an aggressive desiccating agent. In practice neither of these help very much since the device is likely to be non-linear and at its least accurate near the two extremes so these data may tell you little about how it behaves in between. Also, zero and 100 are rarely experienced in real life so calibrating them is of limited interest.

As a water soluble chemical dissolves, its atoms interfere with evaporation at the water surface, meaning the stable equilibrium between water vapour and the solution becomes less than 100%. By very precisely controlling the concentration of a solution you can control the humidity of the air above that solution. Typically sodium hydroxide (e.g., Madge 1961), sulphuric acid or lithium chloride have been used. Unfortunately NaOH and H2SO4 are both unpleasant to handle and this method is difficult without precision weights and measures. Madge (1961) provides conprehensive tables of what concentration of NaOH to use to generate any humidity you want for a range of temperatures (0–40°C). If you have good quality laboratory or jewelers' scales this might be a viable technique for home use. It only requires finding one (admittendly very corrosive!) chemical and allows you to set any humidity you want over the range 6–100%.

Instead of varying concentrations of a particular salt I use saturated solutions of several different salts. Depending on the solubility of a particular salt, a different relative humidity will be generated in equilibrium with the solution. Low solubility salts will yield high humidity because the solution is not far from being just water anyway. Very high solubility salts will conversely yield low humidity. We use saturated solutions because they are easy to achieve without making any precision measurements; dissolve as much as you possibly can and you still have residual solids which will not dissolve. In this sense they are an ideal reference since they depend on basic physical properties of the chemical and do not need to be calibrated or set up in any way. They are are self regulating and will naturally remain saturated as long as there are undissolved solids present.

The test is thus very simple in theory. Seal the hygrometer in an air-tight vessel with a sample of the saturated solution and record what the sensor measures compared to the humidity known from published lab. tests to be generated by that particular solution. In practice there are many things that can go wrong or influence your results and these will be discussed (in tedious detail) below.

The best summary I have found of this technique is that of Fossa & Petanga (2003) who describe essentially the same experiment as I perform here for the purpose of testing the hygrometers in CERN's Compact Muon solenoid(CMS). They (sensibly) restrict themselves to using just LiCl (11%), MgCl (35%), NaCl (75%) and KNO3 (92%) instead of the twelve-point calibration I attempt here. You might very fairly ask why I need a twelve-point calibration for my sensors when they managed to discover the Higgs boson with the CMS and just a four-point calibration.

 

The Devices

I have six devices to test. All are marked AM2302 and have individual serial numbers. Five were bought together as a set from a China-based eBay seller. These all have very similar serial numbers and were presumably manufactured in the same batch. The sixth was bought from a "reputable US-based on-line retailer" and has a clearly different SN. I have seen no significant difference between them and cannot support the suggestion I have seen on-line that those from unknown eBay traders may be grade-outs that failed the manufacturer's spec. Of course neither can I rule out that some of them are.

Serial Number
A SN1305002C0
B SN1307003F2
C SN13070022E
D SN13070041C
E SN130700201
F SN130700A38

I will not give much detail of the electronic setup. Since these are digital devices which output a checksummed numerical value, the external electronics ought to be irrelevant. Once you provide a d.c. supply voltage, everything else happens inside the sensor module itself. I read the devices using a JeeNode v6, a small, low power, Arduino-like, ATMega328P board with an integrated RFM12B radio module, making it very easy to send measurements out to an external data logger. Measurements were logged into a MySQL database via the EmonCMS data logging system developed by the Open Energy Monitor project. I enthusiastically recommend the combination of JeeNodes and EmonCMS as an easy way to initially get going on any wireless, distributed, environmental monitoring system like this.

The sensors and the JeeNode were powered from a single 5V d.c. switched mode PSU. The JeeNode has it's own on-board voltage regulator but the supply to the DHT22s was fed directly from the PSU. (c.f. version 1)

Version 1 consisted of a sealed box containing the entire experiment; the sample solution, the sensors, all the electronics and battery. Version 2 is based on two main design changes; active thermal control to ensure data were collected at a known and stable temperature and removal of all electronics from inside the test cell. The cell should be as small as possible and ideally contain nothing other than test solution and sensor. For the air-tight test cell I use a jam jar. The sensors are attached to the underside of the lid with the cables running out through holes sealed with bathroom caulk. Having a dozen identical jars allows me to keep all the solutions constantly ready for use and simply swap the sensor bearing lid onto any one. I am using US American quart Mason jars. Smaller would I think be better, but require more care in handling to prevent splashing the sensors. As well as the six sensors, a 50mm fan is also included to force better air circulation inside the jar.

The dozen jars are then enclosed in a large insulated cardboard box along with a small, low-power fan heater. The fan heater is used to actively control the air temperature inside the box. There is also another fan running continuously to force better air circulation around the jars and maintain temperatures throughout the box as homogeneous as possible. Thermal gradients of just 0.1°C anywhere in the apparatus seems to create significant errors.

Software on the micro-controller reads temperature and humidity from the six DHT22s once every thirty seconds. The temperatures are averaged and used to drive a PID controller for the fan heater. Since the heater does not have any analogue control, that needs to be approximated by pulsing the heater full on and off with the PID setting the duty cycle of typically 20–30 two-second pulses per hour. Initially four second pulses were used but more frequent, shorter pulses gave measurably better control. Both circulation fans (inside the jam jar and inside the surrounding box) run continuously and proved necessary to maintain the temperature stability.

Schematic layout and photograph of the test apparatus
Figure 1. Left panel shows photograph of part of the apparatus inside the large insulated cardboard box. Visible are several of the jars including the one currently containing the six sensors. A different salt solution is in each jar and the lid can simply be swapped onto each in turn. The samples, electronics and fans are all in the top half of the box. A grille is just visible in this image. The heater is beneath that, in the lower half of the box. Right panel is an overview schematic of the whole apparatus. Apologies for my art work. I am much better a data plots.

 

Constraints and Considerations

Choice of Chemicals

I have not invented this technique. It is a well established method of controlling humidity, used in many fields.

An extensive literature on this topic allows you to select a particular salt to generate any humidity to match your requirements. My literature survey yielded in excess of 60 chemicals previously used for this purpose and we need to select a suitable subset for this experiment. The humidity above solutions is to some degree temperature dependent because the salt's solubility is temperature dependent. Some chemicals are of course poisonous, flammable, reactive, unstable or dangerous in a variety of ways.

Plots showing variation in humidity generated above a selection of salts as a function of temperature.
Figure 2. Left panel: The literature contains humidity measurements for a considerable selection of chemicals. (Data from O'Brien 1948, Wexler 1953, Rockland 1960, Greenspan 1977, Weast 1979). Right panel: The selected sample of chemicals actually used in the current experiment.

Chemicals were bought where I could find them fairly cheaply. Several were only "agricultural grade" and probably not very pure which could affect accuracy of my results. Mixtures of different salts will generally yield a lower humidity than either of the two pure components. I did buy a few (LiCl, MgCl, KI & KNO3) in fairly pure "reagent grade". The NaCl was "food grade"; simply non-iodized table salt. In Figure 2, Ammonium nitrate stands out as being the only one with a significant temperature coefficient. Calcium chloride also has a strong temperature coefficient and was used for a while. It appears in some plots but was abandoned since it has no obvious advantage over magnesium chloride and the published reference values seemed ill determined. All solutions were made with distilled water though I doubt tap water would have any real effect for the precision achieved here.

Zero and One Hundred

I made attempts at 0% and 100% humidity, but give the results rather little credence.

Distilled water was used for 100% RH. This data point will be of varying use depending on individual devices. Their internal firmware caps all output at 99.9%. Since most of my sensors seem to read marginally high, they hit 99.9% before the air is genuinely saturated making this data point meaningless. One of my sensors (B) reads slightly low at very high humidity so that does generate a usable value for pure water. Many hygrometer manufactures caution against extended exposure of the device to condensing humidity and in my experiments they do seem to take a bit longer to recover after 100% humidity than after other readings. Also anything else inside the test cell (electronics, fan, battery etc) must necessarily end up damp since 100% humidity is by definition condensing. Overall I would suggest not bothering with a 100% data point unless you really need it. As I say above, for most of my devices it was worthless anyway since they already read 99.9% when the atmosphere was really only 98%.

I experimented with dry calcium chloride dihydride for zero humidity. This will not generate a true zero. Taking numbers from "Drying Agents" (Merck, 2005), the expected absolute vapour content of the air would be ~0.4 mg/l which converts to 1.9% RH for my local conditions. Using anhydrous calcium chloride ought to improve this to 0.4% RH. I also tried silica gel beads but found the small quantity I had to hand was ineffective. Even more effective would be 4Å molecular sieve. Again taking values from "Drying Agents" (Merck, 2005), under ideal conditions silica gel could achieve 0.02% RH and a 4Å molecular sieve 0.005% RH. In practice the sensor's firmware appears to be capped at a minimum output value of 1.0% so like 100%, interpretation of the 0% data points is not simple and investing in 4Å molecular sieve is probably pointless.

I returned to calcium choride at the end. Instead of using the CaCl as a reference, I used the calibrated sensors to measure the air above dry, crystaline CaCl. I got 3.8±0.5%RH. I do think that tells us much about CaCl since I have no way to assess how well dehydrated the CaCl really was. It had been baked for a couple of hours in the oven at 200°C, but not been in a vaccuum dessicator. Given that I did not achieve the 1.9%RH predicted above for pure, dry calcium chloride dihydride, that supports my decision not to include it as a reference point in the fits.

Time

It takes time for the vapour to equilibrate. The sensors were sealed in the test vessel with each chemical for between three hours and three days. Data for my analysis are typically averages of 12–24 hours of logged values. The smaller the test vessel air volume and the larger the surface area of the solution, the quicker equilibrium is likely to be achieved. My experience is that vapour equilibrium was generally established in just a couple of hours as long as I had the fan running. Achieving stable thermal equilibrium was much more difficult and that is also easier for a smaller, simpler test vessel.

Temperature

The single biggest source of error I was able to identify was temperature and temperature stability. There are at least three different, competing, temperature dependent effects.

Temperature Effect 1: True Physical Changes in the Calibration Reference

As shown above (Figure 2), the expected RH depends weakly on temperature. The salts used were selected to exhibit smaller than average temperature coefficients. My hypothesis had been that choosing solutions which were not temperature sensitive would minimize my results' sensitivity to temperature variation. In practice this proved fairly unimportant because it is easy to calibrate out and other sources of error dominate.

Including a temperature sensitive salt does however provide a good illustration that the experimental procedure works as expected. Figure 3 shows the measured and predicted humidity as a function of temperature for three solutions; potassium iodide, ammonium nitrate and sodium bromide. Ammonium nitrate is expected to have a much stronger thermal coefficient and the effect is obvious in this plot. All three data sets are slightly offset from the reference curves and the slope of the ammonium nitrate data does not perfectly match expectation, but it is clear that the hygrometer is responding to genuine, small humidity changes as the ammonium nitrate solubility changes with temperature. This plot is very important and greatly increases my confidence that the test cells are properly equilibrating at the set temperature.

Plots showing measured humidity does in fact vary with temperature in a manner similar to expectation from the reference data.
Figure 3. Points are raw humidity data from the DHT22 sensor A as the temperature was adjusted over the range 20 < °C < 30 for three different salts. Lines are the reference curves from Figure 2. Ammonium nitrate exhibits the expected strong temperature effect. It looks possible that full equilibrium was not being achieved above 26°C for the ammonium nitrate sample.

Temperature Effect 2: Temperature Stability and Homogeneity Inside the Test Cell

More dramatic is the way the atmosphere (as opposed to the salt solution) responds to temperature change. Relative humidity is a strong function of air temperature. For a given absolute humidity (i.e., absolute mass of water vapour molecules suspended in the air) the measured relative humidity varies with temperature. For example, in my house in Summer (temperature = 23°C, pressure = 83kPa — well above sea level) atmosphere that contains 16 mg water per litre of air would be measured as 77.6% RH. Raising the temperature just 1°C to 24°C, that same water vapour would now read 73.3% and lowering the temperature to 22°C would give 82.2%. Since the diurnal variation of the air temperature in my house is about 5°C, I would expect the RH measurements in a sealed volume of air to be varying by up to 20% over the course of a single day. Clearly if my errors inside the test vessel are 20%, I can say little about the validity of the manufacturer's claimed 2% factory calibration. To obtain a measurement that is repeatable at 1% RH, we need to a test cell with thermal regulation to a precision substantially better than 1°C.

Initially one might expect the error to correlate to temperature, but for a sealed, air-tight test vessels this particular source of error correlates to rate of change of temperature or temperature gradients within the test cell. We are using the natural equilibrium which the solution, vapour and air are continuously trying to achieve. If the temperature is rising then the air is continuously being able to support more vapour, the solution will be evaporating to provide that and the measured humidity will always be lower than expected because it is always trying to catch up. Similarly when the temperature is falling, the vapour will be condensing back into the solution but is likely to always be lagging the equilibrium target and the measured RH will be higher than the calibration value we are trying to achieve. Only when the temperature remains stable for a period of time will the equilibrium be established. This effect was clearly visible in my logged data for the version 1 test cell which did not have active thermal control (Figure 4).

Plot of RH
 measurement errors as a function of diurnal temperature variation.
Figure 4. Data from the version 1, non-thermally-regulated test cell. Humidity measurements from six DHT22 devices over a period of one day with a saturated solution of potassium nitrate (expected RH 93%). My sensors gave readings in the range 93–100 %. Over-plotted is the air temperature. When the air is cooling the sensors all give higher than average values. When warming up, the RH measurements are all low. One of the sensors (E, purple in plot), which has otherwise saturated at 100%, briefly reappears when the temperature is climbing fastest. Note the correlation is with temperature change, not temperature. Just after both the maximum and minimum temperatures, the RH measurements are very nearly the same. These are the times when the test cell has dwelled at a near constant temperature. Serendipitously this provided a criterion to determine when the system has equilibrated. A measurement was only taken when two consecutive maxima and minima yielded consistent results; typically 36 hours to four days after sealing the vessel.

This problem has largely been eliminated through active thermal control and better air circulation. The PID controller keeps the measured temperature at the set point with a precision of better than ±0.03°C over any timescale from ten minutes to several days. Following a similar calculation to that above (temperature = 23°C, pressure = 83kPa), variations of 0.03°C would be expected to cause absolute errors of 0.06% and 0.15% on measurements of 33% and 85% RH respectively. These errors are small enough that we can test the 1–2% claims from the specification data sheet.

Even with the temperature regulated to better than ±0.03°C, humidity variations of up to 4% were still observed and were precisely correlated to the air temperature of the house, outside the experiment box. How can the house temperature effect the results when the temperature inside the jar was fixed? The cause was temperature gradients in the equipment. The thermostatic control is based on the temperature at the sensor. If there is a temperature gradient (i.e., spatial variation) inside the cell then that can cause exactly the same error as if the temperature varied temporally. A 1°C difference between air around the sensor at the top of the jar and the liquid at the bottom could create up to a 5% RH error. Addition of fans both inside the jar and circulating air around inside the box reduced this error to an acceptable level. For humidities less then 50% there is now no measurable drift over timescales of a few days. Above 50% RH, I still see drifts of less than 0.3% on day time scales. In these cases, values for the final analysis were taken as one day averages. Contrary to version 1 there was no need to pulse the fans since they are no longer battery powered and thermostatic control removes concern about the fan motor heating the air. Various duty cycles were tested but running continuously gave clearly stablest results.


Figure 5. The importance of forced convection. Top panel is with a fan inside the jam jar, but without a fan circulating air around the temperature regulated outer box. It clearly shows the striking and surprising result that the measured humidity inside the sealed jar responds dramatically to the house temperature even though the temperature at the sensor is very tightly controlled. In fact the "house temperature" is even being measured in a different room, the other side of the house! Even though it is only about 10cm from the DHT22 sensors to the liquid at the bottom of the jar, that seems to be far enough that a temperature gradient skews the results by as much as 1.5%. The heater will be working less or more depending on the ambient temperature in the house and that seems to change small scale, local temperature gradients inside the box. For the lower panel an extra fan was installed inside the box and left running continuously just to stir up the air as much as possible and try to enforce a more homogeneous thermal environment. Humidity readings fluctuate by only 0.2%.

Both fans, inside the jar and inside the temperature regulated outer box, proved necessary to get anywhere near a sufficiently stable environment.

Temperature Effect 3: Temperature Sensitivity of the Sensor

So far I discussed experimental systematic errors. Finally I come to temperature sensitivity of the sensor itself which is what the experiment was intended to determine. The manufacturer's data sheet says they are "temperature compensated" during the factory calibration procedure but in my experience that process is far from perfect. Over the temperature range I have tested (10 < °C < 40) the RH output varies by between 3 and 8%, so for all six devices temperature alone accounts for more than the claimed 2% precision. See the results section below for more detail. Any attempted recalibration procedure needs to be a function of both humidity and temperature.

UPDATE: The newer much improved data sheet now specifies that the quoted accuracy of ±2% is tested at a constant 25°C. That means the statement above about the temperature induced errors exceeding the data sheet specification is strictly no longer true. The new data sheet has no explicit specification for errors as a function of varying temperature.

Another temperature related defect I see is a sawtooth discontinuity in the humidity values when the temperature is varying around 25°C. Illustrated in Figure 6, I have no clear explanation for this but hypothesize it is a numerical artifact in the sensors' internal calibration. It is likely also related to the discontinuity visible in Figure 10 at around 25°C. Though it is dramatic and possibly even alarming to see discontinuous jumps in the RH output value, do note that the steps are <0.5% RH so well within the device specification.

Figure 6. All my measurements taken around 25°C show small discontinuous jumps in output RH values, but the effect is most obvious when the temperature is changing fairly rapidly. In such circumstance you expect larger absolute errors for reasons already described, but the discontinuous sawtooth was a surprise.

Quantity and Preparation of the Solutions

The less air volume inside the test vessel and the more surface area of the saturated solution, the quicker equilibrium is likely to be achieved. A deep bucket of solution will not particularly help. A wide shallow pan is likely to be better. It is sometimes recommended that you use a mound of dampened solids rather than an actual liquid solution, though for particular salts (e.g., calcium chloride which has a variety of hydrated solid crystalline forms) this will not work. In most cases I endeavoured to get the best of both methods by using a shallow (only 1-2mm depth) pool of saturated solution with a small mound of thoroughly wetted solid piled up in the middle. The idea here is to have all of the liquid, solid and gasous material phases in contact to allow the equilibrium to establish. A deep pool of solution could in theory stratify to be saturated at the bottom but have a less than saturated layer floating on top. Ideally the solution would be mixed during the experiment but this is not easy to arrange. If you have a magnetic stirrer, that would be a great addition to the set up. You must make sure the solution really is saturated. Make sure there are still solids present in the solution which refuse to dissolve even after several hours and ideally have those solids break the surface of the liquid.

A related problem is supersaturation. For some salts it is possible to heat a solution until all the solids dissolve and then cool it again without the salts precipitating back out as crystals. This happened to me a couple of times. It is simply avoided however, again by ensuring that some solid crystals are always present even when the solution is at its warmest. As long as there are any crystals present, the solution is unlikely to supersaturate as it cools.

Hygroscopic Materials

Hygroscopy is the tendency of a material to absorb water vapour into its surface and hold it within its molecular structure. Possibly surprisingly, many plastics (e.g., nylon, ABS, acrylic, polyurethane, polycarbonate, PET, PBT) which may be hydrophobic (liquid water will bead on the surface and run straight off) are in fact hygroscopic (absorb water vapour). This manifests as a sink or source of humidity other than the saturated solution, greatly extending equilibration time. If the salt solution is releasing vapour to the air, the walls of the test cell could be absorbing it meaning you need to run the experiment for a very long time before equilibrium is eventually achieved. If you then switch to a salt that yields a low humidity, the walls of the test vessel will slowly release that stored vapour back into the air. There is considerably more detailed discussion of this problem as it was a major factor for version 1 of this experiment. For the results presented herein however the test cells were glass and contained the absolute minimum of other components which seems to have eradicated this problem.

 

Results

Part 1: As a Function of Humidity

First we look at the varying response of the sensor to different reference humidities, all measured at a single fixed temperature.

Plot showing two days' worht of raw data logging
Figure 7. Two days' worth of raw data logging with the devices being swapped onto several different salts. This plot is primarily to illustrate what the data look like, how clean and stable the measurements are and how quickly the sensors respond. The readings all stabilize nicely in 1–4 hours after a change. Overall the data are good and easy to handle. This plot also illustrates the effectiveness of the PID controller at holding the cell at the set-point when central heating comes on and off in the house, day and night. One to two wiggles are seen in the temperature trace each time I open the cell and then it settles quickly. Lastly, the hysteresis-like behaviour is evident. The measurements on the left of the plot (stepping down from high humidity to low humidity) are consistently higher then measurements for the same salts on the right hand side (stepping back up from low humidity to high humidity).

Salt Reference Measured RH %
RH % A B C D E F
NaOH 7.42 10.17 11.16 11.29 10.20 9.60 8.88
LiCl 11.90 14.68 15.40 15.49 14.70 13.99 13.34
CaCl 32.07 34.74 34.69 34.96 35.02 34.22 33.01
MgCl 33.18 34.37 34.36 34.69 34.62 33.71 32.61
K2CO3 43.52 45.59 45.53 45.99 45.82 46.50 43.65
NH4NO3 65.58 65.98 65.27 66.23 65.61 66.83 65.87
NaCl 75.31 77.56 76.38 77.44 78.09 77.60 79.74
NH4SO4 80.31 82.54 80.91 81.97 82.51 81.88 85.42
KCl 85.57 86.73 84.86 85.93 86.73 86.06 90.94
K2NO3 93.77 96.43 93.36 94.43 95.21 95.80 99.90
H2O 100.00 99.9 99.4 99.9 99.9 99.9 99.9
Experimental results at 20.57°C. 'Reference RH' is the expected value taken from published literature interpolated to the temperature at the time the measurement was obtained. 'Measured RH' are the raw values as returned from the DHT22 / AM2302 devices. Temperature control was arbitrarily set to 20.57°C and data were only read when the measurements had stabilized to this set point ±0.03°C. Temperature is entirely defined by the readings from the AM2302 themselves without any external calibration.

Plots of measured vs. reference humidity for the six hygrometers
Figure 8. For all six devices there is very tight correlation between measured value and the expected reference value. I.e., the manufacturer's calibration is basically good. Magenta curves are quadratic polynomial best fits, though they hardly deviate from straight lines. On this scale you cannot tell much about systematic deviations though you can for example see that A, E and F hit saturation well below 100%.

Plots of (measured-reference) vs. reference humidity for the six hygrometers
Figure 9. The same data as Figure 8 with the same quadratic polynomials are replotted but the vertical axis is now the difference between measured and reference values. These plots effectively show the error that would result from using the raw, factory calibrated values directly from the sensor without applying any re-calibration.

Figure 9 above represents the simplest conclusions of the experiment. Devices A, D & E all consistently read about 2% high. Devices B & C read 4% high when dry but tend towards quite accurate at high humidity. Device F is the only one that shows large deviations from correct. It reads accurately below 60% but deviates quite strongly (up to 6% absolute error) at high humidity. I reiterate that these data are all at a fixed temperature and do not represent the thermal dependence of the devices. Depending on the expected use of the sensors, it will be shown below that thermal effects may lead to much larger errors in real World data.

Repeatability (on time scales of a few weeks) is about 1% RH as specified (Figures 9, 10, and 11). However on year time-scales I have seen such large changes in the sensor output that these corrections of 2 - 5% possibly become irrelevant.

I tried a variety of polynomial fits and data smoothing techniques (moving average, Savitzky-Golay filter, Tikhonov regularization) and nothing beyond the quadratic presented here seemed justifiable. The data scatter is sufficiently large that trying to quantify anything more complicated than a smooth, low-order trend over fits the available information. There is no physical justification for a quadratic fit over any other representation, e.g., a spline, but a quadratic correction function is attractive because it is very easy to apply and invert analytically.

There are some features which are seen identically in all six sensors which leads me to believe they are experimental systematics rather than faults in the sensors. For example, MgCl and CaCl are both expected to read ∼33%. For all six devices the CaCl data points are consistently higher than the MgCl points. It seems likely that one or other of the reference values I am using is inaccurate. (CaCl was later dropped from the experiment because of this, its temperature coefficient and the complicated behaviour of its various hydrated crystalline forms.) The same is true for other salts which consistently appear above or below the fit lines. E.g., NH4NO3 falls about 1% below the fit for every sensor. This seems to suggest that all absolute calibration values should only be believed to the ±1% level, which is no surprise. As noted earlier, data drawn from published journals frequently differ by 2-3% for any given salt; another illustration that these sensors are accurate enough to reveal limitations in the experiment rather than the reverse. For completeness I also note that similar discrepancies could arise through impurities in my salt samples.

There are systematic variations as a function of humidity as you would expect and a multi-point calibration is clearly helpful. However if I had used a single point calibration with NaCl at 75% as might reasonably be performed by any user of these devices, the results would not have been all that bad. Sensors A, D & E show only weak trends and a single point calibration would be adequate. They always read about 2% high. Device F is the only case where a one-point NaCl calibration could make 'corrected' results worse than doing nothing. It would lead you to believe that sensor reads 4% high, whereas in fact it is the most accurate of the six below 60% RH.

Part 2: As a Function of Temperature

This shows the varying response of the sensor to a fixed constant humidity as the temperature is varied.

The sensors were sealed for several weeks in the NaCl jar with the temperature incrementally stepped up and down between 10 and 40°C. The temperature was held at each set point for at least three hours, a reading being taken as the average humidity over a period of about one hour when the RMS temperature was stable to better then ±0.03°C. Working in Winter I was able to get a few data points as low as 6°C even though I have only a heater (no chiller) for thermal control. Results are shown in Figure 10. Device A drifts by only 3% RH as the temperature changes. Device F, again the worst of the six, varies by 8% RH. Most show a distinct wobble or discontinuity around 25°C, presumably related to the 'sawtooth' response already noted in Figure 6. Repeatability on timescales of days to weeks is typically better than 1% RH, though device C exhibits a greater variance.

Figure 10. Humidity measurements for the saturated NaCl sample as a function of temperature. Top panel shows a little less than one day of raw data logging. Lower panel shows the full results. The dark blue line shows the reference 'true' value for NaCl which declines only very slightly as temperature increases.

Repeating with LiCl and subtracting off the reference humidities gives Figure 11 which represents our final estimate of the measurement error as a function of temperature. All six sensors respond alike at low humidities (LiCl ∼13%) but behave quite differently at high humidity (NaCl ∼ 75%).

Figure 11. As Figure 10, but the vertical axis shows deviation from the expected reference value. This plot therefore has the systematic drift of the reference value removed and allows us to display two salts (NaCl and LiCl) on the same axes.

The fact that the two data sets in Figure 11 (NaCl 75% and LiCl 13%) do not overlap illustrates that a proper recalibration would need to be a bivariate function of both humidity and temperature, or alternatively a fully populated 2D look-up table. That is not a quick job. The full temperature range needs to be sampled multiple times for each salt in turn.

Part 3: As a Function Simultaneously of Temperature and Humidity

Finally, if the sensor is to be used to measure humidity under a range of varying temperatures a full bivariate calibration is required. Such a calibration over the rather moderate temperature range 20 < °C < 30 is shown in Figure 12. Over this narrow temperature range the thermal effects are not large but Figures 10 and 11 show that if the sensors are to be used over a wider 5 < °C < 40 range then the bivariate calibration would be necessary.

Figure 12. Surfaces showing deviation of the DHT22 output from the reference value as a function of both temperature and relative humidity.

The curves in Figure 9 should simply be cross sections through these surfaces. For A,B,C and F this is indeed the case. A is fairly flat. B and C both decline towards higher humidity and F diverges very steeply for RH values greater than 70%. For sensors D and E the comparison is less favourable. This would seem to indicate a change in behaviour of these sensors over the intervening few months which separate figures 9 and 12. Response has not grossly changed, they still consistently read a couple of per cent high, but the details of their response do look different.

Figure 13. Surfaces showing deviation of the DHT22 output from the reference value as a function of both temperature and relative humidity.

 

Temperature Accuracy

This document is about humidity measurements and was motivated by the fact that hygrometers are difficult instruments to build and calibrate. By contrast, the technology for manufacture of cheap and accurate thermometers is well established and we would expect the temperature output from the DHT22/AM2302 to be pretty good. This appears to be the case and for completeness I present the results here with little discussion. My apparatus contains no external reference against which to calibrate the temperature output and I therefore simply plot each sensor's offset from the mean of all six sensors. I am strictly only showing the difference between the sensors, but the absolute calibration looks likely to be good to ∼0.5°C with a relative drift of <0.1°C over a 30°C range. Repeatability for most of the sensors is ±0.01°C. (Repeatability for sensor D is ±0.02°C) These numbers easily meet or exceed the data sheet specifications.

Figure 14. Comparison of temperature outputs for the six devices. The test apparatus includes no precision, external temperature reference against which to compare, but at the very least these data demonstrate good temperature stability and repeatability even if they strictly tell us nothing about absolute calibration.

 

Long Term Stability and Failure of Sensor B

After about nine months of continuous use, one of my six devices started producing apparently deviant results. This is described in a separate account, but briefly, the problem turned out to be the control board inside the device overheating. Perhaps the on-board controller is not correctly switching itself to standby mode after each measurement. The sensors themselves were actually still working fine, but since the device was self-heating it did not represent the real ambient conditions.

 

Conclusions

Back near the top of this page.

If you have comments or suggestions feel free to contact me. robert -AT- kandrsmith.org

Lessons learned and advice for repeating this experiment

Having been through several iterations of trying to perform this experiment, here is a brief summary of lessons learned on how I would recommend setting the experiment up.

Future Plans

Possible future extensions of this work:


References

Some of these papers are in academic journals which require pay subscription access, so you may only be able to read the abstracts on-line.

  • Creahan J, 1991, WAAC Newsletter, 13, 1, pp.17-18, "Controlling Relative Humidity with Saturated Calcium Nitrate Solutions"
  • David S Madge, 1961, Entomologia Experimentalis et Applicata. 4, 143-147. "The control of relative humidity with aqueous solutions of sodium hydroxide"
  • Fossa M. & Petagna P., 2003, CMS NOTE 2003/024, "Use and calibration of capacitive RH sensors for the hygrometric control of the CMS tracker"
  • Greenspan L., 1977, J Res Nat Bur Stand - A Phys Chem, 81, 89, "Humidity fixed points of binary saturated aqueous solutions"
  • Merck KGaA, 2005, Publication W.283123, "Drying Agents"
  • O'Brien F.E.M, 1948, J. Sci. Instrum., 25, 73. "The Control of Humidity by Saturated Salt Solutions"
  • Rockland L.B., 1960, Analytical Chemistry, 32, 1375, "Saturated Salt Solutions for Static Control of Relative Humidity between 5 and 40 C"
  • Weast R.C., 1979, CRC Handbook of Chemistry and Physics, Boca Raton, Florida, Chemical Rubber Company, p. E-44.
  • CRC Handbook of Chemistry and Physics. 1995 by CRC Press
  • Wexler A. & Hasegawa S., 1954, J Res Nat Bur Stand, 53, 19, "Relative humidity-temperature relationships of some saturated salt solutions in the temperature range 0 to 50 C"

 

Acknowledgments

Though I designed and integrated the entire experiment, I must acknowledge the many open source projects, both software and hardware, that I used.

Almost vaguely related and possibly of interest is monitoring home radon.