Sie sind auf Seite 1von 16

Embedded Systems Engineering

Home Automation
System

Jayasekara J.M.S.M EN15547934


Mudalige L.R EN15561558
K.W.P.N. Weerawardhana EN15536594
Premadasa T.W.M.P EN15506276

Faculty of Engineering
Sri Lanka Institute of Information Technology

1
DECLARATION

“I declare that this is our own work and this report does not incorporate without
acknowledgement any material previously submitted for a Degree or Diploma in any other
University or institute of higher learning and to the best of our knowledge and belief it does
not contain any material previously published or written by another person except where the
acknowledgement is made in the text.

Also, I hereby grant to SLIIT the non-exclusive right to reproduce and distribute my report,
in whole or in part in print electronic or other medium. I retain the right to use this content in
whole or part in future works (such as articles or books)”

EN15547934 Jayasekara J.M.S.M

EN15561558 Mudalige L.R

EN15536594 K.W.P.N. Weerawardhana

EN15506276 Premadasa T.W.M.P

2
ACKNOWLEDGEMENT

We would like to specially recognize and thank the Module Lecturer Mr. Manaram
Gnanasekara, for his guidance, time and providing us with a systematic way to complete this
project throughout the course. We also would like to recognize his assistance in solving the
technical problems and various other problems we faced during the implementing this home
automation system.

We also would like to thank our friends and colleagues for assisting in the successful
Completion of this Home automation System Project. It was a delightful experience which all
of us accept with gratitude.

We also would like to thank our lectures and instructors for proving us assistance in various
problems encountered during course of our project.

We would like to express our gratitude towards our own group members for their kind co-
operation and encouragement which helped us in completion of this project.

We would like to express our special gratitude to all other people who have not been mentioned
here, whom helped us in various ways to make this a success.

EN15547934 Jayasekara J.M.S.M


EN15561558 Mudalige L.R
EN15536594 K.W.P.N. Weerawardhana
EN15506276 Premadasa T.W.M.P

3
1. INTRODUCTION

Project Requirement of the module


In this project our group was requested to implement a robot using the TI MSP430
development platform with two sensors and two actuators. This project was mainly conducted
under the requirements of third year first semester Electronics and Electrical Engineering
module ‘Embedded System Engineering’ at Sri Lanka Institute of Information Technology. To
accomplish the above mentioned requirements of the module, our group members were able to
design a simple home automation system with various mechanical and electronic resources.

Selected Project objective

Implement a simple home automation system which control following parameters,

 Light Intensity inside the room


 Temperature and humidity inside the room
 Detection of person presence and take actions to save power.

To accomplish the above mentioned parameter control requirements in this module project, our
group members were decided to use following microcontrollers, modules/devices as main
components of this project,

 MSP430G2553 (MSP-EXP430G2 value line LaunchPad Development Tool)


 LDR ( Light Dependent Resistor)
 DHT11 Temperature and Humidity Sensor
 FC 51 IR Distance Sensor Module
 L298D motor controller
 DC motors
 Resistors
 LEDs( Light Emitting Diodes)
 Boards
 Rigi form, hard board

4
2. DESIGN IMPLEMENTATION

Sensors in the System

Sensor Output Reading Method


LDR Analog Used ADC10 Module
to convert voltage
levels to digital
DHT Digital- Output is a 40 bit array Used a character array
1st 8 bits – Temperature Integral to extract data from
2nd 8 bits – Temperature Decimal bits.
3rd 8 bits – Humidity Integral
4th 8 bits – Humidity Decimal
5th 8 bits – Sum of previous all
8 bit packets(checksum)
FC51 IR ostacle sensor Digital (High and Low) , If conditions to read
When an obstacle is found output is pin status.
low

Apparatus Information and Sensor implementation

MSP430G2553 Experimenter Board

This board is a Texas instrument’s value line series board which is the most selling board
under the MSP430 series. Following are the main specifications of the board.

CPU- MSP430 @ 16 MHz Non-Volatile Memory – 16 KB RAM – 0.5 KB


GPIO- 24 Pins I2C -1 SPI- 2 UART - 1 ADC – ADC10-8ch Comparators – 8
Timer (16-bit) – 2 BSL- UART Min Vcc- 1.8 V Max Vcc – 3.6V

Additional Features

 Internal Temperature Sensor


 Watchdog
 Brown Out Reset
 IrDA

Special Inputs – Capacitive Touch I/O

5
Figure 1- MSP430G2 Board with G2553 Chip

LDR

Following are the characteristics of the LDR

1000 Lux 400Ω


Resistance 10 Lux 9 KΩ
Total Dark 1 MΩ
Power Dissipation 100 mW Max
Current 75 mA Max

To read voltage levels of the LDR , a 10KΩ resistor was used in series to work as a voltage
devider, voltage across the 10 K resistor was sampled using the ADC10 module in the
MSP430 Board.

Figure 2 - LDR wiring

6
DHT 11 Sensor

DHT11 is a digital temperature and humidity sensor, in this sensor all the temperature and
humidit data send over an one wire using 40 bits. According to the data sheet to receive data
from the bus following process had to be done.

 Request
 Response
 Data Reading

Request

To request the data from the DHT11 this procedure was follows. the request was sent to
DHT11 by pulling down and pulling up the connected pin for a certain time. Accrding to the
data sheet the pull down time is 18 ms and pull up time is 40 µs s.

Figure 3 – Request

Response

After receiving the request, the DHT11 acknowledges the Controller using following signal.

Figure 4 – Response

Reading DATA

After the response DHT11 Starts to send Data using the Bit array.

7
Reading Data Explained.

Temperature = First 8 bits.Second 8 bits = 0b000100000.0b00010000 = 32.16 º C

Humidity = Third 8 bits.fourth 8 bits = 0b001000000.0b00000010 =64.04%

Fifth 8 bits = sum of all 8 bit series.

Figure 5- DHT11 Sensor

FC51 IR Sensor

This sensor is an obstacle detecting sensor which uses IR as the sensing media. In this sensor
there is an implemented I393 comparator IC which gives HIGH and LOW signal as output
according to the obstacle distance. This sensor give LOW output when an obstacle is in the
range.

Figure 6 -FC51 Sensor

8
3. DESIGN METHOD

When designing this home automation system, our group members had to implement
3 objectives using the MSP430

 Human Presence detection and turning on the system.


 Light intensity detection and turning on turning on the lights.
 Temperature detection and turning on the fans.

Human Presence Detection

To implement the human presence detection, the IR obstacle sensors was used. The simple
theory of using IR sensors is as follows,

In the home automation system, the IR sensors were implemented in the door, one outside the
room and other one inside the room.

These IR obstacle sensors Outputs “LOW” when an obstacle is detected.

Entering the room- for detect entering the room, the outer IR sensor was checked for its
input. When an obstacle was detected by the outer sensor, the code waits few seconds for an
input from the inner sensor, if an input from inner sensor is received during the time period
the system recognized as one person entered the room.

if((P2IN & BIT3)==0){ // outer sensor is connected to the P2.3


hit1=1;
__delay_cycles(250000); //32ms Delay(Values are up to best optimizations)
} // @ 8Mhz
while((hit1==1)&&(hit2==0)){ //hit1=1 when outer sensor was blocked
if((P2IN & BIT4)==0){ //checking for an input from inner sensor at P2.4
in=in+1; //Counter was increased for entering
hit1=0; //hit1 and hit2 values were reset
hit2=0;
__delay_cycles(500000); //64ms Delay(Values are up to best optimizations)
} //@ 8Mhz
}

Leaving the room- for detect leaving the room, the inner IR sensor was checked for its input.
When an obstacle was detected by the inner sensor, the code waits few seconds for an input
from the outer sensor, if an input from outer sensor is received during the time period the
system recognized as one person has left the room.

9
if((P2IN & BIT4)==0){ // inner sensor is checked. connected to the P2.4
hit2=1;
__delay_cycles(250000); //32ms Delay(Values are up to best optimizations)
}
while((hit2==1)&&(hit1==0)){ //hit2=1 when inner sensor was blocked
if((P2IN & BIT3)==0){ //checking for an input from outer sensor at P2.3
out=out+1; //Counter was increased for leaving
hit1=0; //hit1 and hit2 values were reset
hit2=0;
__delay_cycles(500000); //64ms Delay(Values are up to best optimizations)
}
}

System Starting-

if((in-out)>0){ // main code runs when entered count-Left count is >0

//Main Code

Light intensity detection

To detect light intensity, a LDR is used with series to a resistor, in this case ADC10 module
in MSP430 is used to obtain Light intensity data to the controller.

Figure 7-How LDR is used in series with a resistor

ADC10CTL0 = ADC10SHT_3 + SREF_0 + REFON + ADC10ON; //64 Clock cycles,Vcc And Vss
//as reference values, ADC
//turned on, Reference Out on

ADC10CTL1 = INCH_3 + ADC10DIV_3; //input channel 3 was selected (P1.3),Clock

//Divider by 4

10
if((in-out)>0){

ADC10CTL0 |= ENC + ADC10SC; //ADC conversion is Started

while (ADC10CTL1 & ADC10BUSY); //Waiting for finishing the conversion

ADCDATA = ADC10MEM; //converted value is copied to a variable

if ((400 < ADCDATA) & (ADCDATA < 500)){ //lighting is controlled


P2OUT = 0x01; // according to the ADC values
}else if (ADCDATA < 400){
P2OUT = 0x03;
}else{
P2OUT=0x00;
}

Temperature and Humidity Reading

To obtain temperature and humidity data, DHT11 sensor was used. The DHT11 sensor
outputs a digital array. In this DHT sensor the data was obtained using 3 steps as mentioned
in the introductions. While using this sensor it has few errors when it works in 16Mhz clock,
therefore clock speed is limited to 8 Mhz

1. Request
To request the data from DHT11, the data pin should pulled down for 18ms and
pulled up for 48µs. in the Code pin is defined as P1.7 (BIT7)

P1DIR |= pin; // changing direction to output


P1OUT &= ~pin; // pulling down the pin
__delay_cycles(144000); //18ms delay @ 8Mhz
P1OUT |= pin; // pulling up the pin
__delay_cycles(320); //40us delay @ 8Mhz

2. Response

DHT11 should send a response of 54ms pull down Time and 80ms pull up time as the
response. In here Timer is defined as 1000

P1DIR &= ~pin;// changing the direction to input

while(!(P1IN&pin)){ //checking for Pull down response from DHT11

if (timer-- == 0){ //if nothing received for 125ms return zero


return 0;
}
}

while(P1IN&pin){ //checking for Pull up response from DHT11


if (timer-- == 0) { //if nothing received for 125ms return zero
return 0;

11
}
}

3. Reading data

In this DHT11 should send 40bits of data containing temperature and humidity data.

char bitcount = 7;
char byte = 0;
char bits[5] = {0,0,0,0,0}; //aray to receive 5 bytes.(40bits)
unsigned int timer;

char i;
for (i=0; i < 40; i++)
{
timer = TIMEOUT; //timer = 1000 = TIMEOUT
while(!(P1IN&pin)){ //checking for pull down responses
if (timer-- == 0){
return 0;
}
}

timer = TIMEOUT;
char t = 0;

while(P1IN&pin){ //checking for pull up responses


t++;
if (timer-- == 0){
return 0;
}
}

if (t > 40) bits[byte] |= (1 << bitcount); // data is receiving to to bit(5)


//array by bytes.bits are shifted
t = 0; // 7 bits
if (bitcount == 0)
{
bitcount = 7;
byte++;
}else{
bitcount--;
}
}
if((bits[0] + bits[2]) == bits[4]){ //checking for errors. Bit [4] is checksum
temp = bits[2]; // temperature bits were copied to a
// variable
humidity = bits[0]; //humidity bits were copied to variable
if ((temp>25)&&(temp<30)){ //turning on fans according to the obtained re
P1OUT=0x01; //L298 controller input is connected to P1.1
}

return 1;
}else{
return 0;
}

12
Complete Code

13
14
4. Conclusion
In the project we have completed every procedure of this project to successful
completion of the Power Saving Home Automation System. As a team, the team members
worked together in order to complete the objective which was given under the module of
EC3461 Embedded Systems Engineering module which was conducted by Mr. Manaram
Gnanasekara as our Subject Lecturer and Coordinator. In the field of industry the most
important component is the team work. Through this project team member worked as one
unit. Also there are many other components which is very important such as the knowledge,
principles, skills etc.

During the building process of home automation system, we were able to use most of covered
theories in the module and prerequisite modules such like Bitwise operations, shift operators,
analog to digital conversion, and digital communication theories.

Further improvement to the Home Automation

As further improvements, we would like to upgrade the existing MSP430G2 to an IOT


enabled MSP430 which is called MSP432 to control the automation system using a WAN
network.

15
5. References
1. http://robocraft.ru/files/datasheet/DHT11.pdf -DHT11 datasheet
2. http://www.ti.com/lit/ug/slau144j/slau144j.pdf -MSP430G2 series user guide
3. http://www.diyelectronics.co.za/store/ir/1294-infrared-obstacle-avoidance-proximity-
sensor-module-fc-51.html - FC51 Module
4. EC3461 Embedded system engineering Laboratories SLIIT
5. EC2131 Microcomputers Laboratories SLIIT

16

Das könnte Ihnen auch gefallen