Đồ án 1 Mạch đo nhiệt độ và hiển thị LCD 16x2 PDF

Title Đồ án 1 Mạch đo nhiệt độ và hiển thị LCD 16x2
Author Nguyễn Thành Nam
Course Đồ án cơ điện tử
Institution Trường Đại học Bách khoa Hà Nội
Pages 21
File Size 1.3 MB
File Type PDF
Total Downloads 141
Total Views 688

Summary

Download Đồ án 1 Mạch đo nhiệt độ và hiển thị LCD 16x2 PDF


Description

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY SCHOOL OF ELECTRICAL ENGINEERING ====o0o====

REPORT OF PROJECT 1 PROJECT NAME:

DESIGNING TEMPERATURE MEASURING CIRCUIT USING BOARD ARDUINO, DISPLAY ON 16X2 LCD SCREEN AND LED WARNING SYSTEM

Project Supervisor: Project Reporter:

M.S. Đinh Thi Lan Anh Nguyen Thanh Nam

Student ID: Class:

20181909 Advanced Program for Electrical Engineering and Automation 01 K63

HA NOI, 5/2021

Preface Based on the knowledge learned in the subject: Introduction to Computer Science, Analog Electronics and Digital System Design... along with the understanding of electronic devices, I decided to carry out the topic: “Designing temperature measuring circuit using board Arduino, display on 16x2 LCD screen and LED warning system” with the aim to learn more about Arduino, familiarize myself with electronic devices and improve selfknowledge. In this project I used board Arduino Uno, temperature sensor LM35 and LCD 16x2 display. I used Proteus software to design the circuit and run stimulation and Arduino IDE for programming the code. After being installed and loaded with code, the circuit has fully fulfilled its initial purposes. In terms of practical application, we can develop this project so that it can be applied to drying ovens or adjust fan speed based on ambient temperature and so on. Due to limited knowledge of the first time doing a project, it is inevitable that there will be shortcomings and limitations, so I am looking forward to getting suggestions and reminders from teacher to complete my project. I would like to sincerely thank teacher M.S. Đinh Thi Lan Anh for helping me a lot in the process of researching, designing and completing this project 1.

Performing student

Nguyen Thanh Nam

2

TABLE OF CONTENTS CHAPTER 1. OVERVIEW

5

1.1

Introduction about Arduino and Arduino IDE

5

1.1.1

Arduino

5

1.1.2 Board Arduino Uno R3

5

1.1.3 Arduino IDE and Arduino programming language

7

1.2

Introduction about LM35 temperature sensor

8

1.3

Introduction about LCD 16x02 and module I2C for LCD

9

1.3.1

LCD

9

1.3.2 Module I2C LCD

11

CHAPTER 2. DESIGN AND PROGRAM THE PROJECT

13

2.1

13

Designing and simulating the circuit on Proteus

2.1.1 Designing the circuit

13

2.1.2

Simulation

14

2.2

Programming the project

14

2.3

Installation and test-running on test board

16

2.4

Funding for project implementation

16

CHAPTER 3. CONCLUSION

17

REFERENCES

18

3

LIST OF FIGURES

Figure 1.1 Board Arduino Uno R3

5

Figure 1.2 Parts of Arduino Uno R3

6

Figure 1.3 Interface of Arduino IDE

7

Figure 1.4 LM35 temperature sensor

8

Figure 1.5 Pins of LM35

8

Figure 1.6 LCD 16x02

9

Figure 1.7 LCD 1602 pins

10

Figure 1.8 Parts of Module I2C LCD

11

Figure 2.1 Block diagram of the circuit

13

Figure 2.2 The circuit designed on Proteus

13

Figure 2.3 Connection between LCD1602 and module I2C for LCD

14

Figure 2.4 Circuit stimulation in case the temperature is below the appropriate level

14

Figure 2.5 Circuit stimulation in case the temperature is in the appropriate level

15

Figure 2.6 Circuit stimulation in case the temperature is above the appropriate level

15

Figure 2.7 Test running in case the temperature is in the appropriate level

18

Figure 2.8 Test running in case the temperature is above the appropriate level

18

4

CHAPTER 1.

OVERVIEW

1.1 Introduction about Arduino and Arduino IDE 1.1.1

Arduino

Arduino was first invented in the Italian town of Ivrea and was named after a king in 9th century, King Arduin. Arduino was officially introduced in 2005 as a tool for the students of Professor Massimo Banzi, one of the first Arduino developers, at the Interaction Design Instistute Ivrea (IDII). In recent years, Arduino is really famous among the DIY users worldwide (who invent their own products). The number of users is extremely large and their age range is extending from high school to university, which made its creators surprised. The Arduino is actually a microprocessor board which is used for programming to interact with hardware devices such as sensors, motors, lights or other devices. Especially Arduino has itself an extremely easy-to-use application development environment, with a very simple programming language which can be use easily even by those who don’t know much about electronic devices and programming. And what makes the Arduino a phenomenon is the very low price and the open-source hardware and software. In this project, we use the board Arduino Uno R3 which cost us only 110.000 VND. 1.1.2

Board Arduino Uno R3

Figure 1.1 Board Arduino Uno R3

5

Arduino Uno R3 board‘s central processing unit is an AVR microcontroller Atmega328. The main structure of Arduino Uno includes the following parts: -USBpl u g:Thi si st hec ommu n i c a t i onpo r tf o rust oup l o a dc o d ef r o mt h ePCt o t h emi c r oc o nt r ol l e r .I ti sa l s ot hes e r i a lc ommu ni c a t i onf o rd a t at r a n s mi s s i onbe t we e nt h e mi c r o c o nt r o l l e ra ndt h ec omp u t e r . -Po we rp l u g:t or unt h eAr d ui n o, wec a np o we ri twi t ht heUSBp o r ta b o v e , b u ti n ot h e rc a s e swh e nwec a n ’ tc on ne c ti tt ot h ec o mpu t e r ,wec a nu s eas ou r c eof9 Vt o1 2 V i n s t e a d . -Th e r ea r e14i n p ut/o ut pu tp i n sn u mb e r e df r om0t o1 3,b e s i d et ha t , t he r ei sa gr ou nd i n gp i n( GND)a n dar e f e r e n c ev o l t a g epi n( AREF) . -AVRmi c r o c o nt r o l l e r :t h i si st h ec e n t r a lp r o c e s s i n gu ni to ft hee n t i r eb o a r d .Wi t h e a c hAr d ui n omo de lt he r ea r edi ffe r e ntc hi ps .I nt hi sAr d ui noUn oweu s eATMe g a 3 28 .

Figure 1.2 Parts of Arduino Uno R3

-Th ed e t a i l e dp a r a me t e r so fAr d ui noUno: Pr oc e s s o r : Op e r a t i n gv o l t a g e : I n pu tv ol t a g e( o pe r a t i o na l ) : I n pu tv ol t a g e( l i mi t ) : Di gi t a lI / Op i ns : An a l o gi n p utpi ns :

ATme g a 3 2 8 5V 71 2 V 62 0 V 14 6 6

Ma x i mu mc u r r e nti ne a c hp i n : Cu r r e n ti npi n3 . 3 V: Fl a s hme mo r y : SRAM: EEP ROM: Cl o c k: 1.1.3

40 mA 50 mA 32KB( ATme g a 3 28 ) 2KB( ATme g a 3 2 8) 1KB( ATme g a 3 2 8) 16 MHz

Arduino IDE and Arduino programming language

Th er e a lpo we ro fAr du i n ol i e si ni t ss o f t wa r e .Th eAr d ui n o ’ spr o gr a mmi n ge n v i r on me n ti s v e r ye a s yt ou s ewi t ht h eWi r i n gpr o gr a mmi n gl a n gu a g eba s e do nC/ C++wh i c hi ss o f a mi l i a rt os t ud e n t sa nde n g i ne e r s .Mo r e o v e r ,t h e r ea r eal o to fpr e wr i t t e nc o de ss h a r e db y t h eo pe ns o ur c ec ommu ni t y . Ar du i n oI DEi st hes of t wa r ewh i c hweu s et opr o gr a m Ar du i no .Ar d ui noI DEp r o gr a mmi n g e n vi r o nme n ti sa bl et or unont h et hr e emo s tp op ul a rop e r a t i n gs y s t e mst o d a y :Wi n d o ws , Ma c i nt o s hOSXa n dLi nu x .Du et oi t sop e ns ou r c ef e a t ur e ,t h i sp r o gr a mmi n ge n vi r o n me n t i sc o mpl e t e l yf r e ea n dc a nbee xt e n d e db ye x pe r i e nc e du s e r s . Th ep r og r a mmi n gl a n gu a g ec a nb ee xt e nd e dt h r o u g hC++l i br a r i e s .An da st h i sl a n g u a g e i sba s e do nt heCl a ng u a g eo fAVR,us e r sc a ne mb e dc o dewr i t t e ni nAVRi nt ot h epr o g r a m i ft h e ywa nt . Cur r e nt l y , t h eAr d u i n oI DEc a nb ed o wnl o a d e df r o mt he ho me p a g eh t t p : / / a r d ui no . c c /i nc l ud eo ft h e s ef ol l o wi n gv e r s i o ns : -Ar d ui n o1. 0 . 5 -Ar d ui n o 1. 5 . 5BETA( Su pp or tf ort h et wol a t e s tAr dui nobo a r ds :Ar d ui noYu na nd Ar du i n oDue ) -Ar d ui n oI DEf o rI nt e lGa l i l e o

7

Figure 1.3 Interface of Arduino IDE

1.2 Introduction about LM35 temperature sensor Th eLM3 5s e ns ori sah i ghp r e c i s i o ni n t e gr a t e dc i r c ui tt h e r ma ls e n s o rwho s eo ut p ut s v o l t a g ei sl i n e a r l yp r op o r t i o na lt ot heCe l s i u ss c a l et e mpe r a t ur e . Ea c h10 mVd i ffe r e n c eof ou t pu tv o l t a g egi v e su sad i ffe r e n c eof1de g r e ei nCe l s i u ss c a l e .The yd on o tr e q u i r e e x t e r n a lc a l i b r a t i o nb e c a u s et h e yha v eb e e nc a l i br a t e d .

Figure 1.4 LM35 temperature sensor

LM35s e n s o rh a s3pi ns : +So u r c epi nsVCC +Out p utpi nsVo ut( a n a l o gp i n s ) +Gr o un dp i nsGND.

8

Figure 1.5 Pins of LM35

Ma i nf e a t u r e soft h eLM35s e ns or : -I n p u tv o l t a g ef r o m4 Vt o3 0 V -Out p utv o l t a g er e s o l u t i o ni s10 mV/˚ C -Hi gha c c u r a c ya t2 5˚ Ci s0 . 5 ˚ C -Out p uti mp e da nc ei sl o w0 . 1f or1 mAl oa d Th eme a s u r e dt e mp e r a t u r er a n g eo fLM35i s5 5˚ Ct o1 50 ˚ Cwi t ho t he rou t p u tv o l t a g e s t o g e t he r .Co ns i de rt h ef ol l o wi n gv o l t a g el e v e l s : -Te mp e r a t u r e5 5˚ C, o u t pu tv o l t a g e5 50 mV -2 5˚ Ct e mp e r a t ur eou t p u tv o l t a g e2 5 0mV -1 50 ˚ Ct e mp e r a t u r eo ut p utv o l t a g e1 50 0mV. I nt h i sc i r c ui t , wec a nme a s u r et h et e mp e r a t u r er a n g ef r o m0 ˚ Ct o11 0 ˚ C. 1.3 Introduction about LCD 16x02 and module I2C for LCD 1.3.1

LCD

9

Figure 1.6 LCD 16x02

LCD1602 text-displaying screen using HD44780 driver, it can display 2 lines with 16 characters each. The screen is durable, very popular, has a lot of sample code and easy to be used, which is suitable for beginners and those who make projects. Some main features of LCD1602: -

The operating voltage is 5 V. Dimensions: 80 x 36 x 12.5 mm White text, blue background The distance between the two connecting pins is 0.1 inch handy when connecting to the breadboard. The names of the pins are written on the back of the LCD to support the connection and wiring. With LED backlight, can use variable resistor or PWM to adjust the brightness to use less power. Can be controlled with 6 signal wires There is a built-in character set that supports English and Japanese, see also HD44780 datasheet for more details.

10

Figure 1.7 LCD 1602 pins

Pin 1 2

3

4 5

6

7 8 9 10 11 12 13 14

Name Ground (VSS) Vcc (VDD)

Description

Ground (0V) Supply voltage; 5V (4.7V – 5.3V) Contrast adjustment; the best way is to use a variable resistor such as a potentiometer. The output of the potentiometer is connected to this pin. Rotate the Vo/VEE potentiometer knob forward and backwards to adjust the LCD contrast Selects command register when low, and data register RS (Register Select ) when high Low to write to the register; High to read from the RW (Read/Write) register Sends data to data pins when a high to low pulse is given; Extra voltage push is required to execute the instruction and EN(enable) signal is used for this purpose. Usually, we set en=0, when we want to Enable execute the instruction we make it high en=1 for some milliseconds. After this we again make it ground that is, en=0. DB0 Data pin 1 DB1 Data pin 2 DB2 Data pin 3 DB3 Data pin 4 DB4 Data pin 5 DB5 Data pin 6 DB6 Data pin 7 DB7 Data pin 8 11

15 16

Led+ (A) Led- (K)

1.3.2

Backlight VCC (5V) Backlight Ground (0V)

Module I2C LCD

In reality, LCD has too many pins, making it difficult to connect and occupy many pins on the microcontroller. The LCD I2C module was born to solve this problem. Instead of taking 6 microcontroller pins to connect to 16×2 LCD (RS, EN, D7, D6, D5 and D4), the I2C module only needs 2 pins (SCL, SDA) to connect. The I2C module supports LCDs using HD44780 drivers (LCD 16×2, LCD 20×4, …) and is compatible with most current microcontrollers.

Figure 1.8 Parts of Module I2C LCD

Some main features of module I2C LCD: -

Operating voltage: 2.5-6V DC. Monitor support: LCD1602,1604,2004 (driver HD44780). Interface: I2C. Default address: 0X27 (adjustable by shorting pin A0/A1/A2). Built-in Jump latch to supply LCD light or interrupt. Built-in rheostat for LCD contrast adjustment.

To use the I2C interface LCD screen using Arduino, we need to install the Liquidcrystal_I2C library.

12

CHAPTER 2.

DESIGN AND PROGRAM THE PROJECT

2.1 Designing and simulating the circuit on Proteus 2.1.1

Designing the circuit

To design the circuit, I first made a block diagram of the connection between the components as below:

Input (LM35)

Microcontroller (Arduino Uno R3)

Output (LCD, LEDs)

Figure 2.1 Block diagram of the circuit I decided to display on LCD the temperature measured by Celsius scale and Fahrenheit scale. The LED warning system has the rule: blue LED for low temperature (lower than 30oC), green LED for suitable temperature (31oC to 35oC) and red LED for high temperature (higher than 35oC), the levels of temperature can be changed in specific situation. I used Proteus software to design the circuit:

Figure 2.2 The circuit designed on Proteus

The LM35 temperature sensor need to be connected to ground, power source and the analog input pin of the Arduino. To display the temperature, I used a LCD 16x2 connect 13

with a module PCF8574 (I/O expander). The pin SCL and SDA of PCF8574 connect to the corresponding pins of Arduino. In reality, the module PCF8574 has already been integrated in the I2C board, so we only need to connect all the pin of the LCD to all the pin of the I2C board.

Figure 2.3 Connection between LCD1602 and module I2C for LCD

For the LED system, I connected one pin of each of them to the ground and other pins through 220 Ohm resistors and then to the output pins of Arduino. The resistors are used for protecting the LEDs. 2.1.2

Simulation

After writing the code and loading the code successfully, the simulation circuit worked properly and satisfied desired functions.

Figure 2.4 Circuit stimulation in case the temperature is below the appropriate level

14

Figure 2.5 Circuit stimulation in case the temperature is in the appropriate level

Figure 2.6 Circuit stimulation in case the temperature is above the appropriate level

2.2 Programming the project To program the code for the project, I used Arduino IDE software.

15

As introduced in the previous chapter, the LM35 measures the temperature and outputs it as voltage (each 10mV difference gives us a difference of 1 degree in temperature measurement scale). So that, to get the exact value of temperature, I use analogRead() function to read the voltage value from sensor LM35. The analogRead() function read the voltage value from an Analog pin (ADC), this function always returns an integer between 0 and 1023 corresponding to the voltage scale from 0V to 1,1V. After that, the temperature in Celsius scale can be calculated by the formula: celsius = (sensor * 1.1 / 1024.0) * 100 = sensor * 0.1074188 In this formula, sensor is the variable represents the voltage value output of LM35 sensor and celsius is the variable represents the temperature value in Celsius scale. To convert to Fahrenheit temperature (oF), we use the formula: fahrenheit = celsius * 1.8 + 32 In this formula, fahrenheit is the variable represents the temperature value in Fahrenheit scale. For the LED warning system, I used the if-else conditional structure. If the circuit runs continuously, in some cases where the temperature changes fast, it may cause the display to flicker, so that I decided to make it delay 500s after each time the loop runs. The whole code for the project is shown below. #include LiquidCrystal_I2C lcd(0x27,16,2); int blue = 8; int green = 9;

// Declare pin connects to blue LED // Declare pin connects to green LED

int red = 10; byte degree[8] = {

// Declare pin connects to red LED // Declare the "degree" character's pixel data

0B01110, 0B01010, 0B01110, 0B00000, 0B00000, 0B00000, 0B00000, 16

0B00000 }; void setup() { lcd.init();

// Start up the LCD screen

lcd.backlight(); lcd.clear();

// Turn on backlight // Clear the LCD screen

pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT);

// Declare OUTPUT pin

analogReference(INTERNAL); //Adjust the reference voltage used for analog input for //proper operation lcd.createChar(1, degree);

//Create the "degree" character

} void loop() { lcd.setCursor(0, 0); int sensor = analogRead(0); int celsius = sensor * 0.1074188; int fahrenheit = ((sensor * 0.1074188) * 1.8)+32; lcd.setCursor(0, 0); lcd.print("Temperature is"); lcd.setCursor(1, 1); lcd.print(celsius); lcd.write(1); lcd.print("C "); lcd.print(fahrenheit); lcd.write(1); lcd.print("F "); if (celsius > 34) { digitalWrite(red, HIGH); digitalWrite(green, LOW); digitalWrite(blue, LOW); } else { if (celsius < 30) { digitalWrite(blue, HIGH); digitalWrite(green, LOW); digitalWrite(red, LOW); } else { digitalWrite(green, HIGH); digitalWrite(red, LOW); digitalWrite(blue, LOW); } } delay(500); }

17

2.3 Installation and test-running on test board When installing components on the test board, it is necessary to pay attention to the wiring and arrange the position of the devices so that it is reasonable to avoid entanglement, when making the pin connections, the components should refer to the standard datasheet of each component condition to avoid confusion, causing the circuit to fail or cause a short circuit to damage components. During the installation of the circuit, I also encountered many small problems because of the quality of components or errors in wiring…, however, those problems were overcome and the circuit worked, the display functions and the alert works fine. The circuit is installed exactly according to the principle diagram mentioned in previous sections. The circuit works very well, the measured temperature is equal to the ambient temperature and changes properly when there is a heat source in contact with the sensor (in fact I used my hand and the circuit measured about 36 - 37oC).

Figure 2.7 Test running in case the temperature is in the appropriate level

18

Figure 2.8 Test running in case the temperature is above the appropriate level

2.4 Funding for project implementation ST T 1

Tên linh kiện Arduino Uno R3

Số lượng 1

110 000

Thành tiền (VNĐ) 110 000

Đơn giá (VNĐ)

2

LM35 sensor

1

20 000

20 000

3

Breadboard

1

40 000

40 000

4

Module I2C LCD


Similar Free PDFs