Sei sulla pagina 1di 16

Abstract:

The project is designed to operate electrical appliances using an Android application device. The system operates electrical appliances depending on the data transmitted from the Android application device. Operating conventional wall switches is difficult for elderly or physically handicapped people. This proposed system solves the problem by integrating house hold appliances to a control unit that can be operated by an Android smart-phone/Tablet etc. Remote operation is achieved by any smart-phone/Tablet etc., with Android O , upon a !"# $!raphical "ser #nterface% based touch screen operation, interfaced to Arduino controller board. The program on the written for Arduino serially communicates with &luetooth device to generate respective output based on the input data $sent from Android application device% to operate a set of relays through a relay driver #'. The loads are interfaced to the control unit through the relays. The system can be used in e(isting domestic area for either operating the loads through conventional switches wirelessly through Android smart-phone.

Introduction:
)ith the development of technology and the continuous improvement of people*s living standard, people are in pursuit of automated, intelligent and convenient home control systems. At present, the +' is used as the remote control terminal for most home control systems, however, there are some problems in the +' monitor terminal, such as its great bul-, inconvenience to carry, high cost, limited monitoring range and so on. Therefore, it.s a good choice to design a terminal based on phone. )ith the popularity of smart phones, particularly, the phone based on Android system is rapidly developed. At its #/O developer conference, !oogle showed a sneapreview of its Android /ome project, which will e(tend the Android platform into household objects. #t means that the remote control based on Android phone will become a mainstream way. After logging into the control interface, users can easily control the lights, T0s and air conditionings anytime, anywhere, which brings great convenience to people and improves the 1uality of life.

The system scheme:


The system is composed of android mobile terminal, &luetooth module, Arduino board and a relay used to connect various appliances for automated control. An android application is created using eclipse #23 $integrated development environment%, which involves buttons re1uired for controlling the appliances remotely using the android smart phone. "sers send commands by touching the appropriate buttons.

Arduino:
Arduino is an Open /ardware project started in 4556 that tries to bring the world of digital electronics to education, research, and the ma-er community. Arduino stands for ease of use, openness and world-wide availability. Arduino started as a simple prototyping circuit board, a small computer, running at 78 9/: #t has no screen and no -eyboard, and therefore re1uires an e(ternal computer to program it. That computer has to run a piece of software called the Arduino #23 that helps with writing, compiling, and uploading programs into the board. The board is then autonomous, it doesn.t re1uire the computer or the #23 to continue e(ecuting the uploaded code.

Arduino Uno:
This is the most e(tended board from the Arduino family. The board carries an ;-bit microcontroller, and it comes with 7< digital input/output pins and 8 analog inputs. i( of the digital pins can be programmed to send pulse width modulation $+)9%. The "no board also comes with internal peripherals able of running the "ART, +#, and #4' communication protocols. +rograms using the Arduino "no board can be as big as =5 >bytes and run at 789/:

Arduino "no is a very versatile board that has become the wiss army -nife of the ma-er community. #n literally five minutes you can plug this board into your computer and start programming it. #t has a disadvantage, though? @ou cannot use it to communicate directly with an Android device, because it lac-s the " & /ost functionality. /owever, shields are available that can bring the " & /ost functionality to the board, as well as some that could add &luetooth communication. &oth methods allow the microcontroller to tal- to Android devices.

ummary
9icrocontroller Operating 0oltage #nput 0oltage $recommended% #nput 0oltage $limits% 2igital #/O +ins Analog #nput +ins 2' 'urrent per #/O +in 2' 'urrent for =.=0 +in Blash 9emory RA9 33+RO9 'loc- peed ATmega=4; 60 A-740 8-450 7< $of which 8 provide +)9 output% 8 <5 mA 65 mA =4 >& $ATmega=4;% of which 5.6 >& used by boot loader 4 >& $ATmega=4;% 7 >& $ATmega=4;% 78 9/:

+ower
The Arduino "no can be powered via the " & connection or with an e(ternal power supply. The power source is selected automatically. 3(ternal $non-" &% power can come either from an A'-to-2' adapter $wall-wart% or battery. The adapter can be connected by plugging a 4.7mm center-positive plug into the board*s power jac-. Ceads from a battery can be inserted in the !D2 and 0#D pin headers of the +O)3R connector. The board can operate on an e(ternal supply of 8 to 45 volts. #f supplied with less than A0, however, the 60 pin may supply less than five volts and the board may be unstable. #f using more than 740, the voltage regulator may overheat and damage the board. The recommended range is A to 74 volts. The power pins are as follows?

0#D. The input voltage to the Arduino board when it*s using an e(ternal power source $as opposed to 6 volts from the " & connection or other regulated power source%. @ou can supply voltage through this pin, or, if supplying voltage via the power jac-, access it through this pin.

60.This pin outputs a regulated 60 from the regulator on the board. The board can be supplied with power either from the 2' power jac- $A - 740%, the " & connector $60%, or the 0#D pin of the board $A-740%. upplying voltage via the 60 or =.=0 pins bypasses the regulator, and can damage your board. )e don*t advise it. =0=. A =.= volt supply generated by the on-board regulator. 9a(imum current draw is 65 mA. !D2. !round pins. #OR3B. This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the #OR3B pin voltage and select the appropriate power source or enable voltage translators on the outputs for wor-ing with the 60 or =.=0.

#nput and Output


3ach of the 7< digital pins on the "no can be used as an input or output, using pinMode (),
digitalWrite(), and digitalRead() functions. They operate at 6 volts. 3ach pin can provide or

receive a ma(imum of <5 mA and has an internal pull-up resistor $disconnected by default% of 45-65 -Ohms. #n addition, some pins have speciali:ed functions?

erial? 5 $RE% and 7 $TE%. "sed to receive $RE% and transmit $TE% TTC serial data. These pins are connected to the corresponding pins of the ATmega;"4 " &-to-TTC erial chip. 3(ternal #nterrupts? 4 and =. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. ee the attachInterrupt () function for details. +)9? =, 6, 8, F, 75, and 77. +rovide ;-bit +)9 output with the analogWrite () function. +#? 75 $ %, 77 $9O #%, 74 $9# O%, 7= $ '>%. These pins support +# communication using the SPI library.

C32? 7=. There is a built-in C32 connected to digital pin 7=. )hen the pin is /#!/ value, the C32 is on, when the pin is CO), it*s off.
5

The "no has 8 analog inputs, labeled A5 through A6, each of which provide 75 bits of resolution $i.e. 754< different values%. &y default they measure from ground to 6 volts, though is it possible to change the upper end of their range using the AR3B pin and the analogReference $% function. Additionally, some pins have speciali:ed functionality?
T)#? A< or 2A pin and A6 or 'C pin. upport T)# communication using the Wire library.

There are a couple of other pins on the board?


AR3B. Reference voltage for the analog inputs. "sed with analogReference $%.

Reset. &ring this line CO) to reset the micro controller. Typically used to add a reset button to shields which bloc- the one on the board.

ee also the

apping bet!een "rduino pin# and "$ ega32% port#. The mapping for the

Atmega;, 78;, and =4; is identical.

'ommunication
The Arduino "no has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega=4; provides "ART TTC $60% serial communication, which is available on digital pins 5 $RE% and 7 $TE%. An ATmega78"4 on the board channels this serial communication over " & and appears as a virtual com port to software on the computer. The *78"4 firmware uses the standard " & 'O9 drivers, and no e(ternal driver is needed. /owever, Gtoc<. The Arduino software includes a serial monitor which allows simple te(tual data to be sent to and from the Arduino board. The RE and TE C32s on the board will flash when data is being transmitted via the " &-to-serial chip and " & connection to the computer $but not for serial communication on pins 5 and 7%. A Soft!areSerial library allows for serial communication on any of the "no*s digital pins. The ATmega=4; also supports #4' $T)#% and +# communication. The Arduino software includes a )ire library to simplify use of the #4' bus, see the docu entation for details. Bor +# communication, use the SPI library.

&

&luetooth options?
The early implementations of the Android Open Accessory $AOA% didn.t include the possibility of creating accessories over &luetooth. Also, until the deployment of Broyo $codename for Android.s release 4.4%, there was no way for the developers to even access the &luetooth port in the phones and tablets running Android. Brom the moment Broyo was released, you could develop applications that could connect to Android devices. The applications could call the basic functions within the operating system to pair to &luetooth devices and open a transparent serial port connection to them. #t is possible to, for e(ample, use the Arduino &luetooth board to connect to the phone wirelessly. An e(ample of this is shown in figure, where you can see the De(us One, an Arduino &luetooth board, and a specially made shield to control up to si( motors using the +)9-enabled pins on the board.

Android:

'

Android is the world*s most popular operating system for mobile devices and tablets. #t is an open source operating system, created by !oogle, and available to all -inds of developers with various e(pertise levels, ranging from roo-ie to professional. Brom a developer*s perspective, Android is a Cinu(-based operating system for smart phones and tablets. #t includes a touch screen user interface, widgets, camera, networ- data monitoring and all the other features that enable a cell phone to be called a smart phone. Android is a platform that supports various applications, available through the Android +lay tore. The Android platform also allows end users to develop, install and use their own applications on top of the Android framewor-. The Android framewor- is licensed under the Apache Cicense, with Android application developers holding the right to distribute their applications under their customi:ed license.

"nderstanding Android
To begin development on Android even at the application level, # thin- it is paramount to understand the basic internal architecture. >nowing how things are arranged inside helps us understand the application framewor- better, so we can can design the application in a better way. Android is an O based on Cinu(. /ence, deep inside, Android is pretty similar to Cinu(. To begin our dive into the Android internals, let us loo- at an architectural diagram.

Applications
The diagram shows four basic apps $App 7, App 4, App = and App <%, just to give the idea that there can be multiple apps sitting on top of Android. These apps are li-e any user interface you use on Android, for e(ample, when you use a music player, the !"# on which there are buttons to play, pause, see-, etc is an application. imilarly, is an app for ma-ing calls, a camera app, and so on. All these apps are not necessarily from !oogle. Anyone can develop an app and ma-e it available to everyone through !oogle +lay tore. These apps are developed in Hava, and are installed directly, without the need to integrate with Android O .

Application Brameworcratching further below the applications, we reach the application framewor-, which application developers can leverage in developing Android applications. The framewor- offers a huge set of A+#s used by developers for various standard purposes, so that they don*t have to code every basic tas-. The framewor- consists of certain entities, major ones are? Activity 9anager This manages the activities that govern the application life cycle and has several states. An application may have multiple activities, which have their own life cycles. /owever, there is one main activity that starts when the application is launched. !enerally, each activity in an application is given a window that has its own layout and user interface. An activity is stopped when another starts, and gets bac- to the window that initiated it through an activity callbac-. Dotification 9anager This manager enables the applications to create customi:ed alerts 0iews 0iews are used to create layouts, including components such as grids, lists, buttons, etc. Resource 9anagers Applications do re1uire e(ternal resources, such as graphics, e(ternal strings, etc. All these resources are managed by the resource manager, which ma-es them available in a standardi:ed way. 'ontent +rovider Applications also share data. Brom time to time, one application may need some data from another application. Bor e(ample, an international calling application will need to

1)

access the user*s address boo-. This access to another application*s data is enabled by the content providers.

Cibraries
This layer holds the Android native libraries. These libraries are written in '/'II and offer capabilities similar to the above layer, while sitting on top of the -ernel. A few of the major native libraries include urface 9anager? 9anages the display and compositing window-ing manager. - 9edia framewor-? upports various audio and video formats and codecs including their playbac- and recording. ystem ' Cibraries? tandard ' library li-e libc targeted for AR9 or embedded devices.

Open!C 3 Cibraries ? These are the graphics libraries for rendering 42 and =2 graphics. JCite ? A database engine for Android.

Android Runtime
The Android runtime consists of the 2alvi- 0irtual 9achine. #t is basically a virtual machine for embedded devices, which li-e any other virtual machine is a bytecode interpreter. )hen we say it is for embedded devices, it means it is low on memory, comparatively slower and runs on battery power. &esides the 2alvi- 0irtual 9achine, it also consists of the core libraries, which are Hava libraries and are available for all devices.

>ernel
The Android O is derived from Cinu( >ernel 4.8 and is actually created from Cinu( source, compiled for mobile devices. The memory management, process management etc. are mostly similar. The -ernel acts as a /ardware Abstraction Cayer between hardware and the Android software stac-.

Blue-tooth Arduino processing:

11

int state = 0; int incomingByte; void setup() { //set pin 12 to output mode pinMode(12, OUT UT); !e"ia#$%egin(&'00); ( void #oop() { // see i) t*e"e+s incoming se"ia# data, i) (!e"ia#$avai#a%#e() - 0) { // "ead t*e o#dest %yte in t*e se"ia# %u))e", incomingByte = !e"ia#$"ead(); // depending on t*e incoming %yte do t*e need)u# action i) (incomingByte == +1+) { digita#."ite(12, /01/); de#ay(200); !e"ia#$p"int#n(3O43); state=1; ( e#se i) (incomingByte ==+2+) { digita#."ite(12, 5O.); de#ay(200); !e"ia#$p"int#n(3O663); state = 0; ( ( i)(state) !e"ia#$p"int#n(3O43); e#se !e"ia#$p"int#n(3O663);
12

de#ay(220); (

Blue-tooth android processing: &lue-tooth Receivers ? Coo-ing out for &lue-tooth devices

To listen/loo- out for any &luetooth devices that are within range, we need to create and register a &roadcast receiver.

)hen registering a &roadcastReceiver, you will need to tell the program what it is you are loo-ing / listening out for. #n our case we want to listen out for occasions whereby a &luetooth device is BO"D2. This is represented by? &luetooth2evice.A'T#ODKBO"D2 - this is sent or broadcast when a &luetooth device is found $when in discovery mode%. #f a &luetooth2evice is found, then the designated &roadcastReceiver will be called. )e ma-e our own &roadcastReceiver in order to perform a tas- such as displaying the name of the discovered device on the phone. /owever, before you will find anything, you have to start 2iscovering. This is done by calling the start2iscovery$% method of the default &luetooth adapter.

Android processing: 2iscover bluetooth


13

14

import android.content.&roadcastReceiver, import android.content.'onte(t, import android.content.#ntent, import android.content.#ntentBilter, import android.widget.Toast, import android.view.!ravity, import android.bluetooth.&luetoothAdapter, import android.bluetooth.&luetooth2evice, boolean found2eviceLfalse, //)hen this is true, the screen turns green. //!et the default &luetooth adapter &luetoothAdapter bluetooth L &luetoothAdapter.get2efaultAdapter$%, /MThe startActivityBorResult$% within setup$% launches an Activity which is used to re1uest the user to turn &luetooth on. The following onActivityResult$% method is called when this Activity e(its. M/ NOverride protected void onActivityResult$int re1uest'ode, int result'ode, #ntent data% O if$re1uest'odeLL5% O if$result'ode LL R3 "CTKO>% O Toast9aster$P&luetooth has been switched ODP%, Q else O Toast9aster$P@ou need to turn &luetooth OD RRRP%, Q Q
15

1&

Potrebbero piacerti anche