0% found this document useful (0 votes)
35 views21 pages

MC Project

This document describes a student project to create a digital thermometer using an AVR microcontroller. It discusses the hardware components used, including a temperature sensor, microcontroller, and LCD display. It also covers implementing the assembly code to read temperature data from the sensor and display it on the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views21 pages

MC Project

This document describes a student project to create a digital thermometer using an AVR microcontroller. It discusses the hardware components used, including a temperature sensor, microcontroller, and LCD display. It also covers implementing the assembly code to read temperature data from the sensor and display it on the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

University of Duhok

College of Engineering
Electrical and Computer Engineering Department

Microcontroller Project:

Digital Thermometer Project Using AVR


Microcontroller

Student name:
1. Badria Mustafa
2. Lolav Saeed
3. Maryam Fakhri

Supervisor: DR. Adnan Ismail


Contents
Abstract: ........................................................................................ 3
Introduction: .................................................................................. 4
Implementation:........................................................................... 10
Conclusion:.................................................................................. 20
References ................................................................................... 21
Abstract:
Global warming is a big problem now a day. People want to
be more concerned about the weather. They want to know the
temperature and humidity thus they can forecast the weather change.
Here digital thermometer based on ATmega8 microcontroller is a
big deal. That can sense the temperature from the nature and provide
digital output. LCD display can show that result, computer can
analyze it and forecast that day’s weather. This result can be applied
to airplane, ship, bus, industry etc. This project centers around the
development of a digital thermometer sensor using assembly
language programming on an AVR microcontroller. The assembly
code interfaces with the temperature sensor, and the results are
displayed on an LCD in degrees Celsius. Through meticulous wiring
and sensor integration, this project exemplifies the practical
application of assembly language in low-level hardware
programming. The digital thermometer sensor provides real-time
and accurate temperature readings, showcasing its potential
applications in scenarios requiring precise temperature monitoring.
This project based on a microcontroller and a temperature sensor has
an analog sensor that converts the surrounding’s temperature to a
proportional analog voltage. The output from the sensor is
connected to one of the ADC channel inputs of the microcontroller
to derive the equivalent temperature value in digital format. The
computed temperature is displayed in a character LCD in degree
centigrade.[1]
Introduction:
Exploring the realms of embedded systems, the AVR
microcontroller series has proven itself as a stalwart in the field. In
this article, we embark on an in-depth journey into building a digital
thermometer project utilizing the robust AVR microcontroller,
delving into the intricacies of assembly code programming. Our
focus extends to essential components such as the LM35
temperature sensor, an ADC (Analog-to-Digital Converter), and a
16x2 LCD display, ensuring a comprehensive understanding of the
assembly-level implementation. In the pursuit of precise
temperature monitoring, this project introduces a Digital
Thermometer Sensor [1]. By employing assembly language on an
AVR microcontroller, we fuse hardware components—AVR,
temperature sensor, and LCD—to create a real-time temperature
display. This convergence of technology not only captures data but
also exemplifies the synergy between low-level programming and
tangible applications. This introduction sets the stage for exploring
the project's methodology, challenges, and its significance in
modern temperature monitoring [2].
AVR Microcontroller (ATmega328P):
The heart of our project is the ATmega328P microcontroller,
renowned for its reliability and widespread use. Its 8-bit architecture
and versatile I/O capabilities provided the computational power
necessary for processing temperature data and driving the system
[3].

Figure 1

Some temperature sensors commonly used:


DS18B20: A digital temperature sensor that communicates over a
Wire bus.
DHT Series (DHT11, DHT22): These sensors measure both
temperature and humidity and communicate using a digital signal.
LM35: is a temperature measuring device having an analog output
voltage proportional to the temperature. It provides output voltage in
Centigrade (Celsius). It does not require any external calibration
circuitry.
Temperature Sensor (DS18B20):
Our choice of the DS18B20 digital temperature sensor was
driven by its high precision and one-wire communication. With an
extended temperature range, from -55°C to +125°C, it ensured
accurate readings across various environments [4].

Figure 2:
The DHT11 sensor
The DHT11 sensor is a commonly used Temperature and
humidity sensor that comes with a dedicated NTC to measure
temperature and an 8-bit microcontroller to output the values of
temperature and humidity as serial data [5].

Figure 3
LM35 sensor
Major Hardware Description the LM35 series are precision
integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature if the
air temperature were much higher or lower than the surface
temperature, the actual temperature of the LM35 die would be at an
intermediate temperature between the surface temperature and the
air temperature. On the other hand, a small thermal mass may be
added to the sensor, to give the steadies treading despite small
deviations in the air temperature.

Figure 3

Our initial choice of the DS18B20 sensor posed certain challenges


in our thermometer project. The DS18B20, while a capable
temperature sensor, may have presented issues such as
communication while using single wire protocol. In response to
these challenges, we decided to transition to the LM35 sensor for its
simplicity, ease of use, and compatibility with our project
requirements.
Advantages of LM35:
Analog Output:
• The LM35 sensor provides a linear analog output directly
proportional to the temperature in Celsius. This characteristic
simplifies the interface with our microcontroller, eliminating the
need for complex digital communication protocols.
Calibration:
• Calibration of the LM35 is straightforward, allowing for accurate
temperature readings with minimal adjustments. This contrasts with
the DS18B20, where calibration might have been more intricate.
Ease of Integration:
• The LM35 integrates seamlessly into our existing circuitry,
requiring minimal modifications. Its straightforward analog voltage
output facilitates a more straightforward connection and data
interpretation by the microcontroller.
Reduced Complexity:
• Unlike the DS18B20, which communicates over a digital bus, the
LM35's analog output simplifies the overall system design. This
reduction in complexity aligns with our project goals of achieving a
reliable and efficient thermometer.
By switching to the LM35 sensor, we anticipate overcoming the
challenges encountered with the DS18B20, ensuring a more
straightforward, reliable, and accurate temperature measurement
system for our thermometer project.
LCD Display (16x2 HD44780):
The project features a 16x2 character LCD display, incorporating
the widely used HD44780 controller. This display not only presents
real-time temperature readings but also offers a clear and user-
friendly interface [6].

Figure 4
Implementation:

Wiring and Connectors: the components are seamlessly


interconnected using standard jumper wires and connectors,
ensuring a robust and organized wiring configuration to maintain
stable data transmission. Data transmission throughout the system.
Programming the AVR Microcontroller:
Using a suitable Integrated Development Environment (IDE)
like Atmel Studio, write the program for the AVR microcontroller.
The program should read the analogy input from the LM35 sensor,
convert it to temperature values, and display the result on the LCD.

ADCs are essential in various applications,


including:
• Sensor Interfacing: Connecting microcontrollers to sensors like
temperature and light sensors.
• Audio Processing: Converting Analog audio signals for digital
processing.
• Communication Systems: Handling Analog signals in
communication processes.
our assembly coding for project:
That is our simulation that we connect while running:

Figure
Hand connecting:

Figure
The Analog-to-Digital Converter (ADC)
The ADC is an integral component of a microcontroller that
translates continuous Analog signals, representing varying voltage
levels from sensors and external devices, into discrete digital values
[7]. This conversion process enables the microcontroller's digital
processing unit to interpret and utilize real-world physical
measurements, facilitating precise and accurate interactions with the
external environment in a wide range of applications such as
recording voice signals, temperature …etc.
.ORG 0x0000
MAIN: LDI R16, HIGH(RAMEND)
OUT SPH, R16
LDI R16, LOW(RAMEND)
OUT SPL,R16 ; setup stack

LDI R16, 0xFF


OUT DDRB, R16 ; PB = output
OUT DDRD, R16 ; PD = output
CBI DDRC, 0 ; PC0 = ADC0 = input
; Initialize LCD
LDI R16, 0x38 ; LCD: 2 lines, 5x7 matrix
CALL COMMAND ; Call command function
CALL D2MS ; Wait 2 ms

LDI R16, 0x0E ; Display on, cursor on


CALL COMMAND ; Call command function
CALL D2MS ; Wait 2 ms

LDI R16, 0x01 ; Clear LCD


CALL COMMAND ; Call command function
CALL D2MS ; Wait 2 ms

LDI R16, 0x06 ; Shift cursor right


CALL COMMAND ; Call command function
CALL D2MS ; Wait 2 ms

LDI R16, 0x80 ;cursor at line 1 pos. 0


CALL COMMAND
CALL D2MS ; Wait 2 ms
LDI R31, HIGH (MSSG<<1)
LDI R30, LOW (MSSG<<1) ;Z points to MSG
LOOP0: LPM R16,Z+
CPI R16,0 ;compare R16 with 0
BREQ HERE1 ;if R16 equals 0 exit WRITING FIRST LINE
CALL DATA ;call data write function
RJMP LOOP0

here1: LDI R16, 0xC0 ;cursor at line 1 pos. 0


CALL COMMAND
CALL D2MS ; Wait 2 ms

LDI R31, HIGH (MSG1<<1)


LDI R30, LOW (MSG1<<1) ;Z points to MSG
LOOP3: LPM R16,Z+
CPI R16,0 ;compare R16 with 0
BREQ HERE ;if R16 equals 0 exit WRITING FIRST LINE
CALL DATA ;call data write function
RJMP LOOP3

HERE: LDI R16, 0x87 ; enable ADC and select fs/128 = 125 KHz
STS ADCSRA, R16
LDI R16, 0x40
STS ADMUX, R16 ; Vref = 2.56V , input channel = ADC0 single ended

START: LDS R16, ADCSRA


ORI R16, 1 << ADSC
STS ADCSRA, R16 ; start conversion
POLLING: LDS R16, ADCSRA
SBRS R16, ADIF ; skip next instruction if ADIF = 1
RJMP POLLING ; keep polling end of conversion
SBR R16, 1 << ADIF
STS ADCSRA, R16 ; clear ADIF flag
LDS R16, ADCL ; R16 = ADCL

LSR R16 ; ADCL/2 ; NUMBER


LDI R21,10 ;DENUMINATOR =10
CLR R22 ;QUOTENT = 0 AT EVERY FIRST
L1: INC R22
SUB R16,R21
BRCC L1

DEC R22
ADD R16,R21
MOV R23,R16 ;R23 IS THE FIRST DIGIT

MOV R16, R22


CLR R22
L2: INC R22
SUB R16,R21
BRCC L2

DEC R22
ADD R16,R21
MOV R24,R16 ;R24 IS THE SECOND DIGIT

LDI R16, 0xC7 ;cursor at line 1 pos. 0


CALL COMMAND
CALL D2MS ; Wait 2 ms

ORI R24,0X30
MOV R16,R24
CALL DATA ;call data write function
CALL D2MS

ORI R23,0X30
MOV R16,R23
CALL DATA ;call data write function
CALL D2MS

LDI R16,' '


CALL DATA ;call data write function
CALL D2MS

LDI R16,'C'
CALL DATA ;call data write function
CALL D2MS

FOO: LDI R25,125


F2: LDI R26, 255
CALL D2MS
DEC R25
BRNE F2
LDS R16, ADCH ; R16 = ADCH
RJMP START
COMMAND:
OUT PORTD, R16 ; LCD data port = R16
CBI PORTB, 0 ; RS = 0 for command
SBI PORTB, 1 ; E = 1
CALL D100US ; Make a wide E pulse
CBI PORTB, 1 ; E = 0 for H-to-L pulse
CALL D100US ; Wait 100 us
RET

DATA:
OUT PORTD, R16 ; LCD data port = R16
SBI PORTB, 0 ; RS = 1 for data
SBI PORTB, 1 ; E = 1
CALL D100US ; Make a wide EN pulse
CBI PORTB, 1 ; E = 0 for H-to-L pulse
CALL D100US ; Wait 100 us
RET

D100US: LDI R17, 100 ; 100 µs delay


LOOP1: DEC R17
BRNE LOOP1
RET

D2MS: LDI R18, 100 ; 2 ms delay


LOOP2: CALL D100US
DEC R18
BRNE LOOP2
RET
MSSG: .DB "AVR uC Project",0
MSG1: .DB "Temp.:",0
Conclusion:
Building a digital thermometer using an AVR microcontroller
is a rewarding project that combines hardware and software aspects
of embedded systems. With the AVR series' powerful capabilities
and a reliable temperature sensor like LM35, you can create a
precise and effective digital thermometer for various applications.
As you delve into this project, you'll gain valuable insights into
microcontroller programming, Analog-to-digital conversion, and
interfacing with peripherals, making it an excellent learning
experience for electronics enthusiasts and students alike.
References
1. Arefin, A., Digital Thermometer using ATmega8
Microcontroller. 2013.
2. Oyebola, B. and O. Toluwani, LM35 Based digital room
temperature meter: a simple demonstration. Equatorial
Journal of Computational and Theoretical Science, 2017.
2(1).
3. Asheervad, S. and S.N. Thant, Microcontrolled digital
thermometer and temperature regulator. 2000.
4. Abayomi-Alli, A., et al., A Microcontroller based digital
thermometer with timer (DIGITHERMO). International
Journal of Computer Science Issues, 2013. 10(2): p. 229-238.
5. Changela, B., B. Daxini, and K. Parmar, Temperature
Detector for Premature Infant Incubator using AVR
Microcontroller. International Journal of Engineering Trends
and Technology, 2016. 35(7): p. 335-337.
6. Saidu, I., M. Momoh, and A. Mindaudu, Temperature
monitoring and logging system suitable for use in hospitals,
incorporating GSM text messaging. International Journal of
Information Sciences and Techniques (IJIST), 2013. 3(1).
7. Mazidi, M.A., S. Naimi, and S. Naimi, AVR Microcontroller
and Embedded Systems: Using Assembly and C: Pearson
New International Edition. 2015: Pearson Education.

You might also like