Sensors - Tranducers Circuits

Digital Temperature Sensor Circuit

Temperature sensors are commonly used to display the temperature in electrical equipment. The temperature of the room is displayed on the digital clock. It’s because of the temperature sensor that’s built inside it. I’ll show you how to make a Digital Temperature Sensor Circuit in this project. I’ll walk you through two circuits: one with an 8051 microcontroller and the other with an ATmega8 microcontroller.

The temperature is represented as an analogue number. As a result, it is transformed to a digital value and then displayed using an Analog-to-Digital Converter (ADC). The process of converting an analogue value to a digital value is described in this article.

Outline

  • Digital Temperature Sensor Circuit Principle
  • Digital Temperature Sensor Circuit using 8051
    • Circuit Diagram
    • Circuit Design
    • Code
    • Working
  • Digital Temperature Sensor Circuit using ATmega8
    • Circuit Diagram
    • Digital Temperature Sensor Circuit Design
    • Digital Temperature Sensor Circuit Simulation Video
    • How to Operate Digital Temperature Sensor Circuit?
    • Algorithm for Programming to Microcontroller
    • Digital Temperature Sensor Project Output Video
  • Applications of Digital Temperature Sensor Circuit

Digital Temperature Sensor Circuit Principle

This circuit’s fundamental idea is to take analogue temperature readings, convert them to digital values, and then show the digital temperature value on an LCD or 7-Segment Display.

Microcontrollers such as the 8051 and ATmega8 are used in this project. The ATmega8 contains a built-in analogue to digital converter with six 10-bit multiplexed channels. This eliminates the need for an external analogue to digital converter IC. The analogue temperature value is directly applied to the microcontroller’s input ADC channels. Internally, the analogue to digital conversion is done using the successive approximation method.

But in case of 8051 Microcontroller (AT89C51 is used in this project), it doesn’t have any built-in ADC like ATmega8. Hence, I am going to interface an external ADC IC ADC0804 with 8051 Microcontroller to convert the Analog temperature values to digital values. 

Digital Temperature Sensor Circuit using 8051

Circuit Diagram

Components Required

  • AT89C51 (8051 Microcontroller)
  • 11.0592 MHz Cystal
  • 2 X 33pF Capacitor
  • 10μF/16V Capacitor
  • 3 X 10KΩ Resistor
  • 1KΩ x 8 Resistor Pack
  • 10KΩ POT
  • 16X2 LCD Display
  • ADC0804
  • LM35
  • 150pF Capacitor
  • 330Ω Resistor
  • Power Supply
  • Connecting Wires
  • 8051 Programmer

Circuit Design

The digital out pins of the ADC IC  are connected to PORT3 Pins of 8051. PORT0 pins are pulled-up using 1KΩ Resistor pack and they are connected to the data pins of 16×2 LCD. P2.0 and P2.1 of 8051 are connected to RS and E of LCD.

LM35 is connected to Analog In pin VIN+ (Pin 6) of ADC0804. Essential components like oscillator, reset etc. are not explained here.

Code

  #include<reg51.h>
  #define lcd P0
  #define dat P3
  sbit rs=P2^0;
  sbit e=P2^1;
   
   
  void delay (int);
  void display (unsigned char);
  void cmd (unsigned char);
  void init (void);
  void string (char *);
  void intro (void);
  unsigned char degree[8]={0x0e,0x0a,0x0e,0x00,0x00,0x00,0x00,0x00};
  char i=0;
   
  void delay (int d)
  {
  unsigned char i=0;
  for(;d>0;d–)
  {
  for(i=250;i>0;i–);
  for(i=248;i>0;i–);
  }
  }
  void cmd (unsigned char c)
  {
  lcd=c;
  rs=0;
  e=1;
  delay(10);
  e=0;
  }
  void display (unsigned char c)
  {
  lcd=c;
  rs=1;
  e=1;
  delay(10);
  e=0;
  }
  void string (char *c)
  {
  while(*c)
  {
  display(*c++);
  }
  }
  void init (void)
  {
  cmd(0x38);
  cmd(0x01);
  cmd(0x0c);
  cmd(0x80);
  }
  void intro (void)
  {
  string(” Electronics “);
  cmd(0xc0);
  string(” Hub “);
  delay(1000);
  cmd(0x01);
  string(” Digital “);
  cmd(0xc0);
  string(” Thermometer “);
  delay(1000);
  cmd(0x01);
  cmd(0x40);
  for(i=0;i<8;i++)
  display(degree[i]);
  i=0;
  cmd(0x80);
  }
   
  void main()
  {
  unsigned int val=0;
  unsigned int temp=0;
  init();
  intro();
  dat=0xff;
  while(1)
  {
  if(i==0)
  {
  string(“Temp: “);
  i++;
  }
  val=dat*1.953;
  cmd(0x86);
   
   
  temp=(((val/10)%10)+48);
  display(temp);
   
  temp=((val%10)+48);
  display(temp);
  if(i==1)
  {
  display(0);
  string(“C”);
  i++;
  }
  delay(300);
  }
  while(1);
  }

Working

After making all the connections and burning the code onto the 8051 Microcontroller, turn ON the power supply. The LM35 Temperature Sensor provides the Analog Temperature Data to ADC0804, which it converts into Digital Values and sends to 8051.

Upon receiving the digital values, the 8051 Microcontroller performs a small calculation and then displays the temperature on the LCD.

Digital Temperature Sensor Circuit using ATmega8

Circuit Diagram

Digital Temperature Sensor

Circuit Components:

  • Resistors – R1 to R7 having the value of 330 Ohms each.
  • LM35 Temperature sensor
  • ATmega8 Microcontroller
  • 7 Segment Display

Digital Temperature Sensor Circuit Design

The ATmega8 microprocessor, LM35 temperature sensor, and 7 segment display make up the digital temperature circuit. One of the microcontroller’s ADC channels is coupled to the temperature sensor Lm35.

At Port C, the ATmega8 has six ADC channels, which are represented by the PC0-PC5 pins. This demonstrates that six analogue values can be interfaced. However, depending on the priority of the input channels, only one conversion is performed at a time. The ADC has a 10 bit resolution. Remember that Vref and Avcc are externally linked for conversion, as indicated in the diagram.

Until their unique purposes are stated, all of the port pins of the ATmega8 microcontroller serve as standard input/output pins. In order for Port C to function as an ADC channel, the controller’s ADC registers must be specified.

There are three connections on the Lm35 temperature sensor. The first pin is Vcc, the second pin is Output, and the third pin is Ground. When you place the flat surface towards you, the first pin is Vcc, the second pin is Output, and the third pin is Ground. The temperature sensor’s output pin is connected to the microcontroller’s PC0 pin, which is the first ADC channel.

Seven segment display has eight pins and one common pin. Leaving Dp, connect all the seven pins to port B. Connect A to PB0, B to PB1,_____, G to PB6. Seven segment display used here is common cathode display. Current limiting resistors were used between controller and the display.

Digital Temperature Sensor Circuit Simulation Video

https://youtu.be/uKRbCENwLHc

How to Operate Digital Temperature Sensor Circuit?

To begin, turn on the circuit. The microcontroller monitors the ADC channel for input on a continuous basis. The analogue temperature is converted to a digital value and shown on the seven segments. By clicking on the arrow marks below the display of the temperature sensor, you can increase or decrease the temperature value. The ADC channel transforms the input and displays it on the seven segment whenever there is a change. Because of differences in step size, the temperature value presented is double that of the original value. To display an accurate value, divide the amount by 2 and subtract 1 from it before displaying it.

Algorithm for Programming to Microcontroller

  • Initially select one channel from six ADC channels to which temperature sensor is connected and select source for reference voltage using ADMUX register.

Ex: ADMUX=01000000.
If ADC0 is the channel selected and Avcc with external capacitor at Aref pin is selected

  • Enable ADC and select prescalar value using ADCSRA register.

Ex: ADCSRA = (1<<ADEN)|(1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2)
If prescalar value of 128 is selected and enabling ADC. ADPS0, ADPS1, ADPS2, ADPS3 are pre scalar bits.

  • Check for the flag bit in ADCSRA register which sets after completion of the conversion.
  • Read the value from ADC register and assign value to port B which displays on seven segments.
  • The two digit value obtained can be displayed on two seven segments.

Digital Temperature Sensor Project Output Video

https://youtu.be/ELKW0bX1rk8

Applications of Digital Temperature Sensor Circuit

  1. In everyday life, digital temperature sensors are frequently utilised.
  2. They’re used in a variety of environmental settings.
  3. Air conditioners use digital temperature sensors that change the temperature based on the ambient temperature.
  4. They can be found in digital clocks that show both the room temperature and the time.
  5. It can be used in automotive dashboards to display engine temperature, preventing unexpected stops due to overheating.
  6. In the case of the ATmega8, no extra ADC IC is required for conversion.
Tags

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button
Close
Close