PIC12F1822 + LCD + DHT22 (AM2302) Sensor – CCS C compiler

Interfacing PIC12F1822 with DHT22 (AM2302) humidity and temperature sensor

After interfacing the microcontroller PIC12F1822 with DHT11 sensor at:
DHT11 Interfacing with PIC12F1822 microcontroller – CCS C

Now let’s see how to interface this microcontroller with DHT22 (AM2302) digital relative humidity and temperature sensor.
In order to understand this example please read the DHT22 (AM2302) datasheet.
To see how to simulate the DHT22 Proteus simulation and timing diagram read the following topic:
PIC16F877A and DHT22(AM2302, RHT03) sensor Proteus simulation

And the following topic shows how to interface LCD with PIC12F1822:
Interfacing PIC12F1822 microcontroller with LCD display

Required Components:

  • PIC12F1822 Microcontroller
  • LCD (1602 or 2004 or any compatible)
  • DHT22 (AM2302 – RHT03) Sensor
  • 74HC595 Shift Register (74HC164, CD4094….)
  • 10K Variable Resistor
  • 4.7K Resistor
  • +5V Power Supply
  • Breadboard
  • Jumper Wires

PIC12F1822 + LCD + DHT22 (AM2302) Sensor Circuit:
PIC12F1822 DHT22 sensor and 1602 LCD circuit

PIC12F1822 microcontroller internal oscillator is used and MCLR pin function is disabled in the software.
To see how to use 74HC164 or CD4094 instead of 74HC595 go to the link above.
The DHT22 (AM2302 – RHT03) 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 sensor data pin and VCC (+5V) pin as shown in the circuit schematic (4.7K ~ 10K).

PIC12F1822 + LCD + DHT22 (AM2302) Sensor CCS C code:
If you want to understand the code please read the DHT22 datasheet.
Variables Time_out and k are used to test reading time to avoid wrong data reception and microcontroller hanging.
The microcontroller runs with its internal oscillator at 32MHz (8MHz + PLL).

PIC12F1822 + LCD + DHT22 (AM2302) Sensor Video:

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