Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Celsius and Fahrenheit scale digital thermometer using 8051 microcontroller (AT89C51)

By Himanshu Choudhary

Fahrenheit scale digital thermometer is a temperature indicator which displays temperature in Fahrenheit scale. It is similar to Celsius scale digital thermometer, except a little modification in the microcontroller program. The temperature sensed in Celsius scale in the Celsius scale thermometer project is converted into the Fahrenheit scale temperature just by using the Celsius to Fahrenheit conversion formulae. This project also uses 8051 microcontroller (AT89C51).


 

 

A digital thermometer can be easily made by interfacing a temperature sensor to the microcontroller AT89C51. The temperature sensor used in the project is LM35. The LM 35 IC generates a 10mV variation to its output voltage for every degree Celsius change in temperature. The Output of the temperature sensor is analog in nature so we need an analog to digital convertor for converting the analog input to its equivalent binary output. The ADC 0804 is the analog to digital convertor IC used in the project. 0804 is a single channel convertor which converts the analog input up to a range of 5V to an equivalent 8-bit binary output.

 

The step size is defined by the voltage applied at the Vref/2 pin of the ADC IC. For example, if the voltage at Vref/2 pin is set to 1.28V then ADC has a step size of 10 mV. So if the input voltage is 1V the equivalent binary output of ADC will be 100 or 0110 0100 in binary. The 8 bit binary output of the ADC is incremented by one for every 10 mV rise of input voltage. Different step size can be selected by changing the voltage input to the Vref/2 pin. The step size of the ADC is calibrated using a preset to match the actual temperature. Once the ADC is calibrated it will give the correct output further. The binary output of ADC is fed parallel to a port of the microcontroller . The microcontroller reads the input through ADC and displays the corresponding decimal value on LCD indicating the temperature.

The value is converted to the Fahrenheit scale by employing the Celsius to Fahrenheit conversion formulae in the microcontroller program.
 
 

Project Source Code

###

//Program to display temperature in Celsius and Farenheit scale.

#include<reg51.h>
#define port P3
#define adc_input P1
#define dataport P0
#define sec 100
sbit rs = port^0;
sbit rw = port^1;
sbit e = port^2;

sbit wr= port^3;
sbit rd= port^4;
sbit intr= port^5;

int test_intermediate3=0, test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,0};

void delay(unsigned int msec )
{
    int i ,j ;
    for(i=0;i<msec;i++)
        for(j=0; j<1275; j++);
}

void lcd_cmd(unsigned char item)    // Function to send commands to LCD
{
    dataport = item;
    rs= 0;
    rw=0;
    e=1;
    delay(1);
    e=0;
    return;
}

void lcd_data(unsigned char item)    // Function to send data to LCD
{
    dataport = item;
    rs= 1;
    rw=0;
    e=1;
    delay(1);
    e=0;
    return;
}

void lcd_data_string(unsigned char *str)  // Function to string to LCD
{
    int i=0;
    while(str[i]!='')
    {
        lcd_data(str[i]);
        i++;
        delay(10);
    }
    return;
}

void shape()        // Function to make the shape of degree symbol
{
    lcd_cmd(64);
    lcd_data(2);
    lcd_data(5);
    lcd_data(2);
    lcd_data(0);
    lcd_data(0);
    lcd_data(0);
    lcd_data(0);
    lcd_data(0);
}
       
void convert()     // Function to convert the values of ADC into numeric value to be sent to LCD
{
    int    s;
    lcd_cmd(0x81);      
    delay(2);
    lcd_data_string("TEMP:");
    test_final=(((9*test_intermediate3)/5)+32);
    s=test_final/100;
    test_final=test_final%100;
    lcd_cmd(0x88);
    if(s!=0)
    lcd_data(s+48);
    else
    lcd_cmd(0x06);
    s=test_final/10;
    test_final=test_final%10;
    lcd_data(s+48);
    lcd_data(test_final+48);
    lcd_data(0);
    lcd_data('F');
    lcd_data(' ');

    test_final=test_intermediate3;
    lcd_cmd(0xc1);        //Setting  cursor to first position of first line
    delay(2);
    lcd_data_string("TEMP:");
    s=test_final/100;
    test_final=test_final%100;
    lcd_cmd(0xc8);
    if(s!=0)
    lcd_data(s+48);
    else
    lcd_cmd(0x06);
    s=test_final/10;
    test_final=test_final%10;
    lcd_data(s+48);
    lcd_data(test_final+48);
    lcd_data(0);
    lcd_data('c');
    lcd_data(' ');
    delay(2);
}

void main()
{
    int i,j;
    adc_input=0xff;
    lcd_cmd(0x38);        //2 Line, 5X7 Matrix display
    lcd_cmd(0x0c);        //Display On, Cursor blinking
    delay(2);
    lcd_cmd(0x01);        // clear screen
    delay(2);

    while(1)
    {
        for(j=0;j<3;j++)
        {
            for(i=0;i<10;i++)
            {
                delay(1);
                rd=1;
                wr=0;
                delay(1);
                wr=1;
                while(intr==1);
                rd=0;
                lcd_cmd(0x88);
                test_intermediate1[i]=adc_input/10;
                delay(1);
                intr=1;
            }
            for(i=0;i<10;i++)
            test_intermediate2[j]=test_intermediate1[i]+test_intermediate2[j];
        }

        test_intermediate2[0]=test_intermediate2[0]/3;
        test_intermediate2[1]=test_intermediate2[1]/3;
        test_intermediate2[2]=test_intermediate2[2]/3;
        test_intermediate3=test_intermediate2[0]+test_intermediate2[1]+test_intermediate2[2];
        shape();
        convert();
    }
}

###


Circuit Diagrams

Circuit-Diagram-of-Celsius-and-Fahrenheit-scale-digital-thermometer-using-8051-microcontroller-AT89C51

Project Components

  • ADC0804
  • AT89C51 Microcontroller
  • LCD
  • LM35 Temperature Sensor
  • Preset

Project Video


Filed Under: 8051 Microcontroller
Tagged With: 8051, display, lcd, microcontroller, thermometer
 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Pull up via GPIO
  • Variable Phase shift control circuit for PWM circuit
  • Fpga wake up
  • Vco cadencd
  • Thyristor Gate Drive

RSS Electro-Tech-Online.com Discussions

  • HV Diodes
  • DIY bluetooth speaker
  • Question about ultrasonic mist maker
  • Disabled son needs advice please
  • RF modules which can handle high number of bytes per second
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering