International Journal of Electronics and Computer Science Engineering Available Online at www.ijecse.org 798 ISSN- 2277-1956 Designing Home Automation System (HAS) using Java ME for Mobile Phone Sharon Panth 1, Mahesh Jivani 2 1 2 Shri M & N Virani Science College, Rajkot-360005 (Gujarat) India Department of Electronics, Saurashtra University, Rajkot-360005 (Gujarat) India 1 Email- sharon.panth20@gmail.com 2 Email- mnjivani@gmail.com Abstract - Home automation means to control home appliances and their characteristics like on and off, speed, volume and dimming. Since last few years, ICT (Information Communication Technology) have been increasingly embedded into surroundings. This inclination has been frequently referred to as pervasive or ubiquitous computing, where mobile devices are practiced widely. Home automation is taken up on the basis of simplicity, protection and power consumption effectiveness. This paper presents the design and implementation of an economical but yet flexible and secure home automation system based on Java and Bluetooth enabled mobile phone. The design is based on controlling an 8 bit Bluetooth interfaced microcontroller using User Interface (UI) of Java ME Application Program running on Bluetooth enabled Mobile Phone. The home appliances are connected to the on/off relay via microcontroller ports and controlled through two ways: one way is conventional domestic switch and second is through mobile phone. The communication between the mobile phone and the home automation system is through Bluetooth wireless technology. This system is designed to be economical and scalable allowing one to twenty four appliances to be controlled with minimum efforts. Password protection is being used to only allow authorized users to control the appliances at home. Keywords – Home Automation, Java ME, Microcontroller, Bluetooth, Mobile Phone I. INTRODUCTION In present era home automation systems are extensively used [1]. The wireless devices such as mobile phones used to connect their owners globally. They provide immense connectivity that other kinds of devices couldn’t provide; instead, with the embedded Bluetooth technology, they form an ad-hoc network in which devices can communicate with each other [2]. Application development for mobile phones is going to be in enormous requirement for the coming years. Ad hoc network programming plays an important role in wireless application development to take advantage of the connectivity these devices have to offer. Sun’s (now Oracle) Java platform Micro Edition (Java ME) [3] provides a great development platform for developing applications for the embedded electronics and mobile devices. Bluetooth technology is used to change the wires connecting movable/permanent devices while providing high levels of security. The Bluetooth technology is one of the standards to transform the way people perceive digital devices in our homes and office atmosphere. A basic strength of Bluetooth technology is the capability to handle data and voice transmissions simultaneously which offers users with a variety of novel solutions. Because of this novel feature, they form an ad-hoc network in which appliances can communicate with each other as per needs [4]. This wireless technology is very much useful in home automation to interconnect appliances [5]. It is best cost effective, secured and suitable option for home automation. Functioning on unlicensed, globally existing frequency of 2.4 GHz, it can link device and appliances surrounded by a range up to 100 m at the speed of 1 Mbps. Building upon this theme; we propose a home automation system application for mobile phones implemented using Java ME platform which use Bluetooth wireless technology for controlling appliances. ISSN 2277-1956/V2N2-798-807 799 Designing Home Automation System (HAS) using Java ME for Mobile Phone II. SYSTEM ARCHITECTURE The Home Automation System (HAS) developed during the course of this research consists of an User Interfaced (UI) Java ME Application program implemented on a Java based Bluetooth enabled mobile phone, and an 8 bit microcontroller based relay driver circuit with Serial Bluetooth Module, that is able to communicate with the Home- Figure 1. System Architecture -Appliances through the Bluetooth link. The system is based on serial data transmission using Bluetooth wireless communication in order to facilitate the appliances control in a HAS. This system ensures a secured exchange of data on wireless communication. It also supports conventional ON/OFF system of appliances. A user interface (UI) on the Java enabled mobile phone offers system connection and control utilities. ULN 2803 relay driver [6] and Serial Bluetooth Module from TINY OS [7] as well as Keil µvision IDE [8] for compiling C Language Code and uCflash+ programmer [9] for burning HEX file into microcontroller were used for the development. An ATMEL 89C51, 8 bit microcontroller [10] was used as an embedded relay controller. III. DEVELOPMENT PLATFORM This section describes the technologies used for developing the mobile phone application of the Home Automation System. The mobile phone application development presented in this paper is based on the following technologies: Java ME [3], Bluetooth [2], Networking in Java ME, JABWT. Java Platform, Micro Edition (Java ME) is a platform to write and run Java ME based applications on mobile devices. Bluetooth is a standard for wireless technology for fixed and mobile devices. Together, both the technologies provide a facility to create Java ME mobile applications using the Bluetooth Wireless Technology. This is fulfilled with the JSR-82 specification [11], Java APIs for Bluetooth. A. Java ME Java ME (Java Platform, Micro Edition) is the edition of Java “Java for Mobile Devices”. Java ME enables the developers to design and build mobile applications for the target consumer electronics and embedded devices. These applications suit the needs of a variety of information devices. It is a challenge for the developers to make compelling ISSN 2277-1956/V2N2-798-807 IJECSE, Volume 2 , Number 2 Sharon Panth and Mahesh Jivani content for small and resource-constrained devices. This helps the service providers to provide content to their customers over those devices. Java ME combines the functionality of the Java APIs and the reduced version of Java Virtual Machine. Java ME architecture consists of the Configuration, Profile and other optional packages. A Configuration includes the Java Programming Language features, a set of Java Virtual Machine features and some set of Java APIs. There are two types of Configurations: CDC (Connected Device Configuration) and CLDC (Connected Limited Device Configuration). A Profile can be termed as an extension to the Configuration. It consists of the libraries for the developers for the creation of mobile applications for the mobile devices. There are different types of Profiles like Figure 2. Java ME Stack Mobile Information Device Profile (MIDP), Foundation Profile, PDA Profile, Personal profile and many more which work either with CDC or CLDC type of Configurations. The MIDP (Mobile Information Device) Profile provides the Java runtime environment and a set of Java APIs when combined together with the CLDC Configuration for small computing devices. MIDP and CLDC combine together for writing applications for the Mobile Information Devices (MIDs). MIDP, JSR-118 [12] with CLDC is used for the current mobile application development. The “Write Once, Run Anywhere” term of Java still conforms for the quick deployment of these applications on a variety of mobile information devices that supports it. Java ME MIDP mobile devices were launched in April 2001, since then there has been rapid increase in the number of such devices leading to the growth of the mobile application development area. B. Bluetooth Bluetooth is a short-range wireless technology standard for radio transmissions between 2400–2480 MHz created by Telecom vendor Ericsson in 1994 [2]. This technology allows the creation of small, secured networks called the Personal Area Networks (PANs) and became an alternative to the RS-232 data cables. This standard is managed by the Bluetooth Special Interest Group, since 1998. Almost all the mobile devices embed small, low-power and cheap integrated chips in different electronic devices that work as short-range radio transceivers for the radio communications over Bluetooth. The popularity of Bluetooth technology also depends upon its security mechanisms provided using device pairing, authentication, encryption and authorization techniques. The MIDP support and the Bluetooth technology in the mobile devices gives a completely different alternative to create and deploy the mobile applications over the Mobile Information Devices (MIDs) with almost less or no cost. Bluetooth works using a number of protocols as defined in its layered architecture. The Bluetooth protocol stack or the architecture [13] as shown in the figure 3 defines the following protocols which can be used in the application. • • • LMP: The Link Management Protocol (LMP) establishes and controls the links between the devices on the controller. L2CAP: The Logical Link Control and Adaptation Protocol (L2CAP) maintain multiple logical connections between devices and allow assembling and disassembling of packets during communication. SDP: SDP is the Service Discovery Protocol that provides service discovery for the device. ISSN 2277-1956/V2N2-798-807 800 801 Designing Home Automation System (HAS) using Java ME for Mobile Phone • • RFCOMM: RFCOMM is the Radio Frequency Communication protocol, the replacement for the RS-232 cable to provide serial emulation. OBEX: OBEX (OBject EXchange) is an adopted session layer protocol for object exchange between the devices. Figure 3. Bluetooth API Stack The Bluetooth profiles [13] are the implementation of the Bluetooth protocols in full or partial manner defined and adopted by the Bluetooth SIG. The device manufacturers can maintain compatibility in their devices regarding the Bluetooth technology and to provide the services using the support of these profiles in there devices. Hence, a Bluetooth profile resides on the Bluetooth protocol stack and optionally requires the support of other protocols. The Bluetooth profile used in M-Board client-side mobile phone application is the Bluetooth Serial Port Profile (btspp) [13]. RFCOMM is a connection-oriented protocol. It provides streaming communication between the devices. The btspp profile and RFCOMM protocol are used in the application to access the serial port and communicate using streaming data. C. Keil µVision IDE Keil development tools for the 8051 Microcontroller Architecture support every level of embedded software development. The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels, Singleboard Computers, and Emulators support all 8051 derivatives. ‘C Language Program code’ for AT89c51 microcontroller is developed, compiled and debugged using Keil µVision IDE [8]. D. ucFlash+ Programmer The ucFlash+ Programmer [9] is an affordable, reliable, and fast programmer for MCS51/AVR Microcontrollers and 24Cxx I2C EEPROMs. The programmer is designed to operate with the Intel Pentium-based IBM-compatible desktop computers and notebook computers. No interface card is necessary to plug the module into a PC (this feature is especially handy for notebook computer users). The menu-driven software interface makes it easy to operate. ucFlash+ Programmer is used here for programming AT89C51 microcontroller for HAS. ISSN 2277-1956/V2N2-798-807 IJECSE, Volume 2 , Number 2 Sharon Panth and Mahesh Jivani IV. HOME AUTOMATION HARDWARE Home Automation Hardware is work as client part in Home Automation System and it is formulated in two ways like: (A) Automated and (B) Conventional A. Automated Automated way is an actual system and known as circuit for Home Automation System which is shown in Figure 4. Home Automation Circuit comprises microcontroller AT89C51, Serial Bluetooth Module, octal peripheral driver array ULN2803, regulator IC 7812, IC7805 and a few discrete components. Here in this circuit, microcontroller AT89C51 is worked as main programmable switching unit which receives data from Bluetooth serial module and transferred appropriate program data to ULN2803 for operating relay ON and OFF. The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt architecture, a full duplex serial port, and on-chip oscillator and clock circuitry. [10] Figure 4. Home Automation Circuit Power up the Circuit and scan the Bluetooth devices on Java ME Application enabled Mobile Device. If everything’s done correctly you will be able to find a Bluetooth device named ‘Tiny OS’ or name of Bluetooth Module. You will be asked for a pairing code in case of the above model (Tiny OS) it is 1234 but it might be different if you are using a Bluetooth module from another vendor. B. Conventional Conventional way means traditionally all the devices are controlled using “Switches” through switch board. Any user wants to make device ‘ON/OFF’ without using HAS then he/she can use particular switch attached to device. To incorporate this, relays are connected through ‘Two Way Switch’ as shown in figure 5. ISSN 2277-1956/V2N2-798-807 802 803 Designing Home Automation System (HAS) using Java ME for Mobile Phone Figure 5. Two Way Switch Connection with Relay V. HOME AUTOMATION SYSTEM APPLICATION PROGRAM A mobile phone having the Bluetooth connectivity can connect to any other device in its range. The communication channel is established over these Bluetooth enabled devices and communications can take place between these devices. The RFCOMM protocol adapts only a part of the ETSI TS 07.10 standard [13]. It is built on top of the L2CAP protocol, as shown in the Bluetooth protocol stack in figure 3. RFCOMM allows the device manufacturers to easily extend the serial port functionality of their Bluetooth devices. The implementation hence uses the combination of the Bluetooth serial port profile and the RFCOMM protocol implementing JABWT with Networking in Java ME. Figure 6. HAS Application Program Selection Screens on Mobile Phone ISSN 2277-1956/V2N2-798-807 IJECSE, Volume 2 , Number 2 Sharon Panth and Mahesh Jivani There are two methods to establish connections between the communicating devices using Bluetooth. First is the Discovery method where the device discovers other Bluetooth enabled devices. In second case, is the Known method which allows direct connection to be established between the remote devices that are already known. Our application works using the second method. The advantage of using the second method is that we can establish connection directly by specifying the known device’s address (here Bluetooth Serial Adapter) within very less time as compared to the first method where it searches for Bluetooth enabled devices first in its range and then establishes connection, if wanted. The JABWT implementation includes the support for btspp protocol over RFCOMM service. For the communication between the mobile phone and the embedded system (i.e. Home Automation system) the connection string must contain the btspp protocol in the URL. This is implemented by using the Connector class in the GCF Hierarchy. The Connector class creates new connections dynamically using the protocol implementation class formed from platform name (from system property) and protocol name (from the parameter string provided by the developer). The parameter string that describes the target should conform to the URL format as described in RFC 2396 [13]. This takes the general form: {scheme} :[{ target}][{params}] The {scheme} is the name of a protocol such as http}. The {target} is normally some kind of network address. {params} are formed as a series of equates of the form ";x=y". The Connector class open method has a parameter of connection string and this is casted as per the requirement of the connection in the application. The connection string used in the mobile phone application is in the format of the following: btspp://address : port Where, btspp:// is the Bluetooth Serial Port Profile, address is the Bluetooth known remote device address of 12 digit hexadecimal format, port is the port number or the communication channel on which the remote device receives data. For example, btspp:// 001207121217:1 The user must have a mobile phone with MIDP support. The application must be transferred to the phone and installed on it. When user launches the application it displays the Initial screen as shown in figure 6. This screen has an option to exit the application or to connect to the already enabled embedded system. When the user attempts to connect to the embedded system and if the connection is successful then the client application gives appropriate message and opens the serial port for communication. For unsuccessful connection, it displays a message and allows user to attempt the connection again. This process goes on until user desires to exit the application. Otherwise, for successful connections the user is redirected to a screen providing options to select from within the list of the rooms inside the house where the embedded systems are enabled and ready to connect and communicate with the mobile phone. The user can select any option that gets the mobile phone connected with the embedded system of that room. The user can abruptly end the application here if he does not want to continue further. After selecting a particular room the next screen comes up with the list of electrical devices in that particular room. Now the user can select any electrical Home Appliance to make it ON or OFF the already ON device simultaneously. The user also gets the message regarding which device is ON/OFF in the mobile phone as shown in figure 8(b). And finally the user can quit the application. ISSN 2277-1956/V2N2-798-807 804 805 Designing Home Automation System (HAS) using Java ME for Mobile Phone (a) (b) Figure 7. Flow Chart : (a) Mobile Application Program (b) Microcontroller Program VI. MICROCONTROLLER AT89C51 PROGRAM The program (HAC.c) for the microcontroller is written in C and compiled using Keil µVision IDE to generate hex code. The generated hex code is burnt into the microcontroller using an uC Flash+ programmer. The program coding starts with ‘#include <reg51.h>’ header files. The microcontroller port pins are defined using ‘sbit’ function for interfacing with the surrounding peripherals. By selecting device checkbox in Home Automation Application program which is developed using Java ME platform and installed on mobile device, will transmit ASCII characters serially through Bluetooth and on the receiving side microcontroller receives data through serial Bluetooth module on serial port of microcontroller AT89C51. SBUF register will understand this ASCII characters as equivalent HEX value which will be ported to Port 0, 1, and 2’s pins of AT89C51. For operating Relay1 in ON condition, one has to select ‘device1’ check box of ‘Room1’ means ASCII character “A” will be transmit and microcontroller will receive equivalent value in HEX through SBUF register which is “0x41” through Bluetooth serial module which makes ‘pin 1 of Port 0’ high and for making Relay1 in OFF condition simply unchecked ‘device1’ check box of ‘Room1’ means ASCII character ‘a’ will be transmit, microcontroller will receive equivalent value in HEX through SBUF register which is “0x61” which makes ‘pin 1 of Port 0’ low. Same ISSN 2277-1956/V2N2-798-807 IJECSE, Volume 2 , Number 2 Sharon Panth and Mahesh Jivani way you can ON and OFF relay connected to Port 0, 1 and 2. Java ME Application program on mobile transmit following combination given in Table 1. Table -1 Java Me Application Program Transmission Combination Character Capital letters A to H Small letters a to h Capital letters I to P Small letters i to p Capital letters Q to X Small letters q to x AT89C51 Port Port 0 Port 0 Port 1 Port 1 Port 2 Port 2 Relay Number 1 to 8 (Individual) 1 to 8 (Individual) 9 to 16 (Individual) 9 to 16 (Individual) 17 to 24 (Individual) 17 to 24 (Individual) Status ON OFF ON OFF ON OFF IV.IMPLEMENTATION Power up the Circuit and scan the Bluetooth devices on your Mobile Device. If everything’s done correctly you will be able to find a Bluetooth device named ‘Tiny OS’ or name of Bluetooth Module. You will be asked for a pairing code in case of the above model (Tiny OS) it is 1234 but it might be different if you are using a Bluetooth module from another vendor. (a) (b) Figure 8. Real implementation (a) HAS Prototype Board (b) Java Me Program Screen Shot Figure 8 shows the real implementation of HAS. As shown in figure 8, follow the steps for operating devices listed in program. 1. Start Bluetooth connection of your mobile phone. 2. Open the ‘HAS’ application on your mobile phone. 3. Select connect device from option menu using scan for new devices. 4. ‘Bluetooth Serial Module will be available under ‘select a device to connect’ list. 5. Pair ‘Bluetooth Serial Module’ by providing pair code ‘1234’. 6. Start selecting particular device for making ‘ON/OFF’ from List Menu as shown in figure 6, you will see relay ON and OFF according to combination shown in Table 1. VII. CONCLUSION Design and implementation of a Home Automation System using Java ME for mobile phone has been discussed. The purpose of the system is to use mobile phone’s inbuilt Bluetooth facility for automation without using Air Time. Different hardware and software unit of the system are described. The complete application software has been designed using Java ME, Bluetooth API and C Language. The HAS application program is tested on various Java ME mobile phones and the results are presented which are quite satisfactory and response received from the community in general is encouraging. The HAS furnishes a good paradigm for any Automation System based on Mobile Phone and Bluetooth. ISSN 2277-1956/V2N2-798-807 806 807 Designing Home Automation System (HAS) using Java ME for Mobile Phone REFERENCE [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] M. Chan, D. Esteve, C. Escriba, E. Campo, “A review of smart homes—Present state and future challenges”, Computer methods and programs in biomedicine, Elsevier, 9I, pp. 55-81, 2008. J. Haartsen, "BLUETOOTH—The universal radio interface for ad hoc, wireless connectivity", Ericsson Review No. 3, pp. 110-117, 1998. E. R. Harold, " Java Network Programming third edition," O'Reilly Media, ISBN: 978-0-596-00721-8, 2004. N. Sriskanthan, F. Tan, A. Karande, "Bluetooth based home automation system", Microprocessors and Microsystems, Elsevier, 26, pp. 281289, 2002. C.Gomez and J. Paradells, "Wireless home automation networks: A survey of architectures and technologies", IEEE Communications Magazine, Vol.48, No.6, pp. 92-101, 2010. Darlington Transistor Array, Texas Instruments, http://www.ti.com/lit/ds/symlink/uln2803a.pdf, last seen on April, 2013. Serial Bluetooth Module, Tiny OS Electronics, http://www.tinyosshop.com/index.php?route=product/product&product_id=330, 2013. Keil µvision IDE, http://www.keil.com/uvision/, last seen April 2013. uCFlash+ Programmer, UC Micro Systems, http://www.ucmicrosys.com/products/ic-programmers/ucflash.html, last seen on April 2013. AT89c51 8 bit Microcontroller, ATMEL Corporations, http://www.atmel.com/images/doc0265.pdf, last seen on April 2013. JABWT : Java APIs for Bluetooth, http://docs.oracle.com/javame/config/cldc/opt-pkgs/api/bluetooth/jsr082/index.html J.W. Muchow, “Core J2ME Technology and MIDP”, Prentice Hall, ISBN: 0130669113, 2001. P. Singh P, S. Sharma, S. Agrawal, “Study of Bluetooth wireless technology using java”, Indian Journal of computer Science and Engineering (IJCSE), Vol. 2, No. 3, pp. 295-307, 2011. ISSN 2277-1956/V2N2-798-807