An - Najah National University Faculty of Engineering Computer Engineering Department Graduation Project 2 Smart Home Accomplished by: Rami Ghuzzi Oday Yamen Supervisor: Dr. Abdul - Allah Rashed Presented in partial fulfillment of the requirement for Bachelor degree in Computer Engineering Dec 15, 20 20 2 | P a g e Contents Acknowledgment ................................ ................................ ................................ ................................ ............. 4 Disclaimer ................................ ................................ ................................ ................................ ................. 5 Abstract ................................ ................................ ................................ ................................ .................... 6 Chapter 1: Introduction ................................ ................................ ................................ ................................ 7 1.1 Overview ................................ ................................ ................................ ................................ ......................... 7 1.2 Description ................................ ................................ ................................ ................................ ..................... 7 1.3 Report Organization ................................ ................................ ................................ ................................ .... 7 Chapter 2: Problems and Constraints ................................ ................................ ................................ .......... 8 2.1 Constraints ................................ ................................ ................................ ................................ ................. 8 2.2 Earlier Coursework ................................ ................................ ................................ ................................ 9 Chapter 3: Methodology ................................ ................................ ................................ .............................. 10 3.1 Backgr ound and Tools ................................ ................................ ................................ ..................... 10 3.1.1 Description ................................ ................................ ................................ ................................ ........ 10 3.1.2 Hardware Tools and Construction ................................ ................................ ................................ .... 11 3.2 Technologies ................................ ................................ ................................ ................................ ................. 15 3.3 Scenarios ................................ ................................ ................................ ................................ ....................... 16 3.4 Results and Discussion ................................ ................................ ................................ ................................ .. 19 Chapter 4: Conclusion and Future Work ................................ ................................ ........................... 19 4.1 Conclusion ................................ ................................ ................................ ................................ ................ 19 4.2 Future Work ................................ ................................ ................................ ................................ ........... 20 3 | P a g e Figures Figure 1: Front side view of the house....................................................................................12 Figure 2: Back side view of the house.....................................................................................13 Figure 3: Roof view from the top of the house............................................................................13 Figure 4: Kitchen and bedroom 1 view from inside.....................................................................13 Figure 5: Garage view and the brain of the project................................................ ......................14 Figure 6: Front door view from inside with bedroom 2 and bathroom................................................14 Figure 7: Sensors initializing and working flow chart..................................................................17 Figure 8: Application flow chart...........................................................................................17 Figure 9: S cenarios One and Two the house alert System flow chart................................................18 4 | P a g e Acknowledgment We would like to thank our supervisor Dr. Abdul - Allah Rashed for his time, patience, and cooperation in providing any help that he could afford in this project, An - Najah National University and its crew to provide all needed resources that the project requ ired, professors and our teachers who are in the judgment comity for their valuable opinions, discussions, solutions and positive comments on our project F inally, we would thank ou r families and everyone that helped us in our journey doing t his project. 5 | P a g e Disclaimer This report was written by Rami Ghuzzi and Oday Yamen at the Computer Engineering Department, Faculty of Engineering, An - Najah National University. It has not been altered or corrected, other than editorial corrections, as a result of assessment and it may contain language as well as content errors. The views expressed in it together with any outcomes and recommendations are solely those of the students R ami and Oday An - Najah National University accepts no responsibility or liability for the consequences of this report being used for a purpose other than the purpose for which it was commissioned. 6 | P a g e Abstract Our life in the 21st century is complicated enough, more than any time passed, because of technology evolution and the huge amount of information that should be known by each one of us. All that complexity aim is to make life more easy and able to be handled, to keep up with that evolut ion and to contain that amount of information at the same time, and this is where the engineers come in, to fill the gap between the complexity of technology and people simple needs. This project is a sample of modern and future houses, which you will be able to control by an application downloaded on your smartphone. This project focus on the security and control of the smart home. The control of the house will be through an application, it is connected to the alert system which will give notification if there is any, also, it provides controlling the lights all over the house and opening/closing garage door and windows. This project has programmed on both Raspberry pi 3b and Arduino mega 2560, It used different kinds of sensors as we will see in this report. 7 | P a g e Chapter 1: Introduction 1.1 Overview Home is where you feel safe and comfort, far away from outer distribution and noise, your own place in this big world, your comfort zone and freedom from the restrictions of traditions and people out side and in our century with the technology evolution we can develop and make our life much easier through technology smart. 1.2 Description In this project we mainly focus on security of the house as we did a full security alert system that it will be tr iggered by any motion happened in the house in the absence of the owner of the house, also, the fully control in doors , windows and the lights of the house using an application which also provide the owner of the house with the status of the ho use by notif y him if the system catch any trigger or problem in the house. We got out of this project with many personal benefits and skills especially in the hardware field and we applied many of the concepts we took in our engineering journey which we will talk abou t later in this report, we faced many problems especially in this circumstances with the pandemic and hard opportunities for meeting and working together as a result of this pandemic but at the end we did our best and exploited each opportunity to meet and to work to come up with a complete project and that what we got. 1.3 Report Organization The next chapter will discuss the constraints and the difficulties we faced in developing our project and earlier coursework as well. In Chapter 3 (Methodology), we will explain the overall process of development, and what hardware tools and algorithms we used in building the project , the results and the outcome of this project Last chapter (Conclusion and Future work ) will discuss final Conclusio n of this project, the recommendations and some future work. 8 | P a g e Chapter 2: Problems and Constraints T his chapter documents the main constraints we faced during this project. Moreover, we will discuss different coursework and topics that have been useful while doing this project. 2.1 Constraints Hardware Issues - P IR Sensors: This kind of sensors very sensitive to motion and this sensitivity is controlled manually so we were very carefully and try to do our best to manage symmetric and reasonable sensitivity for all PIR’s in our project. Software Issues - Starting with using new operation system (Raspbian OS) as we did download (Ubuntu 18), and we got many problems with this version of system and it was not compatible with the raspberry we are using, so after a while of work, we had to update and work on (U buntu mate 20) which was much better but at the configuration part we faced problems using Linux generally so we transfer to Raspbian OS based on Debian which we found out lately that it’s a primary operation system for the Raspberry Pi family as we could configure the Raspberry we had through GUI instead of libraries and instruction orders for the Ubuntu. - Downloading and activating programs such as NodeJS server, I2C, and VNC server. JavaScript libraries that control Raspberry, phpMyAdmin for database o n Raspberry and many other things such as activating SSH which used for controlling the Raspberry through the terminal. - Building the application: as it is a hardware project mainly, we had a little knowledge on applications building and you will note the weakness of building this application, but we mostly interested about the idea itself more than the style in this period, so we were going to build this application using flutter but for the lack of time we build it using React Native instead as it is easy to use and learn with widely applications built by. - The way we did the notification part of the application was the hardest part of building the application where we need to connect it online with the application 9 | P a g e and keep it on even the applicatio n is not in use. - Keypad and keep reading PIN code in Arduino code as we cannot keep reading PIN code when system is reading other sensors, so we did a relation that combine between timing and interrupting methods to make thing logic and acceptable. 2.2 Earlier Coursework There are many courses we have learnt in the Computer Engineering Department, and some courses that we had to take to complete our knowledge and helped us to complete this project, for example, Microprocessor, Microcontroller, and their Labs: we were able to interface different peripherals with Arduino , such as using the concept of master/slave in I2C where the slave was the Arduino and the master was Raspberry Pi Telecommunications and Security courses and their Labs: W e did chan ge the configuration of our Raspberry Pi IP to connect it with our computers wireless so we give it a static IP and connect it using VNC server and router through internet. In addition of the security course which helped us in authentications of the physi cal building, and the algorithms needed for the security alert system of the house. Raspberry course: To handle the Raspberry Pi which is a main part in our project, we took this course to control and do all needed configurations of the Raspberry Pi 3b. Arduino course: To handle the Arduino Mega which is also a main part in our project, we took this course to control and do all needed configurations of the Arduino Mega. 10 | P a g e Chapter 3 : Methodology In this chapter, we will explain the overall process of development, and what hardware tools and techniques we used in building the project. 3.1 Background and Tools 3.1.1 Description The house consists of 2 Bedrooms, Living room, Kitchen, bathroom, and Ga rage. In addition of front and back doors, garage door, and 2 windows for each bedroom. To make sure our house is safe, we applied a PIN code initially on the front door and because it is not open or invalid the security alert system will continue to work, we have put 3 motion sensors (PIR), two in the bedrooms and one in the garage for any kind of movement that might happen. Two magnetic sensors (Reed Switch), one for the front door and the other for the tailgate. They are all connected to the system that will move the camera if any trigger occurs here or there at home to capture it and includes sending a notification to the app. T here is a waterflow sensor in the bathroom in case of flooding water it will open the drain (which is LED here) for 10 second o r till the water gone, also, a gas/dust sensor in case of flames or house burning. A light sensor (LDR) for sunrise and sunset, and for future features and appliances. Our application is simple and easy it consists of three main parts, lights, Garage door and windows, and notifications. Everything will happen in the house the owner of the house will be notified, he also can control the lights and windows by application through the internet. Our application has no entrance authentication as for the beginnin g it will be connected to the house and owned by the user, later we may do a username/e - mail with a password for our clients. We end up with a full house that has a complete security system and a control application to keep in touch with your smart home. 11 | P a g e 3.1.2 Hardware Tools and Construction Hardware Tools We used the following hardware equipment and modules in our project: Name Quantity Photo Arduino Mega 2560 1 Raspberry pi 3b 1 Bread board 4 Servo motors 3 buzzer 1 Relay (8 channels) 1 LCD (4*20) 1 Keypad 4*4 1 (PIR) motion sensor 3 (Reed Switch) magnetic sensor 2 Water flow sensor 1 12 | P a g e Raspberry Camera 1 LED and Resistor Dust/Smoke sensor 1 Light sensor 1 RTC 1 Jumper wires Construction Process The final preview of the house is shown in the following figures: Figure 1: Front side view of the house. 13 | P a g e Figure 2: Back side view of the house. Figure 3: Roof view from the top of the house. Figure 4: Kitchen and bedroom 1 view from inside. 14 | P a g e Figure 5: Garage view and the brain of the project. Figure 6: Front door view from inside with bedroom 2 and bathroom. Pins Map: o Arduino Pins A0: Smoke sensor A1: Water sensor A2 - A3: Garage door A4 - A5: Bedroom 2 W A6: Light sensor A7: water drain led A8: Smoke sprinkler led A9: Lock 1: I2C Request 3 - 5: RTC 6: Garage motor 7 - 12: LCD 13: Smoke led 14 - 19: Push buttons 22 - 23: Bedroom 1 & 2 M 25 - 28: Relays 1 - 4 29,31: LED’s 30,32: Relay 5 & 6 34: Bedroom 2 PIR 35: Speaker 36: Garage PIR 37,38: LEDs 39: Bedroom 1 PIR 41 - 42: Doors 43 - 44: Bedroom 1 W 46 - 53: Keypad 15 | P a g e 3 .2 Technologies In this section we would like to mention technologies that we have used building this project, we mentioned some of it above and there is other we did not mention. Programming languages: We used in this project many programming languages such as C++ for programming the Arduino, JavaScript for building the NodeJS server and the React Native applicati on , we do MySQL for database NodeJS server Firebase cloud messaging service for the notification I2C communication between Arduino ( Slave ) and Raspberry ( Master ) Serial communication SPI for RTC module as we use it to read date and time and show it on the font LCD PWM for controlling Servo motors Libraries used in NodeJS server for Raspberry - Express and Body parser for running the server - Raspi - i2c for manipulating I2C communication - Firebase - admin for controlling notification messages - PIGPIO for controlling Raspberry Pi pins - Pi - camera - MYSQL driver to connect with SQL server Libraries used in Arduino - Wire.h for manipulating I2C communication - VirtualbotixRTC.h to dealing with RTC module - Keypad.h for Keypad - Servo.h for servo motors - LiquidCrystal.h for dealing with LCD Libraries used in Application React Native - React - navigation and react - navigation - stack for moving between frames - React - native - firebase/messaging for notifications - React - navigation - tabs for tabs on application - Axios for request/response orders between client/server 16 | P a g e 3.3 Scenarios Here we will show you three to four different scenarios of how our house is working and how it is interactive with problems, and the application in all cases will still do its job which is as a remote control and notifications receiver. 1. Owner is out of the house System is on, doors are closed and no motion in the entire house. All sensors working as well. A move happened in bedroom 1, buzzer will turn on, a notification will be sent for the owner application, camera will move toward the trigger and capture the moment and save notification in the database for once. If a fire caused or a water flood the drain will be open and a notification will be sent. System will be waiting for a PIN code t o turn everything off (Status: In the house). 2. Owner is in the house As we are in the house, Security System is off All sensors working, but no actions will be taken. Can control the lights, garage door, and windows by a push buttons or the application. If a fire caused or a water flood the drain will be open and a notification will be sent. System will be waiting for a PIN code to turn everything on (Status: Out of the house). 3. PIN set, reset, re - write The PIN code will be initially “1111”. It can be reset by entering the house and put the new PIN then press ‘A’ and confirm by pressing ‘B’ then It is changed. If you missed a letter in the code, you can re - write by press ‘*’ then rewrite. 4. Notifications The owner will be aware of what is going on in his house by his absence through the notifications which will be sent after any trigger happened in the house and that one of the purposes of the project. For these scenarios we have a full flow charts that we build our house and application upon them , 17 | P a g e Figur e 7 : Sensors initializing and working flow chart Figure 8 : Application flow chart. 18 | P a g e Figure 9 : Scenarios One and Two the house alert System flow chart 19 | P a g e 3 4 Results and Discussion As a result of this project (Smart Home), we did achieve many of the goals that we were aware of and needing for, but as we finished, we also learned and saw many benefits that this project can add and help society in real life. Developing this project resulted in many outcomes: Safe houses Easy life and controlling Keep aware of what is going on in your house with your absence Simplicity which encourages people to go through this kind of technology and apply it. Protected house from burning and water flooding. Reducing costs and time for police and fire department s in case of fire when they follow the system position and information Large field of development and investment. Chapter 4 : Conclusion and Future Work 4.1 Conclusion In this project, we have presented a methodology and a full construct of a smart secured house and how we apply the needed concepts, technologies and took all required courses to come up with this house and application. We achieved this project goals and learned a lot of this experience, it did add so much for us, on the personal and t echnical ways. We encourage and recommend more attention on the hardware courses and projects in computer science and computer engineering departments as it focus on reality and inventing things with benefits on students themselves and societies generally 20 | P a g e 4.2 Future Work For the near future we think that there is a lot of work to do in this field (Smart Home), this thing we can notice and touch from our real and nowadays life. As we can see that everything is going smart and easy to comfort the human being and even the animals, our depends on technology and artificial intelligence is increasing day by day and as we said in the abstract that is engineering job especially the computer engineers, as we are leaders in technology fields, and to keep up with the rest of world and the century technologies, we must keep eye on this evolution and practice more. Some features can be mentioned, smart electrical appliances which is almost in every house that can be connected to the application we did and give us a feedback and keep in touch with any smart machine in our home or house. Working on application itself as we can develop it to more authorization that can be connected to the security of the house, do more work on the GUI to let it keep up with the modern style, give more kind of control of the house to the owner specially on sensors. Supplying the house with clean power by adding Solar cell panels on the roof of the house and put them on a motor connected to (3 to 4) LDRs that follow the sunlight movement and keep up with it. Improve the security of the house by fingerprint or even eye print technology and supply a remote control or the same application for more control inside the house. All technologies and ideas are not that hard to do nowadays and we can do it ourselves as we got all the basics and needed materials, but we did not because of the lack of time and money. The End