Implementation and Analysis of an IoT-Based Home Automation Framework

Abstract

The pervasive advancement in the field of an autonomous system is significantly influenced by the concept of integrating a large number of devices. The use Internet of Things (IoT) has increased day by day for making connected devices over the internet. Besides, mobile sensing devices operated by IoT including smartphones, tablets, digital cameras, sensors, etc. are providing access to a large variety of data and services based on human interaction. In this paper, the implementation and analysis of an IoT-based home automation framework using NodeMCU through the MQTT protocol are described. This helps the users to monitor and control home appliances from remote places by using a mobile application over the internet.

Share and Cite:

Islam, S. , Hasan, M. , Akter, M. and Uddin, M. (2021) Implementation and Analysis of an IoT-Based Home Automation Framework. Journal of Computer and Communications, 9, 143-157. doi: 10.4236/jcc.2021.93011.

1. Introduction

A home automation system gives privileges to the users to control and monitor the home appliances through a remote mechanism like an IoT application. It implements the system as the integration of controllers, sensors, and actuators as a whole by following the radio frequency concept coined in 1999 [1]. The IoT enables the physical device to transmit real-time data in heterogeneous networks by maintaining the recent security protocols via the internet [2]. At the same time, the invention of the microcontroller offers most of the intelligent IoT building techniques of home automation. The IoT can be incorporated with the perception layer, the network layer, and the application layer. For example, wireless sensors, RFID, sensor cameras, GPS, etc. are operated in the perception layer. The network protocol mostly includes Gateways, Bluetooth, ZigBee, Wi-Fi, etc. [3]. Again, the automation system of building, home, city, power line is operated in the application layer.

The main component of the IoT based automation framework is a Wi-Fi-based node microcontroller unit (Node-MCU) [4]. It is a programmable circuit board using the IDE (Integrated Development Board) for coding the instructions and uploading them to a microcontroller. An android application is developed to control and monitor the automated devices using sensor data via smartphone. This home automation uses cloud-based MQTT protocol to the in-built security technique. The commands for the appliances are sent through the cloud by using the MQTT protocol [5]. We used the IoT cloud as an open-source platform. Node-MCU has a programmable circuit in an Arduino or a Raspberry Pi board. We use the IDE (Integrated Development Environment) for writing instruction codes [6]. Mobile apps are used for accessing and controlling home electronic devices.

The most important contribution of this research is to implement a low-cost and user-friendly IoT based home automation framework using open-source firmware Node-MCU through MQTT protocol. The proposed system monitors home environment parameters such as temperature, humidity, light, etc. After monitoring the parameters, it controls the home appliances through the internet at any time from anywhere. The contributions of this research are given below: 1) Implementation of an IoT-based smart home framework that monitors and controls home appliances remotely from anywhere without the need of a mobile provider to support home safety, security, and energy-saving. 2) A rain sensor is also added to detect the raindrops that automatically control the rain shed.

The organization of this paper is structured as follows: Section 2 describes the literature review, Section 3 presents the system design, Section 4 introduces the implementation, Section 5 discusses the results and finally, Section 6 concludes the paper.

2. Literature Review

This section outlines the related works. Suneetha and Sreekanth [7] proposed a smart home system that can control electronic devices based on the environment. Raspberry pi board and Arduino UNO have been used in the system. The system can notify the people about gas leakage and the presence of fire. It also has security system facilities and can also detect object motion, temperature, and humidity. The system is very simple and user-friendly. But it cannot control the brightness of the light or the speed of the fan.

Syet al. [8] proposed a wireless home automation and security system that is designed for the homeowners to feel secured and comfortable. They used an RFID tag card for the security purpose of the home users. They used Arduino, an infrared (IR) receiver, RFID card reader, to read the RFID tag. They used IR based wireless communication to control home appliances. They designed this low-cost home automation with a security system. The limitation of this system is the working range (approximately 10 meters).

Thakur and Han [9] proposed a ubiquitous framework that aims to leverage the immense potential of activity centered computing in an IoT environment. Elderly people face different problems like motor disabilities, physical limitations. To ensure smooth functioning, the proposed framework should address the aforementioned challenges.

In recent years, the home automation system is important to the research community as it helps us in leading a good quality of lifestyle. Sivapriyanet al. [10] reviewed different types of communication methodologies such as GSM, IoT, Wi-Fi, and Bluetooth for the development of home automation.

Martirano [11] described a bimodal low cost as well as energy-efficient lighting control architecture using an android-based smartphone. This technique works using a Wi-Fi module for communicating among remote users and household appliances. Here ESP8266 plays the role of a server and Arduino UNO plays the role of an interpreter of instructions. Chakrabarti and Engels [12] developed an android smartphone-based nice automation method that is low cost as well as secured. The proposed method utilizes RESTful based web services with an interoperable application layer for communication of remote users with the home appliances.

In paper [13], the author presented a smart home based on a smartphone with a touch to speech feedback. This approach solves the problems of accessibility and comfort inside the home. This is especially useful for visually disabled people. They designed the technological part by developing a web server. This web server uses an Arduino UNO board with a Wi-Fi module. The smartphone is connected to the webserver through a router. The router receives the information about the home location and sends a signal to power up the electronic devices. Experimentation was performed with the subjects of visual disabilities and motor disabilities.

In [14], the authors described the design of a home automation system using dual-tone multiple frequencies (DTMF) based home automation system. The purpose of this DTMF based home automation is to develop an embedded system. This system can control remote home appliances remotely by using telephone lines.

Paper [15] described a low cost and flexible home control and monitoring system. This system is based on a Raspberry PI module and a static relay for accessing and controlling the appliances remotely by using a smartphone-based android application. The proposed system does not require a dedicated server PC concerning similar systems. The system offers a novel communication protocol to monitor and control the home environment with more than just the switching functionality. Paper [16] gives the concept of a new circuit topology for monitoring and controlling the electrical devices which use the android system implemented by a wireless transceiver. In [17], the author presented a cloud-based home automation system using the MQTT protocol. It gives the users the facility of controlling and monitoring home appliances through a mobile app or a web page.

In the present paper, we describe a home automation framework that provides indoor and outdoor control, safety, security, monitoring from distant places through the Wi-Fi interface and a NodeMCU. The system is implemented in real-time with smartphones and web-based technologies.

3. System Design

The prototype of the proposed smart home is designed and shown in Figure 1. The smart home has two rooms, one kitchen, one bathroom, one veranda. There is a ventilator in the kitchen. Figure 2 depicts the framework of the proposed architecture including different components.

For the design and implementation of an IoT based home automation system, it uses an opensource firmware Node-MCU through MQTT protocol along with diverse sensors, such as temperature and humidity sensor DHT11, PIR motion sensor HC-SR 505, gas sensor MQ2, rain sensor YL-83 for measuring the temperature, humidity, smoke, gas leakage, and rain. Several actuators control the activities of electronic devices of the home. The lights and fans are controlled by the dashboard. A graphical user interface (GUI) helps to interact with users and the system and ensures the comfort and safety of the users.

The main entrance of the home has a door with a motor and motion sensor. This PIR motion sensor attached to the door detects the motion. This will let the door open and close automatically. The working flow of this prototype is depicted in Figure 3.

Figure 1. The arrangement of the smart home prototype.

Figure 2. Schematic diagram of the proposed architecture.

Figure 3. Total system flow diagram.

Our smart home automation system uses web services as an interoperable application layer. The system has a micro web server that is based on Arduino ethernet and hardware interface module. The proposed system allows authorized users to control and monitor connected appliances. A graphical user interface (GUI) for accessing and controlling the devices is provided by the webserver.

In Figure 3, first of all, the ESP8266 is connected to the power switch. After that, it is connected to Wi-Fi and it gathers the data from different sensors. Then it sends the data to the MQTT dashboard. If the gas is detected from the gas sensor, the exhaust fan of the kitchen is ON. Otherwise, the exhaust fan is OFF. If the temperature value is greater than the threshold value, the room fan or AC is ON. Otherwise, the fan or AC is OFF. If it is raining, then the rain detector detects it and the window is shut down. Otherwise, it is open.

4. Implementation

4.1. Components

The home automation system in our experiment includes ESP8266 or Node-MCU board v2, temperature sensor, gas sensor, motion sensor, humidity sensor, LED, potentiometer, motor drivers whose physical views are shown in Figure 4.

a) Node-MCU Node-MCU 1.0 (ESP-12E Module) is an IoT development board consisting of ESP8266, SoC integrating a 32-bit microcontroller [18] that uses Wireless 802.11 b/g/n standards and supports three operating modes STA/AP/STA+AP. In the study, we used the microcontroller (NodeMCU/ESP8255) as the central unit of the prototype. We connected all the devices to the microcontroller board through jumper cable. The actuators such as light, fan and potentiometer through the 4 channel relay board. The power supply may be from the battery or other power source.

b) 4-Channel 5V DC relay module. It is well known for controlling a high powered circuit by a low power signal. Usually, a DC signal is used for controlling the circuit which is driven by high voltage such as controlling AC home appliances through DC signals from microcontrollers [19]. The relay board is used for controlling high voltage AC, fan washing machine. We used a 4-channel relay module. We connected to light, Fan/AC through the relay module.

c) DHT11 temperature sensor. DHT11 sensors are generally used for sensing the temperature and humidity of an area. It works for triggering related devices with a relay module [20]. DHT11 is one of the most popular and low-cost temperature sensors. DHT22 is another one. But its cost is high and it’s not available. We measured the temperature and humidity through this sensor. It is connected to the microcontroller board.

d) PIR motion sensor (HC-SR 505). A passive infrared (PIR) sensor is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view [21]. PIR sensors are commonly used in security alarms and automatic lighting applications. In this study, we used the imaging motion sensor. It detects

Figure 4. Components used in this experiment. (a) DHT11; (b) Node-MCU; (c) MQ2; (d) 4-channel relay module; (e) Rain sensor; (f) MD-10 POT; (g) Potentiometer; (h) PIR motion sensor.

the presence of a person at the door. We can monitor the presence of any intruder through the motion detector from a remote place.

e) MQ2 gas sensor. MQ2 gas sensor is an electronic sensor used for sensing the concentration of gases in the air such as LPG, propane, methane, hydrogen, alcohol, smoke, and carbon monoxide. MQ2 gas sensor is also known as chemical-resistor [22]. It contains a sensing material whose resistance changes when it comes in contact with the gas. It can detect gases in the concentration of range 200 to 10,000 ppm. There are different types of gas sensors such as MQ4, MQ5, MQ7 etc. Especially, we used the gas sensor MQ2 in the kitchen of the smart home.

f) Other components. A light-emitting diode (LED) is a semiconductor light source that emits light when current flows through it. Electrons in the semiconductor recombine with electron holes, releasing energy in the form of photons. The colour of the light (corresponding to the energy of the photons) is determined by the energy required for electrons to cross the bandgap of the semiconductor. Appearing as practical electronic components in 1962, the earliest LEDs emitted low-intensity infrared (IR) light [23]. We used the LED for visualizing the status of a device. Suppose Motion is detected in the door, then the LED is ON. This is used as an indicator for showing the status of the devices or sensors.

YL 83 is a rain sensor. It has two parts: the electronic board and the collector board. It works on the principle of droplet detection. If the raindrops fall on the collector board, it sends the signal to the electronic board. We set the collector board at the veranda without a roof so that it can collect the droplet of the rain. FC 37 is another rain detector sensor. But we choose YL 89 because we can get the value in two minutes.

Cytron 10A Switch Control Potentiometer DC Motor Driver (MD10POT) is made for DC brushed motors which are widely used in many applications due to the ease of use. We can control the speed and direction of the DC motor through this driver MD10-POT is a motor driver or speed controller that enables us to control the start/stop, direction, and speed of the motor without any hassle [24]. We used the potentiometer for controlling the speed and direction of the sliding window or sliding door. A motor driver is used with a cable that performs the work for opening or closing the door.

4.2. Algorithms

The algorithm of the prototype describes the whole procedure step by step that is shown in Algorithm 1. Node-MCU gets connected to the server along with the other devices. The LED is on/off by the push button on the app through a virtual switch on the dashboard. We can control the home appliances from anywhere using internet connectivity. The room temperature and humidity are displayed on the dashboard. We can use a fan or air conditioner in U3 by adding relays. We can turn on AC if the temperature above 25˚C. Similarly, we can turn off the AC if the temperature below 18˚C. The gas sensor can detect the presence of gas and smoke and the motion sensor can detect the presence of an intruder.

Define the Wi-Fi password and user name

The prototype of the dashboard is implemented using Arduino IDE (Sketch). Ubidot IoT server monitors the condition of home environmental parameters and controls the home electronic devices through the MQTT protocol. A graphical user interface (GUI) is for controlling the devices with fingertips on a mobile screen. First of all, we implemented all the sensors and actuators in the breadboard. The enhancement program is conducted in the virtual breadboard shown in Figure 5. Then we implemented it in a real breadboard shown in Figure 6.

Figure 5. Virtual breadboard presentation of the smart home.

Figure 6. Breadboard assembly of smart home prototype.

4.3. Development of Android APP

To develop an android application, we need to set up an Android IDE with some custom settings to access the PAHO library which is an MQTT client library. This library is written in Java. This is used especially for developing applications on Android [25]. The Paho has been created to provide a reliable open-source platform. It implemented an open and standard messaging protocol. The intension was to give a new and emerging application for Machine-to-Machine (M2M) and the Internet of Things (IoT) [26]. Paho gives the following facilities:

1) Reduces the physical and cost constraints of device connectivity.

2) It provides effective levels of decoupling between devices and applications.

3) It designs scalable web and enterprise middleware and applications.

4) Eclipse hosts a Nexus repository for those who want to use it.

5) It manages application dependencies and sets up a build environment so that we can use the same repository to get the Paho Android Service.

Adding the repository definition and the dependency code is shown in Appendix A. To complete the setup, we have to add few permissions to the android manifest such as—internet, network state, and phone state.

5. Result and Analysis

The process of this smart monitoring approach is shown in Figure 7. Here first activity allows the user to scan a QR code to get the server information since each user has a unique dashboard on the server. The second activity asks the user to connect to the MQTT broker and the third activity shows all the data provided by the broker. We can control the appliances from the MQTT dashboard. Figure 7 shows that the light is on, motion detection gives NORMAL status and the rain detector gives DETECTED indicating that no one is waiting in front of the door and it is raining.

The process of this smart monitoring approach is shown in Figure 7. Here first activity allows the user to scan a QR code to get the server information since each user has a unique dashboard on the server. The second activity asks the user to connect to the MQTT broker and the third activity shows all the data provided by the broker. We can control the appliances from the MQTT dashboard. Figure 7 shows that the light is on, motion detection gives NORMAL status and the rain detector gives DETECTED indicating that no one is waiting in front of the door and it is raining.

The price of the sensors and actuators used in the implementation of the smart home does not differ very much for changing their brand. But the price of the microcontroller board (Node-MCU or ESP8266) is different. Due to this reason, the cost of the smart home implementation mainly depends on the price of the microcontroller board. The comparative study is given in Table 1.

We compared the performance and cost of four microcontroller boards (ESP8266). The chart in Figure 8 shows the parameters. We find that the ESP8266 is the best performer. The Galileo board is too costly. Arduino Uno uses more current and voltage and also needs extra board for the extension. We

Figure 7. MQTT dashboard for home automation.

Table 1. Comparative study on the microcontroller board.

Figure 8. Comparison of microcontroller boards.

compared the operating system, clock speed, SRAM, Digital I/O, DC current and cost parameters. In X axis, we represent the properties of the microcontroller boards and in the Y axis, we represent the units of measurement.

6. Conclusion and Future Work

Home automation based on IoT is one of the promising and essential issues in recent times. It provides a comfortable living. In this paper, we implemented an IoT-based low cost and flexible home automation system framework through a mobile android app. We used ESP8266 as a microcontroller board with the Wi-Fi module. However, in future work, we will develop a smart building and as well as a smart city. The big challenge is to manage all in real-time data in a well-organized pattern.

Appendix A: Adding the Repository Definition and the Dependency

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.

References

[1] Anzi, M.O., Vellasami, L, Zianal, A.H. and Mohammed, F.A. (2016) Home Automation System with Android Application. 2016 3rd International Conference on Electronic Design (ICED), Phuket, 11-12 August 2016, 299-303.
[2] Piyare, R. (2013) Internet of Things: Ubiquitous Home Control and Monitoring System Using an Android Based Smartphone. International Journal of Internet of Things, 2, 5-11.
[3] Coral, W., Alarcon, A., Llanos, J. and Hernandez, J. (2019) Home Automation System for People with Visual and Motor Disabilities in Colombia. 16th International Conference on Informatics in Control, Automation and Robotics, Vol. 1, Prague, 29-31 July 2019, 333-340.
https://doi.org/10.5220/0007929303330340
[4] Ashton, K. (2009) That ‘Internet of Things’ Thing. RFiD Journal, 22, 97-114.
[5] Jaradat, M., Jarrah, M., Bousselham, A., Jararweh, Y. and Al-Ayyoub, M. (2015) The Internet of Energy: Smart Sensor Networks and Big Data Management for Smart Grid. Procedia Computer Science, 56, 592-597.
https://doi.org/10.1016/j.procs.2015.07.250
[6] Ye, X. and Huang, J. (2011) A Framework for Cloud-Based Smart Home. Proceedings of 2011 International Conference on Computer Science and Network Technology, Harbin, 24-26 December 2011, 894-897.
[7] Sunetha, K. and Sreekanth, M. (2020) Smart Home Monitoring and Automation Energy Efficient System Using IoT Devices. In: Venkata Krishna, P. and Obaidat, M.S., Eds., Emerging Research in Data Engineering Systems and Computer Communications, Springer, Singapore, 627-637.
https://doi.org/10.1007/978-981-15-0135-7_57
[8] Sy, J.B., Akele, S.M. and Panganiban, E.B. (2020) Wireless Home Automation with Security System (WHASS). International Journal of Electrical Engineering and Technology, 11, 101-110.
[9] Thakur, N. and Han, C.Y. (2020) An Intelligent Ubiquitous Activity Aware Framework for Smart Home. 2020 International Conference on Human Interaction and Emerging Technologies, Paris, 27-29 August 2020, 296-302.
https://doi.org/10.1007/978-3-030-55307-4_45
[10] Sivapriyan, R., Rao, K.M. and Harijyothi, M. (2020) Literature Review of IoT Based Home Automation System. 2020 4th International Conference on Inventive Systems and Control, Coimbatore, 8-10 January 2020, 101-105.
https://doi.org/10.1109/ICISC47916.2020.9171149
[11] Martirano, L. (2011) A Smart Lighting Control to Save Energy. Proceedings of the 6th IEEE International Conference on Intelligent Data Acquisition and Advanced Computing Systems, Prague, 15-17 September 2011, 132-138.
https://doi.org/10.1109/IDAACS.2011.6072726
[12] Chakrabarty, S. and Engels, D.W. (2016) A Secure IoT Architecture for Smart Cities. 2016 13th IEEE Annual Consumer Communications & Networking Conference, Las Vegas, 9-12 January 2016, 812-813.
https://doi.org/10.1109/CCNC.2016.7444889
[13] Raza, S., Misra, P., He, Z. and Voigt, T. (2017) Building the Internet of Things with Bluetooth Smart. Ad Hoc Networks, 57, 19-31.
https://doi.org/10.1016/j.adhoc.2016.08.012
[14] Bouanani, S.E., Achbarou, O., Kiram, M.A. and Outchakoucht, A. (2019) Towards Understanding Internet of Things Security and Its Empirical Vulnerabilities: A Survey. International Journal of Advanced Computer Science and Applications, 10, 337-345.
https://doi.org/10.14569/IJACSA.2019.0101048
[15] Punjabi, H.C., Agarwal, S., Khithani, V., Muddaliar, V. and Vasmatkar, M. (2017) Smart Farming Using IoT. International Journal of Electronics and Communication Engineering and Technology, 8, 58-66.
[16] Palkar, S., Lan, C., Han, S., Jang, K., Panda, A., Ratnasamy, S., Rizzo, L. and Shenker, S. (2015) E2: A Framework for NFV Applications. Proceedings of the 25th Symposium on Operating Systems Principles, Monterey, October 2015, 121-136.
https://doi.org/10.1145/2815400.2815423
[17] Benevolo, C., Dameri, R.P. and D’Auria, B. (2016) Smart Mobility in Smart City. In: Torre, T., Braccini, A. and Spinelli, R., Eds., Empowering Organizations, Vol. 11, Springer, Cham, 13-28.
https://doi.org/10.1007/978-3-319-23784-8_2
[18] El Kamchouchi, H. and El Shafee, A. (2012) Design and Prototype Implementation of SMS Based Home Automation System. 2012 IEEE International Conference on Electronics Design, Systems and Applications, Kuala Lumpur, 5-6 November 2012, 162-167.
https://doi.org/10.1109/ICEDSA.2012.6507788
[19] TTI, Inc. Relay Module.
https://openlabpro.com/guide/relays-and-actuators/
[20] Chaurasia, T. and Jain, P.K. (2019) Enhanced Smart Home Automation System based on Internet of Things. 2019 3rd International Conference on I-SMAC (IoT in Social, Mobile, Analytics and Cloud), Palladam, 12-14 December 2019, 709-713.
https://doi.org/10.1109/I-SMAC47947.2019.9032685
[21] Panasonic. PIR Motion Sensor.
http://na.industrial.panasonic.com/products/sensors/sensors-automotive-industrial-applications/lineup/pir-motion-sensor-papirs
[22] ElProCus (2021) Gas Sensor MQ2.
https://www.elprocus.com/an-introduction-to-mq2-gas-sensors
[23] LED Baseline, Inc. (2021) LED Accessories.
https://www.ledbaseline.com/product-category/led-accessories
[24] Cytron. Switch Control Potentiometer.
https://www.cytron.io/p-10-amp-7v-30v-potentiometer-and-switch-control-dc-motor-driver
[25] Pan American Health Organization (2021) About the PAHO Library.
https://www.paho.org/English/DD/IKM/LI/library.htm
[26] Aadi (2019) M2M Protocols.
https://www.iotgabfest.com/m2m-protocols
[27] Jabbar, W.A., Kian, T., Ramli, R.M, Zubir, S.N., Zamrizaman, N.S.M., Balfaqih, M., et al. (2019) Design and Fabrication of Smart Home with the Internet of Things Enabled Automation System. IEEE Access, 7, 144059-144074.
https://doi.org/10.1109/ACCESS.2019.2942846

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.