31
SMART HOME USING EMBEDDED AL-Azhar University Faculty of Engineering - Communication Dep . Supervised By : Dr. Ahmed Yahya Team Members : Ahmed Hamdy Ammar Anwar Abdel Kader Blal Saleh Sadek Mohamed abdel Hameed Omar Lotfi el Tayifa

Smart home project technical paper [al azhar university]

Embed Size (px)

Citation preview

Page 1: Smart home project technical paper [al azhar university]

SMART HOME USING EMBEDDED

WEB

AL-Azhar University

Faculty of Engineering - Communication Dep.

Supervised By:

Dr. Ahmed Yahya

Team Members:

Ahmed Hamdy Ammar

Anwar Abdel Kader

Blal Saleh Sadek

Mohamed abdel Hameed

Omar Lotfi el Tayifa

Page 2: Smart home project technical paper [al azhar university]

Chapters:

1. INTRODUCTION

2. PROJECT MAIN BLOCK DIAGRAMS

3. COMPONENTS AND COST ANALYSIS

4. DESIGN APPROACH AND DETAILS

5. SCHEDULE, AND TASKS

6. CONCLUSION

7. REFERENCES

8. COMMENTS

9. APPENDICES

Page 3: Smart home project technical paper [al azhar university]

1. INTRODUCTION

1.1 Preface

A “smart home” is living environment embedded with a networked collection of hardware devices and software components to provide services that enhance autonomy and the quality of life for its inhabitants. Computer controlled sensors allow the home read information about people, objects, or conditions in the smart home environment, and computer controlled actuators allow the smart home to manipulate objects and appliances in the environment. General functions provided by the smart home include safety, security, and health monitoring; notification of emergencies, memory aids, and task assistance.

1.2 What Is A Smart Home?

A Smart Home is a popular term for a whole-house automation system involving the integration of Entertainment Centers, Lighting and Climate Control, and a Security System into one cohesive control system for the home. This level of integration enables the most complete response to any event in the home. For example, the push of a button labeled “party”, could set the interior/exterior lighting to the desired levels, lower the temperature set point by a couple degrees, launch the desired party playlist on the multi-room audio system, and disable the security alarm system. This level of capability has been built into our home resulting in what we believe to be the only true “Smart Home” in Cypress Ridge.

1.3 Abstract

The exponential growth of networking technology as well as microprocessors’ advancement drove to the development of new protocols ideally for applications such as home automation, industrial control, health monitoring etc. Moreover, with the rapid expansion of the Internet, there is the potential for the remote control and monitoring of such network enabled devices. However, the new and

Page 4: Smart home project technical paper [al azhar university]

exciting opportunities to increase the connectivity of devices within the home for the purpose of home automation remain largely unexploited.

1.4 Installed Features

One consistent user interface to control entertainment, lighting, and security

Automatic shut off of light in idle state Secured remote Internet access to monitor and control all non-

entertainment functions Open doors or windows automatically turn off the thermostat,

turned on only when all doors/windows are closed Family room lighting adjusted after sunset when TV turned on Custom heating/cooling cycles setup and altered through user

interface Away mode on-screen button activates the security and

surveillance systems Away mode response to zone intrusion or motion detection

includes sending SMS to homeowner and flashing all lights in addition to local siren and dial out options

1.5 Proposed Work

The focus of our project is on making the life more comfortable with a minimum cost of implementing such a system, for example the objective of design is to reduce the system’s complexity and lower fiscal costs. Hence, the system endeavors not to incorporate complex and expensive components

1.6 Evaluation

Quantitative results will compare our work with previous work and will highlight how our application works better. Some key factors for the evaluation will include performance, reduction of cost, ease of use, and how the product makes the lives of people easier and better. Maintaining and enhancing the quality of life for both older people and people with disabilities involves making independent living as easy as

possible .

Page 5: Smart home project technical paper [al azhar university]

2. PROJECT MAIN BLOCK DIAGRAMS

2.1 Embedded web server Module

As mentioned above the project will use the Ethernet so it has to understand the TCP/IP stack to function what needed from its protocols.

The hardware that is used in that part:

RJ45: all of us know it .it’s an ether net jack and it need to be interfaced with a small circuit that handle the deferential modulation of the ether net transmitting, for that we used a ready RJ45 module that has a build in differentiation handler circuit,this RJ45 is called BEL 0810-1xx1-03 that

also has two LEDs both can be use to show the status of the network.

ENC28J60 : Ether net controller that gets the frames from the Ether net and send it via an SPI interface to the responsible hardware this controller can be programmed via a SPI interface by giving it the MAC and IP addresses . this controller needs an 25 MHz crystal to operate and it gives an connection of 10 Mbps connection .but there is a problem with the ENC that is the working voltage it works on 3.3V so its outputs have to be shifted to be 0 or 1 for that we use the 74LC125 try stat

Page 6: Smart home project technical paper [al azhar university]

buffer to make shifting for the outputs to be exactly 5 volts also to cobble the serial eeprom from the ENC so the ENC can send data and the SEEPROM will ever harm the output and also the ENC cant affect the

SEEPROM ,why? This will be shown later .

PIC16F877A: powerful controller with (code memory) 64k Flash, 4k ram, 1k eeprom at 5 volts power supply these capabilities serve the ability of processing the TCP/IP stack and also it has 5 I/O ports 12bit ADC with 7

channels we used that controller with a 16Mhz crystal .

This IC works on 25 MHz with two power supplies one is the usual one the other on is used as an temporary source when the first supplier is disconnected this IC store the date as a BCD data inside it so when writing or reading to/from it we have to convert the data from BCD to know how to deal with it.

2.2 Wireless connectivity

ZigBee (IEEE 802.15.4) is a new global standard for wireless communications providing short-range cost effective networking capabilities that are suitable for applications in the industrial and home automation markets. Such applications require multi-month to multi-year battery life, lower data rates and less complexity than available from existing wireless standards.

While there are many technologies and standards previously used in other projects/products, Zigbee is the cutting–edge technology for wireless sensing for at least for the next 10 years. It is the ideal standard to be used for Wireless Home Automation for its power-saving and simplicity characteristics.

Page 7: Smart home project technical paper [al azhar university]

2.3 Sensor Network

Throughout this project, we have been establishing a Home Automation System using a RF Wireless Sensor Network (WSN). The system has a centralized architecture: Locally, a centralized controller receives information from multiple sensors and, once processed generates the opportune orders for the actuators. User control and monitoring system is established through a web interface that exchanges information with the local controller using the appropriate protocols.

Page 8: Smart home project technical paper [al azhar university]

2.4 Access Control

The Smart Home system have an access control system that will provide ID-based entry into the home and trigger the activation of a user-matched lighting and mode scheme, This system will use a password authentication mechanism to communicate with a microcontroller that will release an electric door strike for access and turn on a set of lights and mode corresponding to the pre-determined path of the user.

Page 9: Smart home project technical paper [al azhar university]

3. TECHNICAL SPECIFICATIONS

3.1 Components

Price in L.EDescriptionTypeQty.

4 x 22See page.. PIC16F877A42 x 25Input data to system4X4 Keypad2

Convert serial data to Ethernet data & vice versa

ENC24J601

2 x 3Clock generator for PIC4MHz Crystal

oscillator2

5Clock generator for ENC40MHz Crystal

oscillator1

3Clock generator for LM35DZ32KHz Crystal

oscillator1

25Display password as* 2X16 LCD Display

LMB162A1

93Display events and available

control functions4X16 LCD Display1

8Analog Temperature SensorLM35DZ13 x 2.5Voltage regulator to 5VLM78053

35See page...Stepper Motor14 x 5-Relay4

--Variety of resistors

--Variety of capacitors

3-Soldering Boards

3.2 Cost analysis

The prototype consists of an access module, sensors and Ethernet module. The parts for the prototype will total … L.E as shown in Table.

The total cost for having a Smart Home product installed in a typical 3 unit home with one main Ethernet embedded server averages to.. L.E. That price includes: parts, transportation, installation, and any services that are needed during the life of the product.

Page 10: Smart home project technical paper [al azhar university]

4. DESIGN APPROACH AND DETAILS

4.1 access control

Access Control System is designed for areas where need for security is crucial. It protects human life, property and information and provides safe and comfortable environment by limiting unnecessary access to essential areas such as office, building, and factory.The use of access control is becoming very popular because it can remove the manual aspect of entry involved with keys while also increasing security due to unique identification. Using access control for entrance into a building will not only increase convenience, but also allow for tracking of who has entered the building premises at a given time. This will increase home security and thus the safety of the occupants.

4.1.1 Circuit diagram:

Page 11: Smart home project technical paper [al azhar university]

4.1.2 Circuit Operation

“Easy to install, Convenient to use”When the user hit any key on the keypad , it trigger the microcontroller that a value is being inserted ,and a “*” mark appears on the LCD display ,after the user complete the five digit password the microcontroller process the password into algorithm ,the make a comparison with a pre-defined value, then make an action on the output port.

If the inserted pass word is wrong no action is being occurred unless the LCD is typing “access denied”, if repeated more than 3 times an intruder alarm become on.

4.1.3 Program Flow Chart

Page 12: Smart home project technical paper [al azhar university]

4.1.4 Source Code

The code is written in picbasic language

DEVICE=16F877AXTAL=4DECLARE LCD_TYPE 0 ‘these lines define LCD on MCUDECLARE LCD_DTPIN portC.4DECLARE LCD_RSPIN PORTC.3DECLARE LCD_ENPIN PORTC.2DECLARE KEYPAD_PORT PORTD ‘define keypad portDEFINE KEYPAD_BUTTONS 16 ‘define keypad size DIM VAR1, VAR2, KEY as BYTEDIM A ,B,C,D,E, XDIM SerDataALL_DIGITAL = TrueTRISC=0 ‘port c is outputMAIN:A=0X=1CLSPRINT "ENTER PASS:"LOOP: ‘this loop to scan the keypad VAR1 = INKEY DELAYMS 50 IF VAR1<16 THEN KEY = LOOKUP VAR1, [20,7,4,1,1,4,7,11,2,5,8,0,3,6,9,12,25]

PRINT AT 1, X+11,"*"X=X+1IF KEY=3 THEN A=3+XIF KEY=4 THEN B=4+XIF KEY=5 THEN C=5+XIF KEY=6 THEN D=6+XIF KEY=7 THEN E=7+X

IF X=6 THEN GOSUB CHECK

DELAYMS 500GOTO MAINENDIF

ENDIFGOTO LOOP

CHECK: ‘this subprogram to compare the

‘Password and make an action

DELAYMS 250

Page 13: Smart home project technical paper [al azhar university]

CLSIF A*B*C*D*E=45045 THEN HIGH PORTA.1PRINT "ACCESS GUARANTEED"ELSE PRINT "ACCESS DENIED"ENDIFRETURN END

4.1.5 Power Requirements

Source: 5V DC Voltage, 25 mA max input current

4.1.6 Environmental Requirements

Temperature Range: 0° to +85° C

Page 14: Smart home project technical paper [al azhar university]

4.2 Main control interface

It is very crucial to have interfaces that are convenient for inhabitants to use so they can easily interact with the smart home system. Three such interfaces are the web, and a visual LCD style programming environment.

4.2.1 Circuit diagram:

4.2.2 Circuit Operation

The Circuit is receiving information about events occurred in home and being read by sensors, adapting modes based on time read from the DS1307 I2C clock, it also permit the user to control home elements through the Keypad/LCD interface.

Page 15: Smart home project technical paper [al azhar university]

4.2.3 DS1307 I2C Clock

The DS1307 serial real-time clock (RTC) is a low power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus.The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12- hour format with AM/PM indicator. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply.Timekeeping operation continues while the part operates from the backup supply.

FEATURES- Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of

the Month, Month, Day of the week, and Year with Leap-Year Compensation Valid Up to 2100

- 56-Byte, Battery-Backed, General-Purpose RAM with Unlimited Writes

- I2C Serial Interface- Programmable Square-Wave Output Signal- Automatic Power-Fail Detect and Switch Circuitry- Consumes Less than 500nA in Battery-Backup Mode with

Oscillator Running

Page 16: Smart home project technical paper [al azhar university]

4.2.4 Program Flow Chart

4.2.5 Source Code

DEVICE=16F877AXTAL=4DECLARE LCD_TYPE 0 ‘define LCD on MCUDECLARE LCD_DTPIN PORTB.4DECLARE LCD_RSPIN PORTB.3DECLARE LCD_ENPIN PORTB.2DECLARE LCD_LINES 4 DECLARE SDA_PIN PORTa.0 ‘define serial I2C

‘portsDECLARE SCL_PIN PORTa.1DIM SEC as byte ‘seconds variableDIM MN as byte ‘minutes variable

Page 17: Smart home project technical paper [al azhar university]

DIM HR as byte ‘hour variableDIM WKDY as byte ‘week variableDIM DAY as byteDIM MON as byteDIM YR as byteDIM SerDataTRISB=0TRISA=0ALL_DIGITAL = TrueCLSPRINT $FE, $0F 'Blinking cursor on write_clock:MN=4 ‘numbers in BCDHR=6WKDY=2DAY=5MON=7YR=9BSTARTBUSOUT $D0BUSOUT 0BUSOUT $80BUSOUT MNBUSOUT HRBUSOUT WKDYBUSOUT DAYBUSOUT MONBUSOUT YRBSTOPBSTARTBUSOUT $d0BUSOUT 0BUSOUT 0BSTOPread_clock:SEC=BUSIN $D1,0 ‘number in BCDMN=BUSIN $D1,1HR=BUSIN $D1,2WKDY=BUSIN $D1,3DAY=BUSIN $D1,4MON=BSUIN $D1,5YR=BUSIN $D1,6FOR X=1 TO 255 VAR1 = INKEY DELAYMS 50 IF VAR1<16 THEN KEY = LOOKUP VAR1, [20,7,4,1,1,4,7,11,2,5,8,0,3,6,9,12,25]

PRINT AT 1, 1, "1=LIGHT"PRINT AT 1, 7, "2=FAN"PRINT AT 2, 1, "3=ALARM"

Page 18: Smart home project technical paper [al azhar university]

PRINT AT 2, 7, "4=DOOR"PRINT AT 3, 1, "5=ELEC"PRINT AT 3, 7, "6=INFO"PRINT AT 4, 1, "7=RESET ALL"

IF KEY=1 THEN SerData=%0001 SEROUT PORTA.0 , 24660 , [SerData]ENDIFIF KEY=2 THENSerData=%0010 SEROUT PORTA.0 , 24660 , [SerData]ENDIFIF KEY=3 THENSerData=%0011 SEROUT PORTA.0 , 24660 , [SerData]ENDIFIF KEY=4 THENSerData=%0100 SEROUT PORTA.0 , 24660 , [SerData]ENDIF IF KEY=5 THENSerData=%0101 SEROUT PORTA.0 , 24660 , [SerData]ENDIF IF KEY=6 THENPRINT AT 1,1,@ hr,":", @ mn,":" ,@ sec]ENDIFIF KEY=7 THENSerData=%0111 SEROUT PORTA.0 , 24660 , [SerData]ENDIF

ENDIFNEXTSTOPEND

4.3 Applications

4.3.1 Thermometer using A/D converter

In this application thermometer is designed. The application can be used to display the temperature in degrees centigrade

4.3.1.1 Circuit Diagram

(Note: This diagram was before merging with the Application circuit)

Page 19: Smart home project technical paper [al azhar university]

4.3.1.2 Circuit Operation

In this project a PIC16F77-type microcontroller is used. This is a 40-pin microcontroller with built-in 8 channel A/D converters, each having 10- bits of resolution. The microcontroller is operated from a 4 MHz resonator.The temperature sensor used is the LM35DZ 3-pin analog sensor with a range of 0°C to 100°C. LM35DZ provides an analog output voltage which is proportional to the measured temperature.

LM35 Precision Centigrade Temperature Sensors:

Page 20: Smart home project technical paper [al azhar university]

The device has 3 pins: Vs, Gnd, and Vo. Vs and Gnd are connected to the supply voltage and the ground, respectively. It is recommended by the manufacturers to use a 10_ resistor and a 1_F capacitor filter at the output of the sensor to minimize electrical noise. Vo is the analog output voltage given by Vo 10 mV/°C For example, at a temperature of 20°C the output voltage is 200mV. In this project LM35DZ is connected to analog input AN0 of the PIC16F77 microcontroller.- Supply Voltage +35V to −0.2V- Output Voltage +6V to −1.0V- Output Current 10 mA

4.3.1.3 Software

At the beginning of the program LCD connections and the A/D parameters are defined. Variable Res stores the converted data. A/D conversion is started using the ADCIN statement. When the conversion is complete, the converted data is available in register Res. The contents of Res can be converted into mille volts by multiplying it by 4.93. But, since the output of the sensor is 10 mV/°C, it will be necessary to divide Res by 10 in order to find the real absolute temperature in degrees centigrade.Thus, the temperature can be obtained by the following operation:Res * 4.93/10 = Res * 0.493 = 0.5 * ResIn the program, variable Res is multiplied by 2 to obtain the temperature with a 1°C accuracy (the resolution of the A/D converter is 19.53mV which is equivalent to nearly 2°C). The value of Res is then displayed on the LCD as a two-digit decimal number. The above process is repeated after one-second delay.For more accurate temperature measurements an A/D converter with a higher resolution will be required, e.g. 10-bit or higher.

4.3.1.4 Program Flow Chart

Page 21: Smart home project technical paper [al azhar university]

4.3.1.5 Source Code

Device = 16f877AXTAL = 4DECLARE ADIN_RES 10 ‘10-bit result required DECLARE ADIN_TAD FRC ‘RC OSC chosen DEFINE ADC_SAMPLEUS 50 ‘Allow 50us sample timeDIM VAR1 as WORD DIM Temp1 as ByteTRISA = 1 ‘RA0 (AN0) is inputDelayms 500ALL_DIGITAL = False ‘A/D clock is internal RC, select AN0

‘Turn on A/D converterADCON1 = %10000000 ‘Set analogue input on PORTA.0 MAIN:VAR1 = ADIN 0 ‘Place the conversion into variable VAR1

Page 22: Smart home project technical paper [al azhar university]

Temp1 = (VAR1-2) / 2 ‘convert to CCLSPrint at 1, 1,"Temp= ", DEC Temp1," C"Delayms 1000GOTO MAINEND

5. WORK PLAN & SCHEDULE

Time Frame Work Load

October 2009 – December 2009 Research

January 2010 Survey for parts

February 2010 Start building device

March 2010 – August 2010Continue building device and writing application to interact with device

June 2010 – August 2010 Testing and implementation

August 2010 Present Project

Page 23: Smart home project technical paper [al azhar university]

6 .CONCLUSION

Smart home technology can be extended onto applications such as

security systems, entertainment systems, and the healthcare industry.

The biggest asset to smart home technology is its ability to react in real

time in ways that humans cannot. With the advent of cheap

microcontrollers and the growing need for home interconnectivity,

smart homes are no longer a goal for the future but rather a standard

for new home builders and current home owners to consider. Smart

home technology provides a safe, secure living space that is more energy

efficient, autonomous, and flexible.

Page 24: Smart home project technical paper [al azhar university]

7. REFERENCES

TCP/IP Lean - Web Servers for Embedded Systems, Second Edition - Jeremy Bentham

PIC16F877A Data Sheet http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf

Discussion forum www.edaboard.com

8. COMMENTS

Comments from the grader will be inserted here