Interfacing PIC MCU with DHT11 sensor – mikroC Projects

This topic shows how to interface Microchip PIC16F887 microcontroller with DHT11 (RHT01) relative humidity and temperature sensor (digital sensor) where the compiler used in this project is MikroElektronika mikroC Pro for PIC.

Related Projects:
DHT22 Sensor interface with PIC microcontroller – mikroC Projects
Interfacing PIC16F887 with DHT11 sensor – CCS C compiler

Hardware Required:

  • PIC16F887 microcontroller
  • DHT11 Sensor (RHT01)  —  datasheet
  • 16×2 LCD screen
  • 10k variable resistor (or potentiometer)
  • 4.7k ohm resistor
  • 5V Power source
  • Breadboards
  • Jumper wires

Interfacing PIC MCU with DHT11 sensor circuit:
Circuit diagram is shown below.

mikroc dht11 sensor circuit with PIC16F887

(All grounded terminals are connected together)

The internal oscillator of the microcontroller is used and MCLR pin function is disabled.

Interfacing PIC MCU with DHT11 sensor mikroC Pro for PIC code:
Configuration words are:
CONFIG1 : 0x2CD4
CONFIG2 : 0x0700

The configuration words can be changed from: Project –> Edit Project …

Functions used in the code:
void Start_Signal(void): used to send start signal to the DHT11 sensor.
unsigned short Check_Response(): used to detect the response signal which comes from the DHT11 sensor, this function returns 1 if OK and 0 if error.
unsigned short Read_Data(unsigned short* dht_data): this function reads 1 byte (8 bits) from the sensor, data are saved in the variable dht_data. Returns 0 if OK and 1  if error (time out error).

The video below shows a Proteus simulation of the project:


  1. Hi, congratulations for all what you do,

    Please how to display the decimal part of the temperature?

    1. The resolution of the DHT11 sensor is 1°C which means there is no decimal part (because the second byte of the temperature is always 0).
      DHT22 Provides a resolution of 0.1°C, that means always there is one number after the decimal point.

  2. Hello thank you for your effort, i would like to know why do i get time out! message on my lcd display, and how to fix that.
    I would be grateful

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.