- Name: PIC12F675 Temperature display.
- Description: Displays the temperature and humidity readings from a DHT11 sensor to a single seven segment LED module driven by a 74HC595 shift register. Written in C code.
- Author: Gavin Lyons.
In this folder the source code in C can be found in file dht11_12.c.
This program displays the temperature and humidity readings from a DHT11 sensor to a single seven segment LED module driven by a 74HC595 shift register. Written in C code.
The information is displayed in a scroll like fashion thru the single digit display. with a second between each display.
Program flow
- start
- display b (Begin)
- wait two seconds for sensor to stabilize
- Get data from sensor.
- display b (Begin)
- Display t (t for temperature)
- Display first digit of temperature reading i.e 1 for 19 C
- Display second digit of temperature reading i.e 9 for 19 C
- Display H (h for humidity)
- Display first digit of humidity reading i.e 3 for 38 %
- Display second digit of humidity reading i.e 8 for 38 %
- GOTO to 4
Error codes
- E = Comnmunications Error. No response to the PICs request signal from sensor.
- Dash = Communications Failure. Sensor responded to Start signal but failed to communicate data with PIC correctly.
- C = Checksum Error. Received all data from sensor but it failed checksum.
Communication Format with DHT11 can be separated into four stages.
- Request to sensor
- Response from sensor
- Data Reading 5 bytes from sensor
- Sum the 1st 4 bytes and check if the result is the same as CheckSum(5th byte)
GPIO function
GPIO function on PIC, 3 lines to 74HC595
- SER Serial / Data in pin 14 GP0
- RCLK / Latch pin 12 GP1
- SCLK / storage clock pin 11 GP2
- n/c
- DHT11 sensor line. GP4
- n/c
Connections from seven segment single module to shift register pins.
- A = pin 7 QH
- B = pin 6 QG
- C = pin 5 QF
- D = pin 4 QE
- E = pin 3 QD
- F = pin 2 QC
- G = pin 1 QB
- Dot n/c
For more info on pinlayout of seven segment display, see here.
https://en.wikipedia.org/wiki/Seven-segment_display
For more info on DHT11 sensor see datasheet here.
https://components101.com/sites/default/files/component_datasheet/DHT11-Temperature-Sensor.pdf