The 4th International Symposium on Engineering, Energy and Environments 8-10 November 2015, Thammasat University, Pattaya Campus, Thailand
An Internet-based Remote Switching Software Development using Cloud-based and Rapid Development Tools Watchara Amasiri, Saran Lerdnantawat and Dahmmaet Bunnjaweht* Department of Electrical and Computer Engineering, Faculty of Engineering, Thammasat University, Klong Luang, Pathumthani, Thailand, 12120
Abstract
Embedded systems are ubiquitous in our lives today. Their value is constantly growing due to hardware and software technology advancements along with end user market demands. The proliferation of embedded devices, the expansion of open source development, the available hardware support and the networking capabilities have all helped the design of new embedded systems. There have been as many embedded systems, industrial equipment, sensor devices, instruments and other objects connected to the Internet as humans using computers, smart phones, and other electronics for information technology. The enormous potential of the Internet of things has become the hottest topic in the electronics industry. Internet of things functionality designed into equipment or web-enabled devices will become a critical factor in the sale of the majority of all end-user systems by the end of this decade. In 2008, Google released the Android mobile phone operating system. This began the tremendous growth of mobile applications in the consumer world. The total Android devices shipped have surpassed one billion before the end of 2014. In this paper, an internet-based switching control was developed. The embedded hardware core was an Arduino Mega 2560 with an Ethernet shield. The control software was implemented using cloud-based and rapid development tools that are MIT App Inventor II and NI LABVIEW, respectively. This implementation has a user-friendly interface via Android mobile phone and personal computer. Connection through the Internet is easily achievable, enabling remote control from anywhere in the world. The system supports both DHCP and static IP addresses. The control software is designed to achieve the point and click interface. With minimal modification the system can be used for lighting control, office systems, home automation and remote control over the Internet.
Keywords : Remote switch, embedded system, internet of things, Android phone, mobile application
* Corresponding author. (Tel.) +662 5643001 E-mail address:
[email protected]
W. Amasiri et al./ The 4th International Symposium on Engineering, Energy and Environments (2015)
1. Introduction With the popularity of the Internet, Internet-based control systems using computers or embedded systems have gained more and more popularity and reliability. There are many possible applications ranging from simple home appliance control to more sophisticated supervisory control and data acquisition (SCADA) system. Under the light of the Internet of things (IoT), there are more and more objects that feature an IP address for Internet connectivity, along with the communication that occurs between these objects and other Internet-enabled devices and systems. The network-enabled devices in smart homes become not only popular, but also affordable. The simplicity of smartphone and tablet usage has driven many application developments to center around these devices. The remote switching in Internet network was implemented in [1]. The main control unit was connected with 8255. Main control unit was used for data transmission and reception from the computer. Switch driver was used for turning the electric appliance on-off. The onoff status detector was built for checking and monitoring the electrical appliance status. A wireless alternative was designed and implemented for home automation system in [2]. An ATMEL 89Χ52 microcontroller was employed. The design integrated the ATMEL 89Χ52 microcontroller and the GSM module as a machine-to-machine (M2M) core. In [3], an Internet-based wireless home automation system for multifunctional devices was implemented. The system combined the PIC16F877 microcontroller and the 433MHz FM module as network nodes. A design of multi-channel wireless remote switch control system for smart home control system was discussed in [4]. The system used the single chip microcomputer (SCM) AT89S52 as the control core and the wireless encoding and decoding chip PT2262/2272 as the wireless communication core. Since 2008, the mobile phone landscape has changed dramatically with the introduction of smart phones running Android, a platform marketed by Google [5]. Mobile applications are now changing how people experience computing and use mobile phones. In 2010, Google announced the beta release of the App Inventor for Android (AIA) visual programming environment. In July 2010, MIT App Inventor was released. It is a cloud-based development tool that allows users to create authentic mobile application for the Android platform [6]. In this work, the software for embedded controller was built on an Arduino platform and written in C/C++. The mobile application software for Android device was implemented using MIT App Inventor II and the software for PC client was implemented using NI LabVIEW. Both of these development tools have a block-based platform. 2. Embedded Controller An Arduino MEGA 2560 is an essential part of this embedded hardware. The Arduino MEGA 2560 is a microcontroller board based on the ATmega2560, which is a highperformance Atmel 8-bit AVR RISC-based microcontroller. An Arduino Ethernet shield [7] is required to provide an Ethernet network capability. The Arduino Ethernet shield is an addon peripheral that is compatible with most Arduino platforms. An embedded controller program is written in C/C++. The integrated development environment (IDE) comes with a library called Ethernet for Arduino Ethernet Shield. This feature makes software implementation for the embedded device and client device easier. The controller program is built to work with Hypertext Transfer Protocol (HTTP). The command reception and status transmission are performed using GET method.
W. Amasiri et al./ The 4th International Symposium on Engineering, Energy and Environments(2015)
NETWORK
Fig. 1. Internet-based switch connection method
Firstly, the controller program will initiate the Ethernet shield chipset. Then, it will receive IP address and analyze the packets received from the client. The program looks for a command containing the HTTP message. If the specific commands are detected, the Arduino will configure the digital output state to switch on or off depending on the decoded command. The pseudocode for embedded controller is given in Fig 2. Pseudocode – Embedded controller 1 Initiate Ethernet shield 2 Infinite Loop 3 Looking for GET request 4 Which command? 5 Switching case; Write 0 or 1 to digital pin 6 Monitoring case; Send status back to client 7 End
Fig. 2. Pseudocode – Embedded controller
To monitor the client status, the embedded controller connects to the client device using a simple web page connection. Once the client device is ready to receive a status, the controller will send the status message in a simple Hypertext Markup Language (HTML) form. This operation makes the client device programming easier. 3. Client Application Client application is designed to be used by Android device or personal computer. The client application supports both status monitoring mode (monitoring mode) and switch selection mode (switching mode). Pseudocode – Client Device – Monitoring Mode 1 Connect to controller via HTTP 2 Infinite loop (500ms) 3 Get switching status 4 Display switching status 5 End
Fig. 3. Pseudocode for client device in monitoring mode
In both modes, the system operates on the HTTP request and the HTTP response and employs the GET method. The client will retrieve new data every 500 milliseconds for each
W. Amasiri et al./ The 4th International Symposium on Engineering, Energy and Environments (2015)
update cycle. Pseudocode for monitoring mode and switch selection mode are shown in Fig. 3 and Fig. 4, respectively. Pseudocode – Client Device – Switching Mode 1 Connect to controller via HTTP 2 Wait for button pressing 3 Which button? 4 Send command 5 End
Fig. 4. Pseudocode for client device in switching mode
3.1. Android Device Application An Android device application is built on MIT App Inventor II. Using block-based programming platform [6], the MIT App Inventor II is a cloud-based development tool that can generate an Android application on the web browser. This block-based programming platform allows the user to put various blocks together to create a device application. (a)
(b)
Fig. 5. (a) Android client application; (b) Example sour code for send a command via GET method
The MIT App Inventor II has a designer area, used for application screen design, and a block area, used for source code editor. There are also many components included such as sound feature, sensor connection, social connection and Bluetooth connection. To install an application, MIT App Inventor II connects to target Android hardware via USB or Wi-Fi connection. In addition, it can serve as an on-screen emulator. For an Android device, the client application will connect to the controller over the network by using the web browser component. Strings, received from the controller every 500 milliseconds, will be processed before displaying the switching status. In switching mode, when the user push a button to change the switching state, the command will be sent to the controller using web browser component via GET method. The application package created is compatible with Android operating system, version 2.3 or higher. 3.2. Personal Computer Application An application for personal computer is implemented using LABVIEW using DataSocket [8] that allows VI to connect to network based on TCP/IP. DataSocket is compatible with many protocols, such as DSTP, OPC, LOOKOUT, HTTP, FTP and local file access. Same as in Android device application, the PC application receives status message from the controller every 500 milliseconds and displays via a green bulb as shown in Fig. 7. When the user clicks on the button to change the switching state, the application uses the DataSocket to send the GET request to the target controller.
W. Amasiri et al./ The 4th International Symposium on Engineering, Energy and Environments(2015)
Fig. 6. PC client application
Fig. 7. Example source code for PC application
4. Implementation and Results An Internet-based remote switching software is successfully implemented with cloudbased and rapid development tools. The test results for both controller part and client part complied fully with original design goals. Under this test scenario, the controller can remotely perform On-Off control for 2 devices as shown in Fig. 8. It can be configured to 2 sets of selection based on SPDT-like control. This system can upgrade to control up to 64 home appliances by using all pins of the Arduino MEGA 2560 or more by using shift registers and the upgraded firmware. In addition, the client software can be upgraded by using block-based programming.
Fig. 8 Diagram of system under test
W. Amasiri et al./ The 4th International Symposium on Engineering, Energy and Environments (2015)
5. Conclusion The system is designed to suit the basic functionalities of an Internet-based switching controller. This enables a low-cost and easy implementation in order to create a remotely controlled electronic switch. The client application has a user-friendly interface via Android mobile phone and personal computer. The control software is designed to achieve the point and click interface. With minimal modification, the system can be used for lighting control, office systems, home automation or any remote control configuration over the Internet.
Acknowledgements The authors would like to thank MIT Center for Mobile Learning, Massachusetts Institute of Technology for developing MIT App Inventor and for kindly making MIT App Inventor II publicly available.
References [ 1 ] R. W-L. Cheung, Y-H. Wang, and Y-F. Fung, "Remote switching in Internet network," Proc. Advances in Power System Control, Operation and Management, vol.2, pp.370 - 375, 2000 [ 2 ] A. Alheraish, "Design and implementation of home automation system," IEEE Trans. Consumer Electronics, vol.50, no.4, pp.1087 - 1092, 2004 [ 3 ] A.Z. Alkar, and U. Buhur, "An Internet based wireless home automation system for multifunctional devices," IEEE Trans. Consumer Electronics, vol.51, no.4, pp.1169 - 1174, 2005 [ 4 ] Z. Min, "Design of multi-channel wireless remote switch control system for smarthome control system," Proc. Consumer Electronics, Communications and Networks, pp.274 - 277, 2013 [ 5 ] M. Butler, "Android: Changing the Mobile Landscape," IEEE Pervasive Computing, vol.10, no.1, pp.4 - 7, 2011 [ 6 ] MIT App Inventor [Online]. Available: http://appinventor.mit.edu/ [Accessed: 25- Jul- 2015]. [ 7 ] Arduino Ethernet Shield [Online]. Available: https://www.arduino.cc/en/Main/ArduinoEthernetShield. [Accessed: 25- Jul- 2015] [ 8 ] L. Podesta, "A Web browser for remote control of measurement systems," Proc. Instrumentation and Measurement Technology, vol.1, pp.647 - 649, 2002