Anda di halaman 1dari 40

MINOR PROJECT REPORT ENVIRONMENT MONITORING SYSTEM

SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENTS FOR THE AWARD OF DEGREE OF BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING

Guide: Mr. B.K.Singh

Submitted By: Ashwani Kumar Saxena (07614802810) Rishabh Chopra(05696402810) Rohit Gupta(07514802810)

MAHARAJA AGRASEN INSTITUTE OF TECHNOLOGY SECTOR-22, ROHINI, DELHI-110086. AFFILIATED TO

GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY, NEW DELHI-110078 (2010-2014)

Certificate

This is to certify that the Minor Project Report (ETEC 459) entitled Environment Monitoring System done by team comprising of Ashwani Kumar Saxena (07614802810), Rishabh Chopra (05696402810) and Rohit Gupta (07514802810) is an authentic work carried out by them under my guidance. The matter embodied in this minor project work has not been submitted earlier for the award of any degree or diploma to the best of my knowledge and belief.

Date:

Name of the Guide: Mr. B. K. Singh Designation Address

ACKNOWLEDGEMENT
We would like to articulate our profound gratitude and indebtedness to our project guide Mr. B. K. Singh, who has always been a constant motivation and guiding factor throughout the project time in and out as well. It has been a great pleasure for us to get an opportunity to work under him and complete the project successfully. We wish to extend our sincere thanks to Prof. R S Gupta, Head of Department, for approving our project work with great interest. An undertaking of this nature could never have been attempted with our reference to and inspiration from the works of others whose details are mentioned in references section. We acknowledge our indebtedness to all of them.

Ashwani Kumar Saxena (07514802810) ashwanikumar686868@gmail.com Rishabh Chopra (05696402810) chopra.rishabh22@yahoo.in Rohit Gupta (07514802810) rohitgupta11041993@gmail.com 3

ABSTRACT
Motivation: A comfortable environment can increase the productivity multi-folds. So it is important that the environment variables such as temperature, relative humidity and light intensity are continuously monitored and corresponding systems adjusted to maintain a comfortable working environment.

What We Thought: If a microcontroller based development system is provided with sensors such as Temperature sensor, Humidity sensor and Light dependent resistor to measure the present values of temperature, relative humidity and light intensity respectively; microcontroller can then control the output values sent to various devices such as fans, AC, bulbs, tube lights. In this way, all these controlled devices will work collectively to bring the environment to our comfort level.

Goal: The goal of this work is to develop an environment monitoring system that senses these parameters and performs various functions such as showing the present values on LCD screen, analog and digital controlling of various devices.

CONTENTS
Certificate Acknowledgement Abstract List of figures List of tables Chapter 1. Introduction 1.1 What do we want to change? 1.2 Basic Details 1.3 Advantages 1.4 Applications Chapter 2. Components Used 2.1 Microcontroller 2.2 Sensors 2.2.1 Temperature sensor 2.2.2 Light sensor 2.2.3 Humidity sensor 2.3 LED dot matrix 2.4 LCD 2.5 Relay Chapter 3. Hardware Interfacing 3.1 Detailed Block Diagram 3.2 Components controlled by sensors 3.3 Circuit diagram 3.4 Components details Chapter 4. Source Code Chapter 5. Outputs Catalogue 5.1 Light parameter output 5.2 Temperature parameter output 5.3 Humidity parameter output Conclusion References 2 3 4 6 7 8 8 9 10 10 12 12 16 16 17 18 19 20 22 24 24 25 26 27 28 32 32 36 38 39 40

LIST OF FIGURES
FIGURE NO. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

PAGE NO. 8 8 9 10 10 11 11 13 13 16 16 16 17 17 17 18 18 19 20 21 22 22 23 24
26 32 32 32 33 33 33 34 34 34 35 35 35 36 36 37 37 38 38

DETAILS Fan and its regulator Lights in a room Block diagram Intelligent homes Industries Remote areas Cool cabin-Google Pin diagram of Atmega16 Atmega16 architecture Thermocouple vs thermistor vs I.C. sensor LM 35 LM 35 pin out Photoresistor symbol NORP12 Circuit diagram of NORP12 SY-HS-220 SY-HS-220 characteristics LED dot matrix LCD pin out Generating character code Block diagram of relay Relay ON Relay OFF Detailed block diagram Circuit diagram LCD showing SUNLIGHT 2*2 display on LED dot matrix Bulb OFF LCD showing BRIGHT 4*4 display on LED dot matrix Bulb OFF LCD showing DIM 6*6 display on LED dot matrix Bulb ON LCD showing DARK 8*8 display on LED dot matrix Bulb ON LCD showing 24oC temperature Fan OFF LCD showing 28oC temperature Fan ON LCD showing 30% relative humidity LCD showing 70% relative humidity 6

LIST OF TABLES
TABLE NO. 1 2
3

PAGE NO. 12 25
27

DETAILS Types of megaAVR microcontrollers Components controlled by sensors


Components in circuit diagram

Chapter 1. INTRODUCTION
What Do We Want To Change?

Fig.1 Fan and its regulator

Fig.2 Lights in a room What if all these lights know when to get lightened up themselves!

Basic Details:
The environment monitoring system consists of a microcontroller, few sensors and controlled devices. Sensors include Light sensor Temperature sensor Humidity sensor

LCD display will continuously display the current values of environment variables.

Fig.3

Advantages:
Power consumption by controlled devices is optimum. Removes the need of constant manual monitoring. Makes the process computerized thus reducing the probability of errors. Beneficial for monitoring remote areas.

Applications:
1. Intelligent Homes

Fig.4 A home where when you enter lights lighten up themselves, fans will start rotating, if its hot, fans will themselves rotate faster, if its humid, AC will itself take the charge is what everybody want. And advancements done to this project can lead to all this.

2. Hazardous Industries

Fig.5 No one will like to enter a laboratory where nuclear reaction is going on or some exothermic reaction is going on. Our system can help in maintaining the optimum environment in all such areas.

10

3. Remote Areas Monitoring

Fig.6 If you are at your base office and you need to maintain the environment in your plant in some remote area, what else can you think of except our system that can itself maintain the environment and can let you decide the environment to be maintained.

4. Cool Office Cabins

Fig.7 A good company is not where you can see everyone busy at his table with some file, a good company is where they all can talk, enjoy and when they will work for just an hour with a better understanding and satisfaction, they can give what those busy people cant in whole day!

11

Chapter 2. COMPONENTS USED MICROCONTROLLER


AVR Microcontroller:
AVR was developed in the year 1996 by Atmel Corporation. The architecture of AVR was developed by Alf-Egil Bogen and Vegard Wollan. AVR derives its name from its developers and stands for Alf-Egil Bogen Vegard Wollan RISC microcontroller. The AT90S8515 was the first microcontroller which was based on AVR architecture however the first microcontroller to hit the commercial market was AT90S1200 in the year 1997. AVR microcontrollers are available in four different categories: TinyAVR Less memory, small size, suitable only for simpler applications. MegaAVR These are the most popular ones having good amount of memory (upto 256 KB), higher number of inbuilt peripherals and suitable for moderate to complex applications. XmegaAVR Used commercially for complex applications, which require large program memory and high speed. Application-specific AVR - MegaAVRs with special features not found on the other members of the AVR family, such as LCD controller, USB controller, advanced PWM, CAN etc.

Types of MegaAVR microcontrollers:


Part Name ROM RAM EEPROM Interrupts Operation Operating Packaging Voltage frequency

ATmega8 ATmega8L ATmega16

8KB 8KB

1KB 1KB

512B 512B 512B 512B 1KB 1KB

19 19 21 21 21 21 Table 1

4.5-5.5 V 2.7-5.5 V 4.5-5.5 V 2.7-5.5 V 4.5-5.5 V 2.7-5.5 V

0-16 MHz 0-8 MHz 0-16 MHz 0-8 MHz 0-16 MHz 0-8 MHz

28 28 40 40 40 40

16KB 1KB

ATmega16L 16KB 1KB ATmega32 32KB 2KB

ATmega32L 32KB 2KB

12

Atmega16 Microcontroller:

Figure 8 Atmega16 Architecture:

Figure 9

13

I/O Ports Atmega16 has four (PORTA, PORTB, PORTC and PORTD) 8-bit input-output ports. Internal Calibrated Oscillator o Atmega16 is equipped with an internal oscillator for driving its clock. o By default Atmega16 is set to operate at internal calibrated oscillator of 1 MHz. o The maximum frequency of internal oscillator is 8MHz. o Alternatively, ATmega16 can be operated using an external crystal oscillator with a maximum frequency of 16MHz. In this case, we need to modify the fuse bits. ADC Interface o Atmega16 is equipped with an 8 channel ADC (Analog to Digital Converter). o ADC reads the analog input for e.g., a sensor input and converts it into digital information which is understandable by the microcontroller. Timers/Counters o Atmega16 consists of two 8-bit and one 16-bit timer/counter. o Timers are useful for generating precision actions for e.g., creating time delays between two operations. Watchdog Timer Watchdog timer is present with internal oscillator. Watchdog timer continuously monitors and resets the controller if the code gets stuck at any execution action for more than a defined time interval. Interrupts Atmega16 consists of 21 interrupt sources out of which four are external. The remaining are internal interrupts which support the peripherals like USART, ADC, timers etc. USART It is available for interfacing with external device capable of communicating serially (data transmission bit by bit). Memory: Atmega16 consist of three different memory sections: 1. Flash EEPROM: o Flash EEPROM or simple flash memory is used to store the program dumped or burnt by the user on to the microcontroller. o It can be easily erased electrically as a single unit.

14

o Flash memory is non-volatile i.e., it retains the program even if the power is cut-off. o Atmega16 is available with 16KB of in system programmable Flash EEPROM. 2. Byte Addressable EEPROM: o This is also a non volatile memory used to store data like values of certain variables. o Atmega16 has 512 bytes of EEPROM, this memory can be useful for storing the lock code if we are designing an application like electronic door lock. 3. RAM: o Random Access Memory, this is the volatile memory of microcontroller i.e., data is lost as soon as power is turned off. o Atmega16 is equipped with 1KB of internal RAM. o A small portion of RAM is set aside for general purpose registers used by CPU and some for the peripheral subsystems of the microcontroller. ISP AVR family of controllers have In System Programmable Flash Memory which can be programmed without removing the IC from the circuit, ISP allows to reprogram the controller while it is in the application circuit. SPI (Serial Peripheral Interface) SPI port is used for serial communication between two devices on a common clock source. The data transmission rate of SPI is more than that of USART. TWI (Two Wire Interface) can be used to set up a network of devices, many devices can be connected over TWI interface forming a network, the devices can simultaneously transmit and receive and have their own unique address. DAC Atmega16 is also equipped with a Digital to Analog Converter (DAC) interface which can be used for reverse action performed by DAC. DAC can be used when there is a need of converting a digital signal to analog signal.

15

SENSORS
1. Temperature Sensor
What Is Integrated Circuit Temperature Sensor? A two/three terminal integrated circuit temperature transducer that produces an output current/voltage proportional to absolute temperature in Kelvin or Centigrade. Why it is preferred over thermistors and thermocouples? Linearity Low cost No additional circuit required

Figure 10

Temperature Sensor used - LM35

Figure 11

Figure 12

They use the fact as temperature increases, the voltage across a diode increases at a known rate. Technically, this is actually the voltage drop between the base and emitter Vbe of a transistor. Voltage at pin in mV = (reading from ADC) *(5000/1024) Centigrade temperature = (analog voltage in mV) / 2 The temperature Sensor is interfaced to the microcontroller as analog sensor. 16

FEATURES: calibrated directly in Celsius Linear scale +10 mV/C 0.5C accuracy Temperature range -55 to 150 C

2. Light Sensor
A photoresistor or light dependent resistor (LDR) is a resistor whose resistance decreases with increasing incident light intensity. A photoresistor is made of a high resistance semiconductor. If light falling on the device is of high enough frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band. The resulting free electron (and its hole partner) conduct electricity, thereby lowering resistance.

Figure 13

Light Sensor used NORP12 (Light Dependent Resistor)

Figure 14

Figure 15

It has a high resistance in the dark, and a low resistance in the light. LDR response is not linear, in general there is a larger resistance change at brighter light levels. FEATURES o linear resistance variation o temperature range -60C to 75C o cheap

17

3. Humidity Sensor
Humidity is the presence of water in air. The amount of water vapor in air can affect human comfort as well as many manufacturing processes in industries. Humidity sensor converts relative humidity to corresponding voltage. Relative humidity is ratio of actual vapor pressure to saturated vapor pressure expressed in %. Substance used possesses the property of hygroscopy i.e. ability of a substance to attract and hold water molecules from the surrounding environment.

Humidity Sensor used: SY-HS-220

Figure 16 FEATURES Accuracy + 5% Humidity range : 30 to 90 % Temperature range : -30 to 85 C in-built driver circuit

Figure 17

18

LED DOT MATRIX

Figure 18 It is a matrix of LEDs. All the anode terminals of a row LEDs are connected together and taken out as 1 pin. Similarly, all cathodes of a column LEDs are connected together and taken out as 1 pin. In case of a 8X8 LED dot matrix, we have 8 pins for the 8 rows and 8 pins for 8 columns. There are 64 LEDs in this matrix. We use one PORT for controlling the rows and one PORT for controlling the columns. For selecting a row we give 1 to that row and the rest rows are passed 0. Similarly, for selecting a column we give 0 the corresponding pin and the rest columns are passed 1. Thus, if we want to glow the LED in 2nd row and 5th column, we write: PORTB=0b00000010; PORTC=0b11101111; //for rows //for columns

19

LCD (LIQUID CRYSTAL DISPLAY)


The devices used for displaying. They have 1 or 2 embedded microcontrollers and support at most of 80 characters. LCD contains three memory areas: DDRAM- Display Data RAM to store display data represented in 8-bit character codes. CGROM- Character Generator ROM to generate 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes. CGRAM-Character Generator RAM to create custom characters in LCD. It has 2 registers which are used as buffer - Instruction Register (IR) and Data register (DR). Selection is done by the RS pin of the LCD. o When RS=0, the LCD microcontroller treats the values on the data pin as instruction input and stores them in IR. o When RS=1, the LCD microcontroller treats the values on the data pin as Data input and stores them in DR.

Figure 19

20

Generating Character Code

Figure 20 int main() { // configure the LCD LCD_cmd(0x40); /* bringing the cursor to the initial CGRAM address to store the character. The character codes are being passed one by one after this. The cursor gets incremented automatically.*/ LCD_write(0x00); LCD_write(0x04); LCD_write(0x0e); LCD_write(0x0e); LCD_write(0x0e); LCD_write(0x1f); LCD_write(0x04); LCD_write(0x00); LCD_cmd(0x80); /* bringing the cursor back to the DDRAM address for printing the character.*/ LCD_write(0); return 0; }

21

RELAY
Relay is used to connect bulb and fan. Relay is a type of switch which is connected/ operated in one circuit and they control the flow of current in other circuit. In other words, they allow a small current flow circuit to control a higher current circuit.

Figure 21

Relay Design:
All relays operate using the same basic principle. Relays have two circuits: o A control circuit (shown in GREEN) o A load circuit (shown in RED). The control circuit has a small control coil while the load circuit has a switch. The coil controls the operation of the switch.

Relay Operation:
When no voltage is applied to pin 1, there is no current flow through the coil. No current means no magnetic field is developed, and the switch is open. When voltage is supplied to pin 1, current flow though the coil creates the magnetic field needed to close the switch allowing continuity between pins 2 and 4.

Relay Energized (ON):


Current flowing through the control circuit coil (pins 1 and 3) creates a small magnetic field which causes the switch to close, pins 2 and 4. The switch, which is part of the load circuit, is used to control an electrical circuit that may connect to it. Current now flows through pins 2 and 4 shown in RED, when the relay in energized.

Figure 22 22

Relay Energized (OFF):


When current stops flowing through the control circuit, pins 1 and 3, the relay becomes de-energized. Without the magnetic field, the switch opens and current is prevented from flowing through pins 2 and 4. The relay is now OFF.

Figure 23

Relay Connection:
Relays are magnetized when a proper voltages and proper current is applied to it. For providing these IC ULN2803 is used. The microcontroller pins are declared as output. These pins are connected to ULN input pins. ULN outputs are then used to drive relays.

23

Chapter 3. HARDWARE INTERFACING DETAILED BLOCK DIAGRAM

Figure 24

24

COMPONENTS CONTROLLED BY SENSORS

INPUTS

OUTPUTS

Bulb NORP12 Light Sensor

LED Dot Matrix

LCD

LM 35 Temperature Sensor

Fan

LCD

SY-HS-220 Humidity Sensor Table 2

LCD

25

26

27

Chapter 4. SOURCE CODE


#include<avr/io.h> #include<util/delay.h> #include<adc.h> #include<lcd.h> int main() { //output ports DDRD=0xff; //LCD port DDRB=0xff; //rows of led dot matrix DDRC=0xff; //cols of led dot matrix DDRA=0x06; //00000110 i.e except 1 and 2 rest all 6 are input ports //where 1 port is for fan output //2 port is for bulb output //variable declaration unsigned int x,y,light,temperature,l,humidity; while(1) { l1: //initialization LCD_init(); ADC_init(); LCD_cstm1(); //pin 0 has LM 35 temperature = ADC_read(0); temperature /= 2; //calibration //pin 3 has SY HS 230 l = ADC_read(3); humidity = (12*l)/80-10; //calibration //pins 5 and 6 have norp 12 x=ADC_read(6); y=ADC_read(5); light = (x+y)/2;//taking average //code to display temperature on LCD fourbit_cmd(0x80); LCD_str("TEMPERATURE ( C)"); fourbit_cmd(0x8d); fourbit_data(0); fourbit_cmd(0xc8); LCD_num(temperature); fourbit_cmd(0xc9); fourbit_data(0); 28

fourbit_cmd(0xca); LCD_str("C"); fourbit_cmd(0xcb); _delay_ms(1000); LCD_clr(); //code to display humidity on LCD fourbit_cmd(0x80); LCD_str("HUMIDITY"); fourbit_cmd(0xc8); LCD_num(humidity); _delay_ms(1000); LCD_clr(); if(light>850 && light<1023)//if outside its too much bright { fourbit_cmd(0x80); LCD_str("LIGHT INTENSITY"); fourbit_cmd(0xc4); LCD_str("SUNLIGHT "); _delay_ms(2000); LCD_clr(); //code for LED DOT MATRIX PORTB=0b00011000; PORTC=0b11100111; //if temperature >26, switch on the fan at pin 1 if(temperature>26)//temperature { PORTA=0b00000010; goto l1; } else { PORTA=0b00000000; goto l1; } _delay_ms(100); } else if(light>450 && light<850) { fourbit_cmd(0x80); LCD_str("LIGHT INTENSITY"); fourbit_cmd(0xc4); LCD_str("BRIIGHT "); _delay_ms(2000); LCD_clr(); PORTB=0b00111100; PORTC=0b11000011; if(temperature>26) { 29

PORTA=0b00000010; goto l1; } else { PORTA=0b00000000; goto l1; } _delay_ms(100); } else if(light>350 && light<450) { fourbit_cmd(0x80); LCD_str("LIGHT INTENSITY"); fourbit_cmd(0xc6); LCD_str("DIM "); _delay_ms(2000); LCD_clr(); PORTB=0b01111110; PORTC=0b10000001; //as light intensity is dim, bulb is also glown at pin 2 if(temperature>26) { PORTA=0b00000110; goto l1; } //for bulb else { PORTA=0b00000100; goto l1; } _delay_ms(100); } else if(light>250 && light<350) { fourbit_cmd(0x80); LCD_str("LIGHT INTENSITY"); fourbit_cmd(0xc6); LCD_str("DARK "); _delay_ms(2000); LCD_clr(); PORTB=0xff; PORTC=0x00; //as light intensity is dark, bulb is also glown at pin 2 if(temperature>26) { PORTA=0b00000110; goto l1; 30

} else {

//for bulb

PORTA=0b00000100; goto l1; } _delay_ms(100); } } return 0; }

31

Chapter 5. OUTPUTS CATALOGUE


1. Light Parameter Outputs 1.a. Case 1

Figure 26. LCD showing SUNLIGHT

Figure 27. 2*2 display on LED DOT MATRIX

Figure 28. BULB OFF

32

1.b. Case 2

Figure 29. LCD showing BRIGHT

Figure 30. 4*4 display on LED DOT MATRIX

Figure 31. BULB OFF

33

1.c. Case 3

Figure 32. LCD showing DIM

Figure 33. 6*6 display on LED DOT MATRIX

Figure 34. BULB ON

34

1.4. Case 4

Figure 35. LCD showing DARK

Figure 36. 8*8 display on LED DOT MATRIX

Figure 37. BULB ON

35

2. Temperature Parameter Outputs 2.a. Case 1

Figure 38. LCD showing 24oC temperature

Figure 39. FAN OFF

36

2.b. Case 2

Figure 40. LCD showing 28oC temperature

Figure 41. FAN ON

37

3. Humidity Parameter Outputs 3.a. Case 1

Figure 42. LCD showing 30% relative humidity

3.b. Case 2

Figure 43. LCD showing 70% relative humidity

38

39

REFERENCES
1. Design and Implementation of Environmental Monitoring System in Intelligent System in Intelligent Home Hong, Wu & Wang, IEEE 2. Embedded C Programming and the Atmel AVR, Richard H Barnett 3. Datasheets by i3indya Technologies 4. www.atmel.in/Images/doc2466.pdf 5. www.ti.com/lit/ds/symlink/lm35.pdf 6. www.alldatasheet.com/datasheet-pdf/pdf/124418/ETC1/NORP-12.html 7. www.alldatasheet.com/datasheet-pdf/pdf/184066/.../SY-HS-230.html 8. http://embedded-lab.com/?p=2478 9. https://www.sparkfun.com/datasheets/LCD/ADM1602K-NSA-FBS-3.3v.pdf 10. en.wikipedia.org/wiki/Relay 11. http://www.labcenter.com/index.cfm

40

Anda mungkin juga menyukai