Site icon Ercan Koçlar

DHT11 Humidity and Temperature Sensor’s MikroC Library

dht11-nem-ve-sicaklik-sensoru

dht11-nem-ve-sicaklik-sensoru

This post is also available in: Türkçe (Turkish)



DHT11 HUMIDITY and TEMPERATURE Sensor

 

Specifications of the DHT11 Humidity and Temperature Sensor

DHT11 Humidity and Temperature Sensor Features
Positive Features Negative Features
  • It does not need calibration.
  • It provides digital output thanks to the included 8-bit MCU.
  • It does not occupy extra pins as it communicates bidirectionally over a single line
  • Data can be received over cable at distances of 20 meters and beyond
  • It is small in size, cheap, and has its own housing.
  • It provides the temperature value in °C
  • The system itself has an 8-bit checksum for data verification.
  • It uses the 1-wire protocol. Therefore, precise timing is required when reading data.
  • It has low resulation. ( the resulation 1 bit)
  • It cannot be used with corrosive liquids or other chemicals, only with water.
  • Response time is between 6 to 30 seconds.
  • It should not be used for purposes such as emergency situations and device shutdown.
Humidity Measurement Values
Parameters Conditions Min Average Max
Resolution   1%RH 1%RH(8 bit) 1%RH
Repeatability     ±1%RH  
Accuracy
at 25 °C
at 0-50 °C
±4%RH
±5%RH
Measurement Range
at 0 °C
at 25 °C
at 50 °C
30%RH
20%RH
20%RH
90%RH
90%RH
80%RH
Response Time (s) 1/e(63%)25 °C,
1m/s Air
6 s 10 s 15 s
Hysteresis     ±1%RH  
Long-term Accuracy General   ±1%RH per year  
 
Temperature Measurement Values
Parameters Conditions Min Average Max
Resolution   1 °C ( 8 bit) 1 °C(8bit) 1 °C(8bit)
Repeatability     ±1 °C  
Accuracy   ±1 °C   ±2 °C
Measurement Range   0 °C   50 °C
Response Time (s) 1/e(63%) 6 s   30 s
 
DHT11 humidity and temperature sensor

 

DHT11 Working Protocols

 

DHT11 General Working System

The general working principle of the DHT11 humidity and temperature sensor is shown.

 

DHT11 Communication System

The communication system with DHT11 humidity and temperature sensor is shown.

 

DHT11 Data Reading System

The data reading and interpretation system of the DHT11 humidity and temperature sensor is shown.

 

DHT11 Complete Communication System and Data Control

The complete process involving the DHT11 humidity and temperature sensor is shown.

Checking the Accuracy of Data from DHT11 – Checksum

The oscilloscope examination of the DHT11 humidity and temperature sensor is shown.

 

DHT11 Pin Functions

Pins of the DHT11 the humidity and temperature sensor shown.
Pin Name Function
VDD +5v power supply
DATA Data exchange occurs
x Pin3 is not used
GND Ground

 

DHT11 Humidity and Temperature Sensor Circuit

Circuit Diagram

The DHT11 humidity and temperature sensor circuit diagram

Necessary Materials

Circuit Construction

The general view of the DHT11 humidity and temperature sensor circuit

 

DHT11 humidity and temperature sensor close-up view

 

The DHT11 Humidity and Temperature Sensor MikroC Library

 

Functions

 

DHT11_ISI_NEM_VERI_OKUMA The Function

Function : unsigned char DHT11_ISI_NEM_VERI_OKUMA(unsigned char *veri)

Purpose : To retrieve the humidity and temperature data from the sensor.

Parameters :

How to Use :

DHT11_ISI_NEM_VERI_OKUMA(data);//Alınan veriler "data" adındaki diziye aktarılır.

Feedback :

 

Application of Functions

Reading DHT11 Humidity and Temperature Values

//GLCD Pin tanımalamarı
char SAPTRIS at trisd;//data portları
char SAPDATA_giris at portd;
char SAPDATA_cikis at latd;
sbit SAP1024_RD at RC1_bit ;       //GLCD RD UCU BAĞLANTI PİNİ
sbit SAP1024_CE at rc2_bit ;       //GLCD CE UCU BAĞLANTI PİNİ
sbit SAP1024_CD at Rc3_bit ;       //GLCD C/D UCU BAĞLANTI PİNİ
sbit SAP1024_RST at Rc4_bit ;      //GLCD RST UCU BAĞLANTI PİNİ
sbit SAP1024_FS at Rc5_bit ;       //GLCD FS UCU BAĞLANTI PİNİ
sbit SAP1024_WR at RC0_bit ;       //GLCD wr UCU BAĞLANTI PİNİ

sbit SAP1024_RD_Direction  at TRISC1_bit;       //GLCD RD UCU BAĞLANTI PİNİ
sbit SAP1024_CE_Direction  at TRISC2_bit;       //GLCD CE UCU BAĞLANTI PİNİ
sbit SAP1024_CD_Direction  at TRISC3_bit;       //GLCD C/D UCU BAĞLANTI PİNİ
sbit SAP1024_RST_Direction at TRISC4_bit;      //GLCD RST UCU BAĞLANTI PİNİ
sbit SAP1024_FS_Direction  at TRISC5_bit;       //GLCD FS UCU BAĞLANTI PİNİ
sbit SAP1024_WR_Direction  at TRISC0_bit;       //GLCD FS UCU BAĞLANTI PİNİ

//DHT11 Pin Tanımlamaları
sbit DHT11_DATA at RC7_bit;
sbit DHT11_DATA_Direction at TRISC7_bit;


void  main()
{
    unsigned char veri[5];//verinin atanacağı dizi
    unsigned char deger;
    char txt[15];
    ADCON1=0b00000001;
    CMCON=7;
    SAP1024_INIT(240,128,6);
    

    //veriler ekranda daha anlamlı gözükebilmesi için başlıklar oluşturulur
    SAP1024_YAZI_YAZMA(32-9,10,"NEM DEGERI:%");
    SAP1024_YAZI_YAZMA(36,12,"'C");
    SAP1024_YAZI_YAZMA(32-9,12,"ISI DEGERI:");

  while(1)
    {
      do{
         deger= DHT11_ISI_NEM_VERI_OKUMA(veri);
         delay_ms(6500);}// DHT11 tepki süresi 6-10 saniye arası oldugundan 6,5 saniyede 1 kez veri alınır.
      while(deger!=1);//veri doğruluğu kontrol edilir veriler doğru gelmediği müddetçe döngüde kalır 

      WordToStr(veri[0],txt);//nem verisi stringe çevirilir
      SAP1024_YAZI_YAZMA(32,10,txt);
      SAP1024_YAZI_YAZMA(32-9,10,"NEM DEGERI:%");
    
      WordToStr(veri[2],txt);//sıcaklık verisi stringe çevirilir
      SAP1024_YAZI_YAZMA(31,12,txt);
      SAP1024_YAZI_YAZMA(36,12,"'C");
      SAP1024_YAZI_YAZMA(32-9,12,"ISI DEGERI:");

    }

}
The result of the DHT11 humidity and temperature measurement is shown.

The Operation Video


Result


Library Files


References


 

This post is also available in: Türkçe (Turkish)

Exit mobile version