International Journal of Research and Innovation in Applied Science (IJRIAS) |Volume VII, Issue III, March 2022|ISSN 2454-6194 www.rsisinternational.org Page 26 An IoT-Based Home Automation and Weather Monitoring System Alexander A. Willoughby, Ayodele O. Soge, Muiz A. Adeleke, Oluwaseyi A. Ilori Department of Physical Sciences, Faculty of Natural Sciences, Redeemer’s University, PMB 230, Ede, Osun State, Nigeria Abstract: This paper reports an IoT-based home automation and weather monitoring system developed for remote control of household appliances and weather monitoring. The proposed system comprises a Wi-Fi enabled ESP32 microcontroller as the network gateway, a relay module, and a DHT11 sensor for monitoring temperature and humidity. The status of the household devices and the weather data are continuously collected and stored in a MySQL database, which is set up on the IoT platform. A user interface was created using two different protocols - HyperText Transfer Protocol (HTTP) and Message Queuing Telemetry Transport (MQTT). The IoT-based home automation and weather monitoring system is designed to be low cost, user-friendly and can remotely control home appliances and monitor weather data over the internet. Keywords: Internet of Things, home automation, weather monitoring, ESP32 microcontroller, MySQL database I. INTRODUCTION he Internet of Things (IoT) is the network of things, with clear element identification, embedded with software intelligence, sensors, and ubiquitous connectivity to the Internet [1]. IoT allows physical objects to be sensed (to provide specific information) and controlled remotely across the Internet, thereby creating opportunities for more direct integration between the physical world and computer- based systems and resulting in improved efficiency, accuracy, and economic benefits [1]. According to Kodali et al. [2], IoT conceptualizes the idea of remotely connecting and monitoring real world objects (things) through the Internet. The integration of this concept into our home, makes it smarter, safer, and automated. Home automation involves the remote monitoring of home conditions, electric appliances, and executing the required actuation [3]. Home appliances such as television, air-conditioner, refrigerator, and light bulbs are assigned a unique address and are connected through a common home gateway which can be remotely accessed and controlled from any computer, mobile phone, or laptop [3]. It has been predicted that 21st century homes will become more and more self-controlled and automated due to the comfort it provides, especially when employed in a private home [4]. This prediction is supported by the current rapid advancement of wireless technologies such as Wi-Fi and cloud networks [4]. In recent years, several home automation systems for remote monitoring and control of household devices have been reported. Balakrishnan et al. [3] developed a MQTT (Message Queuing Telemetry Transport) based secured home automation system comprising temperature sensors and ESP8266 model as the network gateway. MQTT protocol was implemented for transferring and receiving sensor data which are accessible via ACL (access control list) and monitored on webpage or any network device. Likewise, Vinay Sagar and Kusuma [4] reported an IoT based home automation system using Intel Galileo that employs the integration of cloud networking, wireless communication, to provide the user with remote control of various lights, fans, and appliances within their home and storing the data in the cloud. The system was designed to be low cost and expandable allowing a variety of devices to be controlled. Kodali et al. [2] also reported an IoT based smart security and home automation system which sends alerts to the owner by using Internet in case of any trespass and raises an alarm optionally. It also serves as home automation by making use of the same set of sensors. The smart wireless home security system was constructed using TI-CC3200 Launchpad board which comes with an embedded micro- controller and an onboard Wi-Fi shield enabling the monitoring and control of all electrical appliances in the home. Yar et al. [5] proposed a cost-effective integrated system for smart home based on IoT and Edge-Computing paradigm. The proposed system uses a resource-constrained Raspberry Pi (RPI) device as a central controlling unit, which provides a cost-effective platform for interconnecting a variety of devices and various sensors in a home via the Internet. The home automation system provides remote and automatic control to home appliances, ensuring security and safety. Besides, the proposed solution uses the edge- computing paradigm to store sensitive data in a local cloud to preserve the customer’s privacy. The proposed framework reduced the computational cost, the network bandwidth and storage over the costly cloud solution. The smart home automation system was conclusively proven to be very efficient in terms of energy consumption, response time, data processing, and bandwidth use. Similarly, Maragatham et al. [6] proposed an IoT based home automation system using Raspberry Pi 4 embedded microcontroller with WLAN module (Wireless Local Area Network) to remotely control home appliances. Raspberry Pi 4 microcontroller acts as a monitoring module for the temperature sensor, and passive infra-red (PIR) sensor. The electrical appliances in the home were switched on and off using a relay module. Furthermore, a simple solution for home automation based on ESP8266 chips and Raspberry Pi boards was reported by Stolojescu-Crisan et al. [7]. The home automation system called qToggle uses a very basic core API (Application Programming Interface), allowing for a T International Journal of Research and Innovation in Applied Science (IJRIAS) |Volume VII, Issue III, March 2022|ISSN 2454-6194 www.rsisinternational.org Page 27 more flexible network design. qToggle was designed to be a complete smart home prototype, with a lot of functionalities—automation, control, monitoring, and security. A smartphone application was also developed for users to control a series of home appliances and sensors. Hence, the qToggle system is user friendly, flexible, and can be further developed by using different devices and add-ons. The aim of this project was to develop a low-cost, efficient, and flexible home automation system for weather monitoring and remote control of household appliances using IoT. II. SYSTEM DESIGN The IoT-based home automation system was implemented using Wi-Fi enabled ESP32 microcontroller. A two-channel relay module capable of controlling two appliances individually was also used for interfacing the appliances to enable communication between the appliances and the microcontroller. Also, a DHT11 sensor for monitoring temperature and humidity was interfaced with the microcontroller to send weather data to the user remotely. Communication between the hardware components is illustrated in Fig. 1. The home automation system is connected to the internet via Wi-Fi for IoT implementation. The status of the devices and the weather data are continuously collected and stored in a MySQL database, which is set up on the IoT platform. The ESP32 General Purpose Input/Output (GPIO) pins are programmed and assigned to the DHT11 temperature and humidity sensor for reading weather data. GPIO pins were also programmed and allocated to the relay module which controls the household devices. Fig. 1 The home automation system design The proposed system is accessible by the user and subject to the user’s control via the user interface using a smartphone or computer from anywhere in the world. The user interface is created using two different protocols - The protocols are HyperText Transfer Protocol (HTTP) and Message Queuing Telemetry Transport (MQTT) - for enabling communication between the software and hardware. The home automation system is designed to be low cost and based on a reliable and scalable IoT platform that can remotely switch on or off any home appliance and monitor weather data over the internet. III. SOFTWARE DEVELOPMENT The Hyper Text Transfer Protocol (HTTP) and the Message Queuing Telemetry Transport (MQTT) were the two protocols used for communication between hardware and software for the home automation and weather monitoring system. A. HTTP Protocol PHP Application Programming Interfaces (APIs) are stored in a MySQL database and are called using HTTP requests whenever the user attempts to toggle the state of the appliance and monitor weather data from anywhere via the user interface (an HTML page) as shown in Figs. 2 and 3, respectively. On clicking a particular button, an HTTP request is sent to the database which pulls the current state of the device and sends it to the user (Fig. 3). Fig. 2 Software development for weather monitoring using the HTTP protocol [8] Fig. 3 Software development for home automation using the HTTP protocol [8] International Journal of Research and Innovation in Applied Science (IJRIAS) |Volume VII, Issue III, March 2022|ISSN 2454-6194 www.rsisinternational.org Page 28 B. MQTT Protocol An MQTT broker was installed on a Virtual Private Server (VPS) which hosted the IoT platform. The broker coordinates or orchestrates communication between different clients as described in Fig. 4. It receives all the messages from all the clients, filter them, look up which client is subscribed to what topic, and then redistribute the messages to those clients. Topics designated to appliance control and weather data are created and published on the broker, then these topics are subscribed to using NODE-RED. This gives the user access to control appliances and monitor weather data from anywhere through the user interface (Node-Red Dashboard) as illustrated in Fig. 5. Fig. 4 MQTT Pub/Sub Paradigm [8] Fig. 5 MQTT Communication between devices and sensors [8] IV. DEVELOPMENT OF THE IOT-BASED HOME AUTOMATION AND WEATHER MONITORING SYSTEM Several hardware components were coupled together and tested at the different stages of developing the IoT-based home automation system. The hardware components comprised ESP32 microcontroller, 2-channel relay module, DHT11 sensor, and home appliances e.g., light bulb, as displayed in Fig. 6. The room temperature and humidity are sensed using DHT11 sensor connected to ESP32 development board. The ESP32 microcontroller controls the operation of the system, processes the information from the DHT11 sensor and gives instructions to the relay module which serves as the interface between the microcontroller and the home appliances. It was programmed using C++ programming language in Arduino Integrated Development Environment. Additionally, the ESP32 microcontroller was configured as MQTT client, publishing the sensor data to the MQTT broker, and subscribing for the commands to control the home appliances via the relay module. Fig. 6 A home automation system V. RESULTS The weather data comprising temperature and humidity values of 29.2 o C and 85% as displayed on the web interface using the HTTP protocol are shown in Fig. 7. A more detailed report on the weather data as stored in MySQL database is presented in Fig. 8. The user interface created for appliance control using HTTP protocol is displayed in Fig. 9. Five home appliances labelled D1, D2, D3, D4 and D5 can be controlled by the user interface. Fig. 7 Real time weather readings displayed on the web interface using the HTTP protocol Fig. 8 Weather readings being stored in MySQL database International Journal of Research and Innovation in Applied Science (IJRIAS) |Volume VII, Issue III, March 2022|ISSN 2454-6194 www.rsisinternational.org Page 29 Fig. 9 User interface created for appliance control using HTTP protocol The IoT-based home automation and weather monitoring system switches the television and light bulb on and off as depicted in Fig. 10. It also monitors the room temperature and humidity using the node-red dashboard displayed on the laptop in Fig. 10. Fig. 10 The IoT-based home automation and weather monitoring system switches the TV and light bulb on and off while monitoring temperature and humidity via the node-red dashboard VI. CONCLUSION An IoT-based home automation system using Wi-Fi enabled ESP32 microcontroller capable of monitoring weather condition and control home appliances has been reported. This work has proven that a remotely operated home automation system can be built inexpensively to monitor several home appliances. It is also worth mentioning that the MQTT protocol is a better option to use as a basis of hardware-software communication as compared to the HTTP protocol in terms of speed in response. The IoT-based home automation system can be extended in further work to remotely monitor solar panel parameters, such as voltage, current and radiation, making this system scalable and flexible. REFERENCES [1] Rayes, A., & Salam, S. (2019). Internet of Things From Hype to Reality: The Road to Digitization (2nd ed.). Switzerland: Springer, Cham. [2] Kodali, R. K., Jain, V., Bose, S., & Boppana, L. (2016). IoT based smart security and home automation system. international conference on computing, communication and automation (ICCCA) (pp. 1286-1289). IEEE. [3] Balakrishnan, S., Madhurekha, B., Shobana, N., Selshiya, S. S., & Sathyabama, G. (2019). Home Automation System using ESP8266 based MQTT. International Journal of Research in Engineering, Science and Management, 2(2). [4] Vinay Sagar, K. N., & Kusuma, S. M. (2015). Home automation using internet of things. International Research Journal of Engineering and Technology, 2(3), 1965-1970. [5] Yar, H., Imran, A. S., Khan, Z. A., Sajjad, M., & Kastrati, Z. (2021). Towards smart home automation using IoT-enabled edge-computing paradigm. Sensors, 21(14), 4932. [6] Maragatham, T., Balasubramanie, P., & Vivekanandhan, M. (2021). IoT Based Home Automation System using Raspberry Pi 4. IOP Conference Series: Materials Science and Engineering. 1055, p. 012081. IOP Publishing. [7] Stolojescu-Crisan, C., Crisan, C., & Butunoi, B. P. (2021). An IoT-based smart home automation system. Sensors, 21(11), 3784. [8] Sam, D. (2020). The Mighty MQTT! What You Should Know About It. https://news.rakwireless.com/the-mighty-mqtt-what- you-should-know-about-it/, Retrieved 24 September 2020.