Interfacing PIC16F877A with DHT11 sensor – Proteus simulation

PIC16F877A + DHT11 (RHT01) Proteus simulation

This topic shows how to interface DHT11 (RHT01) digital relative humidity and temperature sensor with PIC16F877A microcontroller, and how to simulate this interfacing using Proteus.

Note that for the simulation Proteus version should be 8.1 or higher. With these versions there is no need to install Proteus DHT11 library, it is included with the software, so don’t waste your time searching for dht11 Proteus library or dhtxx.mdf or dht11 module for Proteus, just use Proteus version 8.1 or higher.

About DHT11 (RHT01) relative humidity and temperature sensor:
The DHT11 sensor comes in a single row 4-pin package and operates from 3.3 to 5.5V power supply. It can measure temperature from 0-50 °C with an accuracy of ±2°C and relative humidity ranging from 20-90% with an accuracy of  ±5%. The sensor provides fully calibrated digital outputs for the two measurements. It has got its own proprietary 1-wire protocol, and therefore, the communication between the sensor and a microcontroller is not possible through a direct interface with any of its peripherals. The protocol must be implemented in the firmware of the MCU with precise timing required by the sensor.
dht11(rht01) sensor
The following timing diagrams describe the data transfer protocol between a MCU and the DHT11 sensor. The MCU initiates data transmission by issuing a “Start” signal. The MCU pin must be configured as output for this purpose. The MCU first pulls the data line low for at least 18 ms and then pulls it high for next 20-40 us before it releases it. Next, the sensor responds to the MCU “Start“  signal by pulling the line low for 80 us followed by a logic high signal that also lasts for 80 us. Remember that the MCU pin must be configured to input after finishing the “Start“ signal. Once detecting the response signal from the sensor, the MCU should be ready to receive data from the sensor. The sensor then sends 40 bits (5 bytes) of data continuously in the data line. Note that while transmitting bytes, the sensor sends the most significant bit first.
dht11(rht01) sensor start
Data consists of decimal and integral parts. A complete data transmission is 40bit, and the sensor sends higher data bit first.
Data format: 8bit integral RH data + 8bit decimal RH data + 8bit integral T data + 8bit decimal T data + 8bit check sum. If the data transmission is right, the check-sum should be the last 8bit of “8bit integral RH data + 8bit decimal RH data + 8bit integral T data + 8bit decimal T data”.
The DHT11 is a digital sensor so it sends 1’s and 0’s, but it is very important to know how it sends the digital data. The figure below shows how the sensor sends its information:
dht11(rht01) sensor timing
Interfacing PIC16F877A with DHT11 (RHT01) sensor circuit:
The following circuit schematic shows complete project circuit.

PIC16F877A DHT11 sensor interfacing circuit
The circuit is simple, there is the microcontroller PIC16F877A, DHT11 sensor and 1602 LCD to display humidity and temperature results.

Hardware Required:

  • PIC16F877A microcontroller   —> datasheet
  • 1602 LCD screen
  • DHT11 sensor
  • 10k Ohm resistor
  • 4.7k Ohm resistor
  • 10k Ohm variable resistor
  • 8 MHz crystal oscillator
  • 2 x 22pF capacitor
  • Bread board and jumper wires
  • PIC microcontroller programmer (PICkit 2, PICkit 3…)
Interfacing PIC16F877A with DHT11 (RHT01) sensor CCS C code:
The interfacing code is written with CCS PIC C compiler PCWHD 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 or microcontroller hanging.

Interfacing PIC16F877A with DHT11 (RHT01) sensor Proteus simulation video:
The following video shows Proteus simulation of this interfacing.

DHT11 Proteus simulation file download:
DOWNLOAD

References:
https://embedded-lab.com/


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

2 thoughts on “Interfacing PIC16F877A with DHT11 sensor – Proteus simulation”

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