Fads to Obsessions and Beyond...




Free domain for life, exceptional technical support, website transfer

DHT-11 Humidity Sensor

A DHT-11 humidity and temperature sensor is interfaced with a PIC18F248 microcontroller to demonstrate humidity and temperature data recording via RS232 connection to a PC. The DHT-11 is tested within a DIY controlled humidity enclosure.

The Food Dehydrator project required a method to measure humidity in order to provide feedback control to the heating and cooling inputs. Humidity is a measure of the amount of water vapour in a volume of air, and indicates the likelihood of dew or fog. Higher humidity reduces the effectiveness of evaporation, and therefore the efficiency of the food dehydrator. Hence the need to measure humidity within the food dehydrator enclosure, to provide the input data to hardware designed to minimise humidity, and therefore maximise evaporation from/drying of food items.

Humidity measurement is of possible importance in other situations, in particular material storage scenarios, to prevent condensation, corrosion, mould, warping or other spoilage - highly relevant for foods, pharmaceuticals, chemicals, fuels, wood, paper, and many other products (1)

There are a number of possible devices that can be used to measure and regulate humidity (2), however, the DHT-11 humidity/temperature sensor provides a relatively simple and economic alternative. While the DHT-11 specified accuracy (at 25oC ±5 RH, repeatability ±1 RH) is not suitable for all applications, this level of accuracy coupled with the low-cost of the sensor makes it very suitable for the Food Dehydrator project.

The Aosong datasheet for the DHT-11 provides the following overview of the sensor. The DHT11 digital temperature and humidity sensor is a composite sensor that contains a calibrated digital signal output of the temperature and humidity. A dedicated digital collection module to the temperature and humidity sensing technology ensures that the DHT-11 has high reliability and excellent long-term stability. The sensor includes a resistive sense of wet components and an NTC temperature measurement device, connected with a high-performance 8-bit microcontroller."

Other features of the DHT-11 from the datasheet:

    • Resolution of temperature/humidity 16 bit
    • Repeatability: ±1% RH, ±0.2oC
    • Accuracy: at 25oC ±5% RH, ±0.2oC
    • Power supply: DC 3.5-5.5V
    • Supply Current: measurement 0.3mA standby 60μA

See the various sections below for circuit details, schematic diagrams, software/firmware and other details.


The schematic for the DHT-11 with connections to the PIC18F248 is given in the Schematics Section below. The ancillary circuitry for the PIC18F248 also includes connection via RS232 to a PC (enables PC control of the DS1307 to set parameters and retrieve data).

Power Supply

A typical "wall-wart" power-supply is used (a surplus laptop charger in this case) in conjunction with a voltage regulator (LM7805) to provide the regulated 5V required by the PIC microcontroller. The DHT-11 also requires a 3-5V supply, which is the same supply as for the PIC microcontroller in this case.

Circuit Operation

The schematic shows the basic minimum circuit to demonstrate the operation of the DHT-11 sensor, in this case, controlled/interfaced to a PIC18F248 microcontroller which also provides data output to PC via RS232 connection.

The LM7805 provides the 5V circuit voltage (stepping down from the 12V input from a "wall-wart" power-supply). The crystal X1 and associated capacitors C1 and C2 provide the oscillator for the PIC18F248 microcontroller. Incircuit serial programming (ICSP) of the PIC18F248 microcontroller is provided via connector J1 with switch SW1, resistor R1 and diode D2 providing voltage protecting during loading code into the PIC microcontroller.

Control signals to/from the PIC18F248 microcontroller are sent from a suitable port on the microcontroller (port B in this case) in order to control the DHT-11 and retrieve data.

Calibration

The DHT-11 sensor provides the relative humidity and temperature data digitally and notionally does not require calibration (datasheet stated accuracy: at 25oC ±5% RH, ±0.2oC).

Calibration checking of relative humidity data from the DHT-11 however can be performed using suitable binary saturated aqueous solutions of simple salts (common table salt can be used for a single point calibration check if desired). The results of such a check of the DHT-11 relative humidity data is reported in the Testing/Experimental Results Section below.

Firmware/Software

The DHT-11 provides simple digital control and a serial interface for retrieval of data using a "one-wire" protocol. The "one-wire" refers to the single data line, however, the sensor still obviously requires V+ and ground, so three wires are required to connect the sensor.

The "one-wire" bus requires a 5.1kohm pull-up resistor, so that when the bus is idle, the bus status is high. The communications protocol is a master-slave structure, in which the master initiates data transfer and then the slave device (DHT-11) responds with a single transmission of 40 bits (5 bytes, high byte first). The data format of the transmission is 8bit humidity integer data + 8bit humidity decimal data +8 bit temperature integer data + 8bit decimal temperature data +8 bit parity bit [however, in practical the "decimal" data bytes are observed to be always zero (0)]. The actual data transmission timing diagrams and steps of the protocol are well documentated in the datasheet, so are not reproduced here.

The PIC micrcontroller code is based upon the CCS routines (3) and (4). The code has been modified to provide access to all the functions available from the DHT-11, and enable the PIC microcontroller to transmit the collected data to a PC via RS232 connection.

The DHT11_lib.h library file contains various #define's used to specify the DHT-11 command set and functions. Various downloads are available in the table below.

Code Snippet 1: Interface to PIC18F248


#include "DHT11.h" 
#include "DHT11_Lib.h"
#zero_ram //all variables automatically initialised to 0
BYTE toggleReadCount;
long readCount;

#int_timer0  
void timer0_isr(void) { 
   set_timer0(TIMER0_PRELOAD); // Reload the Timer - prescaler = 1, period ~90us
   DHTexit = true;
} 

#int_timer1
void timer1_interrupt() { /* Timer1 has wrapped around to 0. */
   toggleReadCount=1;
   set_timer1(3035); //prescaler=8, 10Mhz, preload=3036 -> Freq 5hz, period=0.2sec
}

void get_DHT11_data(){
   unsigned char DHT_transmission = 0; //indicates if recieved data from DHT11 valid or error condition
   
   DHT_transmission = DHT11_get_data(); //send 'start' signal and receive data message from DHT11 (5 sequential bytes)
   switch (DHT_transmission){
      case 1:{
         printf("No Sensor Start\n\r");
         break;}
      case 2:{
         printf("No Sensor Found\n\r");
         break;}
      case 3:{
         printf("Checksum Error\n\r");
         break;}
      default: {
         printf("T: %2u.%01u \n\r",humidityTemp_data[2], humidityTemp_data[3]);
         printf("H: %2u.%01u \n\r",humidityTemp_data[0], humidityTemp_data[1]);
         break;}
   } 
}

void main() {
   char recChar;  //the received character from the serial port via keyboard  
   int16 ADCvalue;
   int16 numReadings = 0;
   float tempCelsius;
   int8 toggleReading = false;
   unsigned char DHT_transmission = 0; //indicates if recieved data from DHT11 valid or error condition
        
   printf("start\n\r");
   setup_adc_ports(RA0_RA1_ANALOG_RA3_REF); //Vref as input to RA3 (pin 5) on the PIC
   setup_adc(ADC_CLOCK_DIV_32 );
   set_adc_channel(0); //0 = AN0 (pin2), 1=AN1 (pin3), etc  
 
   setup_timer_0(T0_INTERNAL | T0_DIV_1 | T0_8_BIT);
   set_timer0(TIMER0_PRELOAD); //prescaler = 1, period ~90us 
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_8); //prescaler 8
   enable_interrupts(GLOBAL); 
   enable_interrupts(INT_TIMER0); 
   disable_interrupts(INT_TIMER1);
 
   DHT11_init(); //this is basically only a 1sec delay to ensure DHT11 settled after power-up  
 
   while(TRUE){  
      if (kbhit()) {      
         recChar = getc();;
         switch (recChar) {
            case 'd': //temperature from LM35
            case 'D': ADCvalue = Read_ADC();
                      tempCelsius = ADCvalue*0.24414; //10bit - 2.5V/1024 = 0.00244v/count
                      printf("LM35 = %2.1f Deg C\n\r",tempCelsius);
                      break;
            case 'h': //retrieve and print data from DHT-11
            case 'H': get_DHT11_data();                     
                      break;
            case 'r': //continous reading of DHT-11 and LM35
                      //from datasheet, not recommended to repeatedly read the sensors, 
                      //each read sensor interval is greater than 5 seconds can be obtained accurate data
            case 'R': if (toggleReading) {
                        toggleReading = false;
                        disable_interrupts(INT_TIMER1);
                        printf("Disable Continous Readings \n\r");
                      } else {
                        printf("Enable Continous Readings \n\r");
                        toggleReading = true;
                        readCount = 0;
                        toggleReadCount = 0;
                        numReadings = 0;
                        set_timer1(3035); //prescaler=8, 10Mhz, preload=3036 -> Freq 5hz, period=0.2sec
                        enable_interrupts(INT_TIMER1);
                      }
                      break;
            default:  printf("Unknown cmd\n\r");
                      break;
         }
      }
      if (toggleReadCount){
         toggleReadCount = 0;
         readCount++; //150 counts of 0.2sec = read every 30 secs
      }     
      if (readCount>=150) { //150 counts of 0.2sec = read every 30 secs       
         disable_interrupts(INT_TIMER1);     
         ADCvalue = Read_ADC();
         tempCelsius = ADCvalue*0.24414;
         numReadings +=1;
         if (DHT11_get_data() == 0) { //send 'start' signal and receive data message from DHT11 (5 sequential bytes)
            printf("%3Lu,%2u,%2u,%2.1f\n\r",numReadings,humidityTemp_data[2],humidityTemp_data[0],tempCelsius); 
            //DHT-11 temp, DHT-11 humidity, LM35 temp
         } else {
            printf("%3Lu,%2u,-,%2.1f\n\r",numReadings,DHT_transmission,tempCelsius);
             //DHT-11 error, "-", LM35 temp
         }
         readCount = 0;
         toggleReadCount = 0;
         set_timer1(3035); //prescaler=8, 10Mhz, preload=3036 -> Freq 5hz, period=0.2sec
         enable_interrupts(INT_TIMER1);        
      }
   }
}
                
                

Code Snippet 2: DHT11_lib.h library file


#define DHT11_pin PIN_B4            //DHT11 sensor connected to Port B Pin 4
#define TIMER0_PRELOAD  31
int8 DHTexit = false;
unsigned char humidityTemp_data[5]; //received data from DHT11, DHT11 transmits 5 bytes
                                    //which give humidity, temperature, CRC (see datasheet)
void DHT11_init()
/******************************************************************************
 * Function:     DHT11_init()
 * Dependencies:
 * Input:
 * Output:
 *
 * Overview:     initialise the DHT11
 * Notes:        Data sheet advises that upon startup, DHT11 requires 1 second
 *               to stabilise before will respond to transmission requests
 *****************************************************************************/
{
   delay_ms(1000);
}

unsigned char DHT11_get_byte()
/******************************************************************************
 * Function:     DHT11_get_byte()
 * Dependencies:
 * Input:        Pin to which DHT11 connected (DHT11_pin)
 * Output:       The byte received from the DHT11 (value)
 *
 * Overview:     Accumulates the input bits from the DHT11 to form a byte that
 *               represents the data read.
 * Notes:        The DHT11 has a custom 1-wire interface (see datasheet).
 *               The distinction between logical "0" and "1" is via pulse width
 *               of the input pulses transmited by the DHT11.
 *****************************************************************************/
{
   int8 iIndex; 
   int8 iValue = 0; 

   for(iIndex = 0; iIndex < 8 ; iIndex++) { 
      DHTexit = False; 
      set_timer0(TIMER0_PRELOAD); //prescaler = 1, period ~90us  
      while (!input(DHT11_pin) && !DHTexit); 
      delay_us(30); 
      if (input(DHT11_pin)) { 
         iValue = iValue |(1<<(7 - iIndex)); 
         DHTexit = False; 
         set_timer0(TIMER0_PRELOAD); //prescaler = 1, period ~90us 
         while (input(DHT11_pin) && !DHTexit); 
      } 
   } 
   return iValue; 
}

unsigned char DHT11_get_data()
/******************************************************************************
 * Function:     DHT11_get_data()
 * Dependencies: Global variable "humidityTemp_data[]" which stores received bytes
 * Input:        Pin to which DHT11 connected (DHT11_pin)
 * Output:       Status code representing the result of reading the transmission
 *               of the 5 bytes of sequential data from the DHT11 after the DHT11
 *               start transmission
 *               0 = received data OK
 *               1 = DHT11 did not respond to 'start' signal
 *               2 = DHT11 did not complete correct response to 'start' signal - not connected
 *               3 - CRC error, received data incorrectly
 *
 * Overview:     Initiates start transmission from the DHT11 using the timing
 *               requirements of the communications protocol in the DHT11 datasheet.
 *               Upon successful initiation of transmission, stores the 5 sequential
 *               bytes sent from teh DHT11 that represent the humidity, temperature and CRC
 * Notes:        Calls DHT11_get_byte() to decode pulse widths from DHT11 transmission to
 *               which form the individual bits of the transmitted bytes
 *****************************************************************************/
{
   unsigned char i = 0;
   int16 check_sum = 0;

   output_low(DHT11_pin); //PIC initiates data transmission from the DHT11
   delay_ms(25);          //by sending 'start' signal, LOW >18ms, HIGH 20-40us
   output_high(DHT11_pin);
   delay_us(30);

   DHTexit = false;            //DHT11 response starts/expected
   set_timer0(TIMER0_PRELOAD); //prescaler = 1, period ~90us  
   while (!input(DHT11_pin) && !DHTexit);
   if (DHTexit) { //data line should go low, if not DHT11 did not respond to 'start'
      return 1;
   }
   DHTexit = false;            //data line held low by DHT11 for 80us
   set_timer0(TIMER0_PRELOAD); //prescaler = 1, period ~90us  
   while (input(DHT11_pin) && !DHTexit);
   if (DHTexit) { //data line should go high, if not DHT11 not connected/responding
      return 2;
   } 
 
   for (i=0;i<=4;i+=1) { //transmission now starts of 5 bytes
      humidityTemp_data[i]=DHT11_get_byte(); //individual bits of each byte accumulated (pulse widths define logical 1 or 0
   }
   output_high(DHT11_pin); //data line HIGH end of transmission
   for (i=0;i<4;i+=1) {  //calculate check sum and compare to CRC byte
      check_sum += humidityTemp_data[i];
   }
   check_sum = check_sum & 0xFF;
   if (check_sum != humidityTemp_data[4]) {
      return 3; //checksum not equal to CRC byte = PROBLEM with transmitted bytes
   } else {
      return 0; //received data OK
   }
}
                

Downloads

Description Downloads
DHT-11 header and library files: CCS C Code Header File
Example PIC code with PIC18F248/PC serial interface: CCS C Source Code Download
Hex Code Download

Note: Image loading can be slow depending on server load.

  • DHT-11 Basic SchematicDHT-11 Basic Schematic

    Silver Membership registration gives access to full resolution schematic diagrams.

    DHT-11 Basic Schematic

This project did not require a PCB.

The construction was done using prototyping board. See the photographs and schematic diagram sections.

Qty Schematic Part-Reference Value Notes/Datasheet
Resistors
1R110k1/4W, 10% 
1R2100R1/4W, 10% 
Capacitors
2C1,C222pFCeramic 
1C30.33uF 
1C40.1uF 
1C6-C101uF 
Integrated Circuits
1U1PIC18F248PIC microcontroller datasheet
1U27805Linear Voltage Regulator  datasheet
1U3DHT-11DHT-11 Sensor datasheet
1U4MAX232ERS232 Driver/Receiver datasheet
Diodes
1D21N-4004 
Miscellaeous
1J1CONN-H55-pin connector for ICSP
1P1CONN9-pin connector for RS232
1SW1SW-SPDT 
1X110MHzCrystal Oscillator

Description Downloads
DHT-11 - Bill of Materials Text File Download

The initial test of the DHT-11 is simply ensuring that the sensor is returning data to the interfaced microcontroller. The temperature data is used in the first place to check the validity of retrieved data (and hence the communications protocol firmware/hardware) as the ambient temperature is easily independantly measured. A mercury glass bulb thermometer (and a LM35 temperature sensor) where used to check that the temperature data returned form the DHT-11 was correct.

Having satisfied that the firmware/hardware was connected/communicating appropriately, a means of testing the humidity sensing function of the DHT-11 was desired. The simplest method is probably just comparing the result obtained from the ambient environment to that reported by a local weather service versus time (and or breathing gently on the sensor which should record a temporary increase in "humidity"). Obviously such methods lack any rigour. This lead to the idea of constructing an enclosure (see the Photographs Section) that would enable adding/removing of water vapour to/from an enclosed portion of air (i.e. directly manipulating water vapour to affect the relative humidity of the test environment).

The DIY humidity enclosure (which had independent means of measuring temperature and a 12V fan in the enclosure to ensure rapid equilibration within the test volume) enabled adding of water vapour using a reservior while silica gel beads (a strong desiccant) provided the means for removing water vapour. The adding/removal of water vapour from the test volume could be performed without removing the enclosure lid.

A number of experimental trials were conducted with the DHT-11 in the DIY humidity enclosure to explore the effect of adding/removing water vapor (i.e. changing relative humidity) and environmental temperature (on both an enclosed and non-enclosed portion of contained humidified air). Such testing enabled verification that the DHT-11 humidity sensor was operating correctly and to what degree adhered to the specifications stated in the datasheet. Additionally, via the use of suitable binary saturated aqueous solutions of simple salts, the absolute accuracy and calibration of the DHT-11 could be assessed.

Adding/Removing Water Vapor from Contained Volume of Air

The DIY humidity enclosure was used to alternately add and remove water vapour from a contained volume of air, maintained at a constant ambient temperature. Representative data is presented in the following diagram (graph 1).

  • Graph 1: DHT-11 humidity data versus add/remove water vapour (contained volume air/constant temperature)

    DHT-11 humidity dataDHT-11 humidity data

    Silver Membership registration gives access to full resolution diagrams.

    Graph 1: DHT-11 humidity data

With respect to Graph 1, the DHT-11 can be seen to report temperature data in close agreement with the LM-35 temperature sensor, and that recorded manually via a mercury glass-bulb thermometer. Relative humidity was observed to increase as expected within the enclosed air volume after the water reservior was opended, and then again decrease when the silica gel desiccant was used to remove water vapour. The increase and decrease in relative humidity observed in graph 1 cannot be used to access DHT-11 response time, as the relative humidity within the enclosure is a function of the enclosure volume versus fan speed and size of the water and silica gel reservior surface areas.

Humidity Calibration

Humidity can be relatively easily calibrated by using saturated binary salt solutions that via chemical equilibrium produce known vapour pressures if kept inside a closed container (5).

The chemical compounds required for a full range of humidity calibration (<10% through to >95%) are perhaps difficult to obtain. However, for a more restricted (and perhaps generally appliable) range of ~35% to 85%, calcium chloride (pool water hardness increaser), sodium chloride (common table salt) and potassium chloride (fertiliser, hydroponic nutrient) provide a relatively easy means of undertaking a three-point calibration.

A number of saturated salt solutions were prepared in ~75ml plastic bottles by adding ~10ml of water and then successively adding the salt until the last portion did not dissolve. The solutions were allowed to stand for ~30 minutes to ensure that some solid salt material remained at the bottom of the plastic bottles, i.e., the solution was actually saturated (and if not, additional salt was added).

A grommet was installed in a lid that fits the bottles of the saturated salt solutions to enable the DHT-11 humidity sensor to measure the enclosed air space above the saturated salt solution (see Photographs Section). The humidity was then recorded, allowing sufficient time for the air space in the saturated salt solution bottles to equilibrate. An example data set of humidity versus time for various saturated salt solutions is presented in Graph 2 below.

Graph 3 summarises the calibration data obtained and plots the measured values of humidity versus the theoretical value that the particular saturated salt solution produces. The DHT-11 appears to read "low", the ±5% RH stated accuracy is plotted as verticle error bars for each data point on graph 3. It should also be noted that a saturated solution of sodium hydroxide (~9% RH) was also used, but the DHT-11 measured the humidity above this solution as ~35% RH. The datasheet states the measurement range of the DHT-11 is 20%RH to 90%RH. From the saturated sodium hydroxide solution result, it would appear the DHT-11 probably does not satisfactorily read to low levels of relative humidity (at least the unit that was tested).

  • Graph 2: DHT-11 humidity data versus binary saturated salt solutions

    DHT-11 humidity dataDHT-11 humidity data

    Silver Membership registration gives access to full resolution diagrams.

    Graph 2: DHT-11 humidity data versus binary saturated salt solutions

  • Graph 3: DHT-11 humidity calibration

    Graph 3: DHT-11 humidity calibrationGraph 3: DHT-11 humidity calibration

    Silver Membership registration gives access to full resolution diagrams.

    Graph 3: DHT-11 humidity calibration

The overall conclusion of the calibration of the particular DHT-11 tested is that the reported relative humidity readings were biased ~10% low. However, the calibration curve for the range 50%RH to 90%RH appears to be relatively linear. So as a low cost component, the DHT-11 appears to be useful to indicate "low" and "high" humidity and provide a relative numerical value that can be used as a "set point" to trigger further action (e.g. starting a heater element etc). However, if accurate humidity values are required for a particular application, and or relative humidity values below 30% are of importance, the DHT-11 does not appear to be useful.

Effect of Temperature on Humidity

The effect of ambient temperature on the humidity reading reported by the DHT-11 was also examined, in addition, comparing the result of temperature from the DHT-11 against a LM-35 sensor. The effect of temperature on humidity in both an enclosed air volume (inside the DIY humidity enclosure - see the Photographs Section) and non-enclosed air volume were studied. The results are presented in the following graph 4. The ambient temperature was altered using room air-conditioning, which affects the interpretation of the results. Alternative means of cooling were not readily available.

  • Graph 4: DHT-11 humidity vs temperature

    Graph 4: DHT-11 humidity vs temperatureGraph 4: DHT-11 humidity vs temperature

    Silver Membership registration gives access to full resolution diagrams.

    Graph 4: DHT-11 humidity vs temperature

In the case of the air volume under test being open to the surrounding room, when the room air-conditioning decreased the ambient temperature the observed humidity via the DHT-11 also decreased. When the air-conditioning was ceased and the room allowed to equilibrate with the surroundings, the humidity increased with increasing temperature. While decreasing humidity with decreasing temperature is to be expected (the cooler air has less thermal energy and hence less water vapour), the observation is more the result of the room air-conditioning removing water vapour due to the refrigeration/condensing method used to produce cool air (notice how room-airconditioning produces water/condensate at the rear of the air-conditioning units), which is re-circulated through the room.

In the case of the air volume under test being closed to the surrounding room, with cooling of the container volume being through the sides of the DIY humidity enclosure (an internal fan helps ensure the air volume equilibrates rapidly), the amound of water vapour within the air volume remains constant, and decreasing temperature would expect to see an increase in relative humidity. The actual observation is a slight decrease. This is possibly the result of condensation of a portion of the water vapour on the sides the humidity enclosure, due to non-thermal equilibrium of the container with the surrounding ambient air temperature.

Finally, the DHT-11 shows close agreement with reported temperature compared to the LM-35 sensor. However, the DHT-11 produces temperature data at "integer" resolution, and does not seem to provide the "decimal" place as described in the datasheet. Hence, the lack of a "decimal" place in the temperature data may restrict the utility of the DHT-11 temperature data (e.g. in PID control circuit or similar situation).


As a general precauation double check polarity of power connections etc before powering up the IC. The DHT-11 has a power supply requirement of DC 3.5-5.5V.

The DHT-11 physically is a relatively small package (15mm x 12mm x 6mm) with the PCB/components protected by a plastic shroud (see datasheet). So suitable cabling (3 wires) will be required if the DHT-11 is to be mounted remotely from the associated power supply and microcontroller circuitry.

Mounting/Location of DHT-11 Sensor

The datasheet (page 6) specifies a number of recommendations concerning the mounting and location of the DHT-11 sensor in order to maximise service life and accuracy/precision of reported data.

Avoid placing the DHT-11 in situations that have long-term condensation and or particularly dry environment. Avoid salt spray, acidic or oxidising gases as sulfur dioxide, hydrochloric acid. The recommended storage environment is as follows: Temperature: 10-40oC; Humidity: 60% RH or less. The datasheet also mentions problems with impact of chemical exposure to the sensor, temperature extremes and influence of strong sunlight/UV radiation.

DIY Humidity Enclosure

Any conveniently available enclosure is suitable, preferrably plastic so that the container walls do not overtly adsorb/desorb moisture (e.g. cardboard box is likely a poor choice for reproducible results). Also a container that has a tight fitting lid is optimal/easier to use.

A discarded plastic container (see Photographs Section) from 10kg of pool chlorine was used in this case. Grommets were used to enable cabling to reach the components inside the humidity enclosure, however, sealing holes with sticky tape would also be a practical solution if such items are not available (or want to minimise expense).

A "window" was cut into the side of the container and then sealed with plastic obtained from a 3L fruit juice container. This is entirely optional, but was convenient as operation of the fan etc could be visually verified without having to remove the container lid (and therefore affect the enclosed humidity).

A 12V fan was installed inside the container to facilitate equilibration of the air volume. A LM35 temperature sensor and a mercury glass bulb thermometer were also installed to provide ancillary temperature data to verify the operation of the DHT-11.

In order to change the humidity within the DIY enclosure, two reserviors that could be opened/sealed externally without removing the enclosure lid were included. One reservior contained water, while the other contained silica gel beads. The silica gel (in the "blue" form) is a strong desiccant and by removing water from the contained air volume enables decreasing the relative humidity. The silica gel beads change to a "pink" colour when saturated with water. The silica can be regenerated by heating in an oven.

DHT-11 Operation/Results

The communications protocol of the DHT-11 appears to be relatively "forgiving" and amenable to "bit banging". However, it is recommended to use interrupt driven routines (as discussed in the firmware code portion of the Testing/Experimental Results Section) as this enables following the DHT-11 communications timing requirements closer and avoids "blocking" functions within the code which can lead to the firmware/hardware "hanging" without user feedback.

It was found that a 10uF decoupling capacitor close to the supply of the DHT-11 did help with avoiding "glitches" - possibly due to the relatively long cables used with the implementation of the sensor. The datasheet does mention that with a 3.5V supply, the cable length should not exceed 20cm, otherwise measurement error could occur due to the voltage drop in the supply lines.

Despite the datasheet specifying that the humidity and temperature data is reported with a "decimal place", it was found in practice that data packets from the DHT-11 always contained "zero" for both the humidity and temperature "decimal data" (bytes 2 and 4 of the data transfer string).

Comments/Questions

No comments yet.

Add Comment/Question

Only Logged-In Members can add comments

"If we could sell our experiences for what they cost us, we'd all be millionaires".

Please donate any amount to help with hosting this web site.

If you subscribe (only $2/annum) you can view the site without advertisements and get emails abouts updates etc.

X

Sorry!

Only logged-in users with Silver Membership and above can download.


Silver Membership is only $2, so join now!