Anda di halaman 1dari 16

International Journal of Research p-ISSN: 2348-6848

e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Temperature Sensor Using Microcontroller

Majed Kamil Qetheth Prof. D . Karuna Sagar


Master of Science in Physics (Applied Electronics) Department of Physics
University College of Science University College of Science
Osmania University Osmania University

Abstract:
Data acquisition is the process of converting the resulting samples (analog
sampling signals (voltage, current, Waveforms) into digital numeric values for
temperature, pressure, or sound) that processing and manipulating (as per the
measure real world physical conditions and requirements) by a computer.

The components of data acquisition systems include:

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1147


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Sensors, to convert physical parameters 1. Real-time monitoring the ambient


to electrical signals. temperature (in both the 0 C and 0 F
Signal conditioning circuitry, to convert scales) on the LCD-Screen
sensor signals into a form that can be 2. Log the Rise and Fall of temperature
converted to digital values. with heating and cool-down of the
Analog-to-digital converters, to convert LM35 Sensor.
conditioned sensor signals to digital
values.
INTRODUCTION
Data acquisition applications are usually
Digital thermometer (Celsius and
controlled by software programs
Fahrenheit scale) using 8051
developed using various general
microcontrolle r (AT89S52)
purpose programming languages such
Celsius and Fahrenheit scale
as Assembly,BASIC,C,C++,C#,Fortran,
thermometer displays the ambient
Java,LabVIEW,Lisp, Pascal, etc.
temperature through a LCD display. It
including various Open Source Software
consists of two sections. One is that which
as well.
senses the temperature. This is a temperature
Stand-alone data acquisition systems are
sensor LM 35. The other section converts
often called data-loggers.
the temperature value into a suitable number
in Celsius scale which is done by
In our project, the Temperature data
the ADC0804. The temperature sensed in
was monitored by using the Microcontroller
Celsius scale is converted into the
& LCD. The Project has an Inbuilt Data
Fahrenheit scale temperature just by using
logger which is used to Log the Temperature
the Celsius to Fahrenheit conversion
data on the LCD. A data logger is any
formulae through a little modification of the
device that can be used to store data.
code in the microcontroller program.

The main objectives of the Project are :

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1148


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Design and Implementation

Figure 1: (ModularBlock Diagram)

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1149


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Flow Chart (Coding Logic)

START

Initialization of Micro-Controller
(AT89S52)

Initialization of ADC (0804)

Initialization of LCD (JHD 162A)

Initialization of Temp. Sensor (LM35)

LM35 sends temperature data


(analog) to A2D Converter

A2D Converter (0804) converts analog temp.


data into digital (binary) and forwards to C
(AT89S52)

Micro-Controller (AT89S52) converts Binary to


Decimal and sends it to LCD

Temperature is displayed on LCD

FINISH
Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1150
International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Figure 2: Flow chart

Algorithm (Functional)

1) Initialize LCD 15) Display 2 digit temperature to LCD


2) Start the ADC to measure temp 16) Compare temp value with threshold
3) Read ADC byte values
4) Convert ADC byte into temperature 17) hex value of current temperature
and record into the flash 18) hex value of threshold temperature
5) Increase no of samples by one 19) LED on if current temperature more
6) Display temp on LCD than threshold value
7) Compare the temperature with the 20) LED off if current temperature
threshold value more than threshold value
8) Waiting time according to recording 21) Provide measuring interval delay
interval 22) Converts the ADC 8 bit output to 2-
9) Start the conversion of ADC digit temperature value in ASCII
(conversion frequency is around 23) Convert the 4 digit decimal into 2
640KHz) byte hex
10) Convert ADC digital output into 24) Input in t3 t2 t1 t0 and output in
temperature and store its 2 digit hex1 hex0
value into flash 25) Provide threshold value range from
11) Increase number of samples by one 20 to 49 degree celcius for user
12) Convert decimal to hexadecimal 26) Provide recording interval range
value from 01 to 99 secs for user
13) Add one to hex value of no of 27) Display a 16 byte in ASCII string
samples on LCD
14) Convert hex value to decimal 28) Send the command to LCD
number 29) Send ASCII data to LCD

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1151


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

THE SOURCE CODE

The Embedded-C Program Code which is dataport = item;


rs= 1;
burnt onto the Micro-Controller is as rw=0;
e=1;
under : delay(1);
e=0;
//Program to display temperature in Celsius return;
}
and Farenheit scale.
void lcd_data_string(unsigned char *str) // Function
#include<stdio.h> to string to LCD
#include<string.h> {
#include<Regx52.h> int i=0;
#define port P3 while(str[i]!='\0')
#define adc_input P1 {
#define dataport P0 lcd_data(str[i]);
#define sec 100 i++;
sbitrs = port^0; delay(10);
sbitrw = port^1; }
sbit e = port^2; return;
sbitwr= port^3; }
sbitrd= port^4;
sbitintr= port^5; void shape() // Function to make the shape of
degree symbol
int test_intermediate3=0, {
test_final=0,test_intermediate1[10],test_intermediate lcd_cmd(64);
2[3]={0,0,0}; lcd_data(2);
lcd_data(5);
void delay(unsigned intmsec ) lcd_data(2);
{ lcd_data(0);
int i ,j ; lcd_data(0);
for(i=0;i<msec;i++) lcd_data(0);
for(j=0; j<1275; j++); lcd_data(0);
} lcd_data(0);
}
void lcd_cmd(unsigned char item) // Function to
send commands to LCD void convert() // Function to convert the values of
{ ADC into numeric value to be sent to LCD
dataport = item; {
rs= 0; int s;
rw=0; lcd_cmd(0x81);
e=1; delay(2);
delay(1); lcd_data_string("TEMP:");
e=0; test_final=(((9*test_intermediate3)/5)+32);
return; s=test_final/100;
} test_final=test_final%100;
lcd_cmd(0x88);
void lcd_data(unsigned char item) // Function to if(s!=0)
send data to LCD lcd_data(s+48);
{

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1152


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

else delay(2);
lcd_cmd(0x06);
s=test_final/10; while(1)
test_final=test_final%10; {
lcd_data(s+48); for(j=0;j<3;j++)
lcd_data(test_final+48); {
lcd_data(0); for(i=0;i<10; i++)
lcd_data('F'); {
lcd_data(' '); delay(1);
rd=1;
test_final=test_intermediate3; wr=0;
lcd_cmd(0xc1); //Setting cursor to first position delay(1);
of first line wr=1;
delay(2); while(intr==1);
lcd_data_string("TEMP:"); rd=0;
s=test_final/100; lcd_cmd(0x88);
test_final=test_final%100; test_intermediate1[i]=adc_input/10;
lcd_cmd(0xc8); delay(1);
if(s!=0) intr=1;
lcd_data(s+48); }
else for(i=0;i<10; i++)
lcd_cmd(0x06);
s=test_final/10; test_intermediate2[j]=test_intermediate1[i]+test_inter
test_final=test_final%10; mediate2[j];
lcd_data(s+48); }
lcd_data(test_final+48);
lcd_data(0); test_intermediate2[0]=test_intermediate2[0]/3;
lcd_data('c'); test_intermediate2[1]=test_intermediate2[1]/3;
lcd_data(' '); test_intermediate2[2]=test_intermediate2[2]/3;
delay(2);
} test_intermediate3=test_intermediate2[0]+test_interm
ediate2[1]+test_intermediate2[2];
void main() shape();
{ convert();
inti,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

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1153


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

PROJECT CIRCUIT DIAGRAM

Figure 3 (a): Circuit Diagram, (b) Project Kit

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1154


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

CIRCUIT FUNCTIONING IC. For example, if the voltage at Vref/2 pin


is set to 1.28V then ADC has a step size of
A digital thermometer can be easily
10 mV. So if the input voltage is 1V the
made by interfacing a temperature sensor to
equivalent binary output of ADC will be 100
the microcontroller AT89S52. The
or 0110 0100 in binary. The 8 bit binary
temperature sensor used in the project
output of the ADC is incremented by one for
is LM35. The LM 35 IC generates a 10mV
every 10 mV rise of input voltage. Different
variation to its output voltage for every
step size can be selected by changing the
degree Celsius change in temperature. The
voltage input to the Vref/2 pin. The step size
Output of the temperature sensor is analog
of the ADC is calibrated using a preset to
in nature so we need an analog to digital
match the actual temperature. Once the
convertor for converting the analog input to
ADC is calibrated it will give the correct
its equivalent binary output. The ADC
output further. The binary output of ADC is
0804is the analog to digital convertor IC
fed parallel to a port of the microcontroller
used in the project. 0804 is a single channel
.The microcontroller reads the input through
convertor which converts the analog input
ADC and displays the corresponding
up to a range of 5V to an equivalent 8-bit
decimal value on LCD indicating the
binary output.
temperature
The step size is defined by the
voltage applied at the Vref/2 pin of the ADC
.

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1155


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

STEP 1

STEP 2

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1156


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

STEP 3

STEP 4

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1157


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

STEP 5

STEP 6

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1158


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

STEP 9

RESULT 0Fahrenheit Scales respectively(Data


The Project TEMPERATURE Logger).
SENSOR USING
MICROCONTROLLER was designed
such that the Real-World Rise and Fall in CONCLUSION
the Ambient Temperature could be sensed
Applications of Celsius Scale
and sampled digitally using ADC0804 and Thermometer Circuit:
processed by the AT89S52 Micro-Controller
It can be used at mobile places like
to be displayed on a 16X2 Line LCD
cars to keep a track of the
Display unit in both the 0Celsius and
temperature.

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1159


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

It can be used to control the Using AT89S51, 0804 and 7-


switching of loads like motors, Segment Display
heaters based upon the temperature. Using PIC Microcontroller with 7-
It can also be used at homes to get Segment Display / LCD Display
the temperature reading. Without External ADC-IC and
interfacing Using ATMega 32, 7
Limitations of the Circuit:
Segment / LCD Display
It requires additional analog to Using PIC- C & 7 Segment / LCD
digital conversion. Display
The measurable Temperature range Using AT89C52, DS1621 Sensor
is between -550 C to +1500 C (Digital) with 7-Segment / LCD
This circuit can only measure values Display
in +/- 10 C steps.
The Fahrenheit Scale values are Reference:
obtained using the conversion Bakker, A., & Huijsing, J. H. (1996).
formula in Source Code Micropower CMOS temperature
sensor with digital output. IEEE
ALTERNATIVES for this Circuit:
Journal of Solid-State Circuits,
There are a number of various other 31(7), 933-937.
ways in which this project task could be
Nolan, J. B., Cooper, R. E., &
accomplished. Such as:
Dellacroce, B. (1997). U.S. Patent
Using the same Analog Temp. Sensor LM35
No. 5,619,430. Washington, DC:
with either ATMega / ATMega32 / PIC /
U.S. Patent and Trademark Office.
Arduino or any other Micro-Controller with
Hill, J., Szewczyk, R., Woo, A.,
a combination of Display alternatives like a
Hollar, S., Culler, D., & Pister, K.
7-Segment Display / LEDs / Andriod-
(2000). System architecture
SmartPhones etc.
directions for networked sensors.
A Few of which combinations are :
ACM SIGOPS operating systems
review, 34(5), 93-104.

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1160


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

Uhrich, D. T. (1997). U.S. Patent Mainwaring, A., Culler, D., Polastre,


No. 5,611,484. Washington, DC: J., Szewczyk, R., & Anderson, J.
U.S. Patent and Trademark Office. (2002, September). Wireless sensor
Polastre, J., Szewczyk, R., & Culler, networks for habitat monitoring. In
D. (2005, April). Telos: enabling Proceedings of the 1st ACM
ultra- low power wireless research. In international workshop on Wireless
IPSN 2005. Fourth International sensor networks and applications
Symposium on Information (pp. 88-97). ACM.
Processing in Sensor Networks, Meijer, G. C., Wang, G., & Fruett, F.
2005. (pp. 364-369). IEEE. (2001). Temperature sensors and
Wang, N., Zhang, N., & Wang, M. voltage references implemented in
(2006). Wireless sensors in CMOS technology. IEEE Sensors
agriculture and food industry Journal, 1 (3).
Recent development and future Panescu, D., Fleischman, S. D.,
perspective. Computers and Whayne, J. G., & Swanson, D. K.
electronics in agriculture, 50(1), 1- (1998). U.S. Patent No. 5,810,802.
14. Washington, DC: U.S. Patent and
Chung, W. Y., & Oh, S. J. (2006). Trademark Office.
Remote monitoring system with Thomson, D., Blake, J., & Mac
wireless sensors module for room Manus, L. (2003). U.S. Patent No.
environment. Sensors and Actuators 6,554,469. Washington, DC: U.S.
B: Chemical, 113(1), 64-70. Patent and Trademark Office.
Potdar, V., Sharif, A., & Chang, E. Eckel, D. P., Bonasia, G., & Porter,
(2009, May). Wireless sensor J. A. (2004). U.S. Patent No.
networks: A survey. In Advanced 6,798,341. Washington, DC: U.S.
Information Networking and Patent and Trademark Office.
Applications Workshops, 2009. Pertijs, M. A., Bakker, A., &
WAINA'09. International Conference Huijsing, J. H. (2001, May). A high-
on (pp. 636-641). IEEE. accuracy temperature sensor with

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1161


International Journal of Research p-ISSN: 2348-6848
e-ISSN: 2348-795X
Available at https://edupediapublications.org/journals
Volume 03 Issue 10
June 2016

second-order curvature correction


and digital bus interface. In Circuits
and Systems, 2001. ISCAS 2001. The
2001 IEEE International Symposium
on (Vol. 1, pp. 368-371). IEEE.
Panescu, D. N., Whayne, J. G.,
Fleischman, S. D., & Swanson, D. K.
(1998). U.S. Patent No. 5,769,847.
Washington, DC: U.S. Patent and
Trademark Office.
Barton, D. K., Bell, F. G., Laird, J.
S., & Meyer, T. C. (2004). U.S.
Patent No. 6,814,706. Washington,
DC: U.S. Patent and Trademark
Office.

Available online: http://edupediapublications.org/journals/index.php/IJR/ P a g e | 1162

Anda mungkin juga menyukai