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:

Leave a Reply

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