Interfacing DHT11 sensor with PIC16F877A – CCS C compiler

This topic shows how to interface PIC16F877A microcontroller with DHT11 digital relative humidity and temperature sensor using CCS PIC C compiler.
The following topic shows how the DHT11 sensor works and how to simulate it with PIC16F877A using Proteus software.
Interfacing PIC16F877A with DHT11 (RHT01) sensor Proteus simulation

PIC16F877A DHT11 sensor hardware circuit

To see how the DHT11 works just read the previous topic and the sensor datasheet.

Interfacing PIC16F877A with DHT11 sensor circuit:

PIC16F877A DHT11 sensor and LCD circuit

The circuit is simple, there is the microcontroller PIC16F877A, DHT11 sensor and 1602 LCD to display humidity and temperature results.
The DHT11 sensor has 4 pins:
VCC : Positive power supply (+5V)
DATA : Sensor data input and output
NC : Not connected terminal
GND : Ground (0V)
A pull-up resistor must be added between the DHT11 data pin and VCC (+5V) pin as shown in the circuit schematic (4.7K ~ 10K).

Interfacing PIC16F877A with DHT11 humidity and temperature sensor C code:
The interfacing code was tested with CCS PIC C compiler version 5.051.
If you want to understand the code please read the DHT11 datasheet.
Variables Time_out and k are used to test reading time to avoid wrong data reception and microcontroller hanging.

PIC16F877A with DHT11 relative humidity and temperature sensor video:
The following video shows the project circuit connected in a breadboard.


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

6 thoughts on “Interfacing DHT11 sensor with PIC16F877A – CCS C compiler”

    1. Data are sent to the LCD in ASCII format and to convert a number to ASCII code we’ve to add 48 to it (for example ASCII code for 2 is: 2 + 48 = 50).

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top