Al-Najah National University Faculty of Engineering and Information Technology Computer Engineering Department Smart Home Home Automation System & Control Shahd Nassar and Manar Shaar Supervisor: Dr. Sufyan Samara Aug 16, 2021 1 Abstract Home is where we should feel secure and comfortable. Nowadays, with technology becoming a part of almost everything in our life, we can achieve a higher level of com- fort and make our life easier and more efficient by automating activities performed frequently in our homes, applying the IoT concept and providing homeowners remote management and control over their houses. The goal of the Smart Home is to smooth the process of managing the house, monitoring its devices, and applying the principle of protection and security using smart technologies. This project is a sample model of modern houses, which will be controlled by an application downloaded on your smartphone to provide smart control, energy saving and security for your house. We will provide remote controlling of lights, a door lock control using keypad, voice or face recognition, fire alarm system, heat monitoring and a smart water level tank detection. 2 Contents 1 Introduction 4 1.1 Problem Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.2 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 Work Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.5 Report Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Literature Review 5 3 Methodology 6 3.1 Hardware Tools and Equipment . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.1 Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.2 Lighting System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.3 Temperature & Humidity Monitoring . . . . . . . . . . . . . . . . . . 7 3.1.4 Security System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.5 Fire & Gas System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.6 Water System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.7 Air Conditioning System . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.8 Solar Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2.1 Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2.2 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4 Conclusion and Future Work 12 5 Appendix 14 5.0.1 Appendix A - Schematics and Flow Charts . . . . . . . . . . . . . . . 14 5.0.2 Appendix B - Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.0.3 Appendix C - Sources . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3 1 Introduction 1.1 Problem Description Smart home systems is considered a new area of interest that have not been fully utilized into our society. This refers to the need of an integration of many other disciplines of research and engineering specializations to make operational and effective smart home. One additional obstacle to the emergence of smart home systems in the market is the cost of installing such systems. In this project, we had the opportunity to work on building an energy efficient and cost effective smart home system that provides remote monitoring and controlling for devices from anywhere using a mobile with an internet connection. Our work includes design schematics, wireless communication, utilization of micro con- trollers and printed circuit boards, in addition to full integration with a programmed piece of software. The primary goal for utilization of automation techniques and smart tech- nologies is based around convenience, comfort and intuitive customization for the family members. Our project aim to integrate the smart phone to interface the whole design of the smart home system for easier usability and more familiarity. 1.2 Motivation There are several reasons behind the motivation of building and developing smart home systems. Nevertheless, the most significant reasons are luxury, convenience, energy manage- ment, security and connectivity. Even though smart home technology might be introduced as an expensive new technology, it has been growing exponentially and it is becoming bet- ter and cheaper in a short period of time. This fact will help to make this technology an expense worth having when someone intends to build a new house. The most prominent motivation behind utilizing smart home systems is the convenience. This particular feature of technologies in general is desirable in the house as it allow the family members to save a lot of time doing every-day tasks. For instance, a member will not need to walk around turning off lights, they can do so by just pressing a button on their smart phone and make sure all the lights are off when leaving. Energy management and security are also considered as huge factors in the emergence of smart home systems. Such systems can assist the house owner on efficient use of energy and save him money by controlling the amount of energy being used. By a way of illustration, the smart home system can give the house member the ability to control electricity-heavy- usage appliances from his phone, such as Air conditioners and water heaters, so that he can set them to turn off and monitor their consumption to be more conscious of the energy. In terms of security, house security becomes a powerful tool that allows the family members to always know that status of the security of their house. One additional reason behind the motivation to apply smart home systems into your house is the idea of connectivity. By connecting every appliance in your house, data extraction possibilities with research analysis is much easier to apply, which will allow you to increase your control over your assets and know how much power a specific appliance is consuming. 1.3 Objectives In this work, we introduce a design for a smart home, which is a project that provides an automation system that would support many functionalities, such as opening the door through face recognition, password or sound, which in turn provides protection and safety for the home owner more than using the traditional lock, in addition to the ease of use. A 4 lighting control system, which aims to reduce electricity consumption and makes it easier for the homeowner to control the lights in a wide range of lighting. A fire detection system that warns the user about fire in the home, and helps him to extinguish the fire early. Air conditioning system according to the house temperature, solar system, temperature and humidity detection and finally a sensor for level of water detection. We introduce a mobile application that offers a unique, user-friendly experience for the house owners. The application allows users to control and edit devices in a simple way. 1.4 Work Steps For this project we firstly needed to study the home system and discover the problems that the homeowner suffers from, then we followed a series of organized steps that helped us complete the project within the specified time. We started looking for electronic parts necessary to build the system, this task required time. After assembling the necessary parts, we had to learn to deal with raspberry pi and ESP32, learning ESP32 programming and Raspberry Pi with python language and usage of Sensors and measurements, then we designed a small house model suitable for the size and arrangement of the electronic parts. Finally, we have built a flutter mobile application that provides a smooth, user-friendly interface to control the system remotely and monitor the devices. It deals with the firebase as a communication medium to communicate with the system. 1.5 Report Organization This report is arranged as follows. Section II clarifies some similar projects and work related to our idea. Section III represents the process we took in our work and the features we supplied. Finally,in Section V, a conclusion of the project and some additional work that can be done in the future. 2 Literature Review As previously mentioned, the technology develops and people tend to use IoT in different fields like health and transportation. It helps controlling and monitoring of user devices. Smart home system demonstrates the IoT concept finely. A home is considered as smart if it is remotely monitored and controlled, secure and where home devices are smart enough to change their status. Smart home system is mainly concerned with the Automation, Security and energy consumption of electricity. We have found similar projects presented to our colleagues in the department of computer engineering. But in this project, we provided features that were accomplished in addition to facial recognition and level of water and monitor lights in different ranges were combined into one project to make it easier and more comprehensive for the users to manage their houses. The smart home system has been experienced and proven to be capable of per- forming intelligent home processes such as switching functions and automatic environmental control. 5 3 Methodology 3.1 Hardware Tools and Equipment 3.1.1 Processors In this project, we used two system controllers to benefit the most and gain most possible experience, the Raspberry Pi 3 and ESP32 controller. Raspberry Pi is a low-cost and lightweight programmable device that acts as the master brain to run the security system of our model, which represents the door control which will be discussed in the security subsection. Figure 1: Raspberry Pi 3 model. The ESP32 is also a low-cost device. It is a low-power system on a chip micro-controller with incorporated Wi-Fi. We used this processor to control the rest of the system including sensors, motors and leds. Figure 2: ESP-WROOM-32 module. 6 3.1.2 Lighting System The lighting system in our house model consists of four leds and controlled through a mobile application to turn them either on or off. A light-sensitivity control feature is added in the application for the lights to turn on in different degrees, providing another level of control and flexibility in the system to adapt users needs. Figure 3: Lighting System. 3.1.3 Temperature & Humidity Monitoring For this feature, a DHT11 Temperature Sensor is used to monitor and detect temperature and humidity in real time, OLED 5V is used to display the temperature and humidity values, it offers a better image quality compared to LCD displays. The ESP32 keeps updating these values in the database and the mobile application read the stored values in the database and display them for the user in the app. Figure 4: Monitoring temperature and humidity. 7 3.1.4 Security System The security system of our model is presented by the ways for accessing the front door and it’s handled and controlled by the Raspberry Pi. We provided three ways for this procedure, the first one would be by entering a password using a keypad which is a block of buttons for digits, the other way is by saying a secret word to the mini USB microphone. Lastly, the face recognition technique which is by capturing an image, encode it and compare it with the stored encoded images. For these techniques to adapt to dynamic changes, we gave the user the ability to change the digital password or word through the mobile the application. For the image processing, we provided a hardware way to capture a new picture and add it to the images folder in the raspberry bi to be encoded at the start run of the raspberry bi, and be compared with when the user chooses the camera way for permission access. The passwords for the first two ways are stored in the database and compared each access trial to the house. Figure 5: Security System. 3.1.5 Fire & Gas System A flame sensor module is used to detect the fire in our house model, we should see the red led illuminate, it offers fast service and low prices. To accomplish gas detecting, we have made interfacing of MQ-135 gas sensor with ESP32, the strengths of this sensor that it has wide detecting range, rapid response and high level of sensitivity. Monitoring of these features is very important taking into account safety, gas and fire sensors are very helpful in achieving this task and keep our systems updated all the time. 8 Figure 6: Fire & Gas System. 3.1.6 Water System The user can always monitor the water level in the tank through the mobile application, which periodically reads any value updates in which are stored in a real-time database. We used a water level sensor to imitate the water tank system of the module, it consists of a series of parallel conductors acting as a potentiometer which resistance changes based on the distance between the surface of the water and the top of the level sensor. According to this resistance, an output voltage is generated, so we establish the water level by measuring this voltage. Figure 7: Water System. 9 Figure 8: Level Sensor. 3.1.7 Air Conditioning System For the air conditioning system, we used a small fan with a DC motor which is a rotary electrical device that converts electrical into mechanical energy. The DC motor is connected with the ESP32 through a high voltage, high current dual full-bridge driver which is the L298, it accepts standard TTL logic levels and drives the DC motor. The user can turn on the fan with several speeds and turn it off easily using the application. Figure 9: L298 Driver with DC motor. Figure 10: Air Conditioning System. 10 3.1.8 Solar Panel For our proposed smart home model to have clean energy and be as efficient as possible, we provided a solar panel on the roof. It converts the energy of light into electrical energy, we added this to help with generating electricity to the L298 full-bridge driver. Figure 11: Solar Panel System. 3.2 Software 3.2.1 Database For storing and syncing our data in real time, we used the Firebase Realtime Database to be the main part of the communication between our controllers and the user’s application. The mobile application and the processors store and read values from the database over Wi-Fi and act based on them in real time. 3.2.2 Application We have supported our project with a flutter mobile application that provides a smooth, simple and user-friendly interface to easily monitor and control the different devices of the house model. 11 Figure 12: Application startup page. 4 Conclusion and Future Work The fact that even though smart home systems are considered as new technology, and the majority of homes were built in the near past, installing smart home technologies have been growing exponentially in a way that brought great attention from researchers of different backgrounds. The technology is improving and becoming cheaper and advanced. The greatest motivation behind implementing smart home technologies is convenience followed by security and energy management. The smart home system that we built in our project consists of many different components and parts. All of these components, such as fire system, lighting system, fans, door security, in addition to the renewable energy system made a very challenging and detailed project. We have learned a lot of information in our design project and its integration with the smart phone. We are very excited to see how much developed these smart home technologies can be. There are several possible future implementations for our project by adding even more features for the family members of the house, or improving the efficiency and other ways to interface with the smart home system to its several components. One additional possible future implementation would be to add the ability to record the information coming in from 12 the microphone of the smart phones for the purpose of connecting it with a virtual helper such as Google Assistance or Alexa. 13 5 Appendix 5.0.1 Appendix A - Schematics and Flow Charts Figure 13: Raspberry pi schematic 14 Figure 14: Raspberry pi flow chart 15 Figure 15: ESP32 schematic 16 Figure 16: ESP32 flow chart 17 5.0.2 Appendix B - Codes Figure 17: ESP32 code - 1 18 Figure 18: ESP32 code - 2 19 Figure 19: ESP32 code - 3 20