Introduction
A digital thermometer is an essential tool for measuring temperature with high precision and ease. Utilizing the 8051 microcontroller, we can design a digital thermometer that reads the temperature from a sensor and displays it on an LCD. This project involves interfacing a temperature sensor (such as the LM35), an ADC (Analog to Digital Converter), and an LCD with the 8051 microcontroller.
Components Required
8051 Microcontroller (e.g., AT89S52)
LM35 Temperature Sensor
ADC0804 (8-bit ADC)
16x2 LCD Display
Resistors (10kΩ, 1kΩ)
Capacitors (33pF, 100μF)
Crystal Oscillator (11.0592 MHz)
Breadboard and Connecting Wires
Power Supply (5V)
Circuit Diagram
The circuit consists of the LM35 sensor connected to the ADC0804, which in turn interfaces with the 8051 microcontroller. The LCD display is used to show the temperature readings.
+5V ----- +5V
|
|
LM35
+---+
+5V --|VCC|
| |
|OUT |------- AIN (ADC0804)
| |
GND --|GND |
+---+
Pin Connections
LM35 Sensor:
VCC to +5V
GND to Ground
Output to Vin+ of ADC0804
ADC0804:
Vin+ to LM35 output
VCC to +5V
GND to Ground
CS to Ground
RD to P2.0 of 8051
WR to P2.1 of 8051
INTR to P2.2 of 8051
D0-D7 to P1.0-P1.7 of 8051
Vref/2 to 2.5V (using a voltage divider)
LCD:
RS to P3.6 of 8051
RW to Ground
E to P3.7 of 8051
D4-D7 to P2.4-P2.7 of 8051
Software Implementation
The code is written in C using Keil uVision IDE. It involves initializing the ADC and LCD, reading the analog value from the sensor, converting it to a digital value using the ADC, and then displaying it on the LCD.
#include <reg51.h>
#include "lcd.h"
sbit RD = P2^0; // Read signal for ADC
sbit WR = P2^1; // Write signal for ADC
sbit INTR = P2^2; // Interrupt signal from ADC
void delay(unsigned int count) {
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void adc_init(void) {
WR = 0; // Start conversion
delay(1);
WR = 1; // End conversion
}
unsigned char adc_read(void) {
unsigned char value;
while(INTR); // Wait for conversion to complete
RD = 0; // Read the value
value = P1; // Get the digital value
delay(1);
RD = 1;
return value;
}
void main() {
unsigned char temp;
float temperature;
lcd_init(); // Initialize LCD
adc_init(); // Initialize ADC
while(1) {
temp = adc_read(); // Read digital value from ADC
temperature = (temp * 5.0 / 255.0) * 100; // Convert to temperature
lcd_cmd(0x80); // Move cursor to first line
lcd_write_string("Temp: ");
lcd_cmd(0xC0); // Move cursor to second line
lcd_write_number(temperature); // Display temperature value
delay(1000); // Update every second
}
}
Explanation
Initialization:
LCD Initialization: The lcd_init() function sets up the LCD.
ADC Initialization: The adc_init() function prepares the ADC for conversion.
Reading Temperature:
The adc_read() function reads the analog voltage from the LM35 sensor, converts it to a digital value using the ADC0804, and returns it.
Temperature Conversion:
The digital value is converted to temperature using the formula: temperature = (value 5.0 / 255.0) 100, assuming a 5V reference voltage for the ADC.
Displaying Temperature:
The temperature is displayed on the LCD using lcd_write_string() and lcd_write_number() functions.
Conclusion
This project demonstrates the use of the 8051 microcontroller to create a digital thermometer. The system is capable of reading temperature data from the LM35 sensor, converting it to a digital format using the ADC0804, and displaying it on an LCD. This project is a great way to learn about sensor interfacing, ADCs, and LCDs with microcontrollers.
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Comentaris