SlideShare a Scribd company logo
1 of 12
Download to read offline
Faculty of Arts and Sciences
Department of Computer Science
CMPS 299 – Software Graduation Project Spring 2016
Final Report
Students: Bassem Al Masri
Fadi Hamad
Reem Abou Ibrahim
Advisor: Professor Ahmad Dhaini
Executive Summary:
Open Sesame is a project intended to facilitate the process of garage opening for users.
With Open Sesame, opening a garage becomes an automated process handled by a smart
application that users only need to download on their phones. No longer will there be a need to
buy garage remote controls or worry about guest access, with Open Sesame, your garage will
be directly controlled through your smartphone user can open his/her garage door through
Bluetooth communication between his/her smartphone and the Bluetooth module of the
garage. Moreover, this resident is able to give access to guest at specific time or unlimited
access, to remove his/her access from a specific garage door, to remove a guest access given by
him/her to a specific garage, and .to check access history on a given garage.
Requirements and Deliverables:
Requirements and Specifications: The system we are building through the android
application and the hardware connected to the garage gate is designed in a way to facilitate the
access to a resident or a guest to a garage gate where response time to connect to the gate
ranges from one second to maximum of 6 seconds which depends on the smartphone. This
system is automated and doesn’t depend on the user intervention since the user isn’t aware of
all the background processes that connect the gate to his/her phone after checking the
eligibility of this user to access this door with the server, establish the Bluetooth
communication, and creates the Bluetooth socket to transfer data from the Android phone to
the gate. Indeed, the user only realizes the appearance of the Button on the main page that
indicates that all the processes succeeded and he/she able to open/close the gate. Other than
that, the user is able to give or remove access to any guest he/she wants through email for
specific duration of time on a specific gate where the guest will notice the grant or the removal
of access instantly through notification.
Deliverables:
Automatic checking if the user has access to specific gate through contacting the server.
Automatic pairing and connecting to a specific garage that the user has access to when
the user is within the proximity of this gate.
Button that is only shown when the user is connected to a gate to allow him/her to
open/close the gate.
User is able to list all the garages that the user has access to as a resident or as a guest.
User is able to click on a specific garage of those that he/she has access to in order for
him/her to check the info of this specific garage.
User is able to add a guest to a specific garage where he/she is resident for through
email where the user is able to determine the duration of this access or it can be unlimited
access time.
User is able to list all the guests that he/she gave them access to this gate when he/she
is resident for.
User is able to click on those guests to check their info.
User is able to remove a guest access from a specific garage that he/she is resident for.
User is able to remove his/her access for a given garage.
User is able to display the access history for him/her when he/she is guest for this gate
or also the guests’ accesses history that he/she gave them this access when he/she is resident
for this gate.
Notify guest when a resident granted his/her access to a given specific garage or in case
the resident removes his/her access.
Hardware is compatible with different types of gates. Those which require a 220V input
are connected through the relay in the OpenSesame hardware. Others which have the relay
and power source, connected to the gate already, are directly connected to the arduino.
Hardware:
The hardware parts needed for our project are:
1. Bluetooth Module HC-05.
2. Arduino Uno.
3. Bridge Rectifier L298N.
4. Relay 12 V.
5. DC Motor.
I. Bluetooth Module HC-05:
The Bluetooth module is connected to the Arduino board through four pins: VCC pin
from the module to the 3.3 v pin in the board, GND pin from the module to the GND pin in the
board, TXD pin in the module to the Digital pin 1 in the board, and RXD pin in the module to the
Digital pin 0 in the board. This way of connection will allow the module to connect to any
Bluetooth device, so that the android phone running our app can discover the module, pair
with it, and establish a Bluetooth communication to send messages through Bluetooth sockets.
This module is designed in such a way that it can only establish one communication at a
time so that it can only be connected through one Bluetooth socket which is what is required in
order to not allow two users to be connected to the same garage at the same time.
II. Arduino Uno:
The Arduino connected to the Bluetooth module will be always ready to read input and
to analyze it. This input will be in form of messages received through the module. After the
Arduino reads the input, it will do some authentication process to make sure that the input
received is the same as the one expected which is unique for this garage. If the authentication
succeeded, the Arduino will output one pin high and another pin low (12 and 13) for only one
minute to open or close the gate depends on the order and then the two pins will become low,
if not nothing will happen.
This board is the only piece of hardware that is running software on it. This software,
written using the Arduino IDE, will be always running on the Arduino to receive data, analyze it,
and then do the appropriate task.
III. Bridge Rectifier:
The output from the Arduino is about 5 V only, so it can’t function neither the DC motor
for testing nor a real garage motor. Thus, this rectifier is needed to transform the output of the
Arduino from 5V to 12V. This rectifier will be connected to the Arduino through three pins: 2 for
input which are the output pins of the Arduino (12 and 13) and another pin for power which is
pin 5V in the Arduino board. Also, the rectifier will be connected to a 12V power source.
Furthermore, this rectifier have an output gate of 12V.
The 5V output coming from the board to the rectifier will trigger the internal switch
inside the rectifier to allow the current to pass from the 12V power source to the output gate.
Thus, in this way the output of the Arduino was transformed from 5V to 12V. This output of the
rectifier will be connected to the DC motor for testing and demo, but in the real case it will be
connected to a 12V relay which discussed in the next section.
IV. 12V Relay:
This relay has input gate to receive order through, com gate connected to power source
of 220V, NC (Normally Close) gate which by default is the output gate connected directly to the
com gate, and NO (Normally Open) gate which is an output gate but by default not connected
to the com gate. When the input gate on the relay is not receiving any high and low input, the
power coming to the com gate will be outputted through the NC gate, but when the input gate
received high and low input, the power coming from the com gate will be redirected to the
output gate NO.
Thus, the connection between this relay, the bridge rectifier, and a real garage motor
will be as follow:
1. The output of the bridge rectifier will be connected to the input of this relay.
2. The com gate will be always connected to the 220V source.
3. The NO gate will be connected to the garage motor.
4. The NC gate can be connected to a lamp but this connection is not necessary. The lamp will
be always on if there is no order to open or close the garage, but it will be turn off when there
is an order to open or close the garage.
Android:
I. Authentication Process:
Open Sesame uses firebase authentication tokens in order to check whether a user is
authenticated or not. It currently employs authentication via email and password, and via
Facebook.
Upon the user opening the app, the following occurs:
1- The app checks whether there exists a valid firebase token, if yes, then authentication
succeeds. If that is not the case, it checks whether there exists a email and password(stored
using a hashing mechanism) in the app’s cache, if yes then it attempts to revalidate the firebase
token using the email and password fetched. If the validation is a success, it goes to the main
page of the app, if not it goes to the login page.
2- If there is no valid firebase token, and no email and password stored in cache, the app checks
if the user has a valid Facebook token, if there exists no token (token equals null) it proceeds to
the login page, if there exists a token but is not valid, the app attempts to validate the facebook
token by authenticating either with the facebook app, or opening facebook via the default web
client. If the token is validated successfully, the app authenticates the firebase token using the
facebook token, and if that succeeds the user goes to the main page of the app, and if not to
the login page.
3-If there is no valid firebase token, no email and password stored in cache and also no
facebook token at all, the app goes to the login page.
4- In the login page, the user can enter his email and password, if they succeed, this validate the
firebase token, and stores them in the app cache. If the user chooses to authenticate via
facebook, this opens the facebook app or facebook website and creates a facebook token that
is authenticated.
5- If the user chooses to logout, the firebase reference is unauthenticated, email and password
are deleted from cache and the facebook token is deleted.
II. Connection to the Garage:
After the login and the authentication process, the user will be redirected to the main
page.
In the background of the main page, a process will be always running in this page to discover
Bluetooth devices to connect with. If this process finds a device, it will contact the cache to
check if this user is eligible to connect to this gate which means if this user has an access to this
garage gate(note that the cache updates automatically upon any change of access on the
database. If the user has access to the garage, the user will try to connect to this garage if there
is no other communication at the same time between the garage and another user, but if the
response was no, the discovery process will continue indefinitely until it connects to a garage
gate and a message will be displayed to the user “You are currently not connected to any
garage”.
If the user already paired with this gate before, a Bluetooth communication will be
established between the gate and the user’s phone as soon as the user is in the range of a gate
that he/she has access to and no one else is connected to this gate at this moment. However, if
this is the first time the user try to connect to this garage gate, the response from the server
will also include the Pairing Key (password) of this gate and the appropriate messages to be
send to the Arduino to open or close the gate. This key will be automatically entered by the
application when the user try to connect to this gate without the user intervention.
After the communication link was established between the user’s phone and the
Bluetooth module of the garage, a Bluetooth Socket will be created to transfer data between
the two hosts and a button will appear in the middle of the page indicating the connection
succeeded and the user is now able to open or close the gate. Once the user hits on the button,
the appropriate message will be sent to the Arduino in order to open or close the gate. After
the Arduino checks the message, it accepts it, and does the appropriate job. Also a history entry
in the database with the current timestamp will be added to the database.
III. Functionalities:
Check the Garages that the User has Access to: The app uses the userID to
query the database and get the list of garages the user has access to. User can see all the
garages that he/she has access to either as a resident or as a guest. These garages will be
displayed as a list where the name of the garage and the status of the user as a guest or
resident appears. In case the user has no access to any garage, a message will be displayed that
“You don’t have access to any garage yet”.
Remove his/her Access from a Given Garage: The user has the right to remove
his/her access from a given garage.
Two cases:
User is a guest to garage: his access to the garage is removed.
User is a resident to garage: his access to the garage is removed, and whatever guests he had
given access to will have their access removed, if this guest is granted access from another user,
he will still have access to the garage even if the first user removes his access.
Click on a Garage that the User has Access to: Once the user clicks on a garage
that he/she has access to, he/she will redirected to another page based on his/her access type
on this garage. If the user is resident on this gate, the page will has two functionalities: one to
display the guests that he/she gave them on this gate and another one for the access history of
him/her and his/her guests, but if the user is only guest on this gate, the page will only have
one functionality to display only his/her access history on this gate.
Specific Garage Page: If the user has resident access to the specific garage he/she
clicks on, one functionality of the new page is to display all this/her guests on this garage, so a
list of all the guests will be displayed with their names and the date when they got the access.
However, if the user doesn’t have guests on this garage, a message will be displayed that “You
have no guests at this garage”.
Click on a Guest To Display Details: The user is able to click on one of the guests
that he/she gave them access in order for him to display their info such as name, email, given
access date and time remaining for access. Also, the user is able to delete the access of the
given guest from his access list of guests. However, this doesn’t mean necessary that the guest
doesn’t have any more access to this gate because maybe another resident also gave him/her
access to the same gate, so there is always a query to check if the guest has given access to the
gate from more than one user. If the query indicates that there is only one resident who gave
him/her access the guest will not have any more access to the garage, otherwise he/she will
remain with access to this gate.
Give Access to a Guest Through email: A resident to a given garage can add guest
to this specific gate during specific period for one hour, 2 hours, 3 hours, or unlimited access.
When the guest gets access to this gate through a resident. This is done via a background
process in the app, that sleeps for the specified time then wakes up and deletes the user access
from the database. This mechanism takes the email of the user, queries the database, gets the
userID of the potential guest, and adds him as a guest under the userID of the current app user.
Give Access to a Guest Through facebook: if the user logs in via facebook, a blue
button on the bottom left appears, this button allows the user to add his facebook friends that
use the app as guests to the garage. This is done via the link between firebase and facebook
allowed by firebase. Basically the firebase id of a user logged in via facebook is : “facebook:X” X
being the facebook ID of the user. When a user adds one of his friends by clicking plus, the app
takes the facebook id of the friend, and queries the firebase database with the firebase ID
derived from the facebook id as explained above in a similar mechanism as the previous add
mechanism.
Check Access History For a Specific Garage: In the specific garage page, a user
can switch to the history tab in order to view his access history.
If he is a resident, the app queries the database for histories with the current garageID and with
the userID of the user, and of the guests of the user.
If he is a guest, the app queries the database for histories with the current garageID and with
the userID of the user only.
Push notifications: push notifications in open sesame are done via async post
requests to a push notifications server using a service called Batch. This service is integrated
with firebase in a way that you can send a post request with the firebase id in the header, and
this request goes to the batch server and the batch server sends the push notification to the
appropriate user.
Push notifications are implemented such that upon :
1- adding a guest: “X added you to garage Y for Z hours”
2- removing a guest: “X has removed your access to garage Y” note: this push is also sent upon
the expiration of a guest and when the resident who invited the guest removes his own access
Offline Capabilities: The app has offline capabilities as the token provided by firebase
allows the user to query the cache for 24 hours before it expires. The user can perform all the
operations as if he is online except for:
1- Logging in from login page
2- Any database changing requests (Add guest, remove guest)
Web:
I. Firebase
Firebase can power your app's backend, including data storage, user authentication, static hosting, and
more. We provide these services so you can focus on creating extraordinary user experiences.
Firebase Realtime Database
Data in your Firebase database is stored as JSON and synchronized in realtime to every connected client.
When you build cross-platform apps with our Android, iOS, and JavaScript SDKs, all of your clients share
one Firebase database and automatically receive updates with the newest data.
Automatically scales with your app
When your app is a breakout hit, you don't have to worry about scaling your server code or provisioning
extra capacity — Firebase handles that automatically for you. Our servers manage millions of concurrent
connections and billions of operations per month.
First-class security features
All of your data is transferred over a secure SSL connection with a 2048-bit certificate. Database access
and validation is controlled at a granular level using our flexible security rules language. All of your data
security logic is centralized in one place making it easy to update and verify.
Works offline
Your Firebase app will remain responsive regardless of network latency or Internet connectivity. All
writes to a Firebase database will trigger local events immediately, before any data has been written to
the server. Once connectivity is re-established, the client will receive any changes it missed,
synchronizing it with the current server state.
Firebase Authentication
With Firebase, you can easily authenticate users from our Android, iOS, and JavaScript SDKs in just a few
lines of code. We have built-in functionality for authenticating users with email & password, Facebook,
Twitter, GitHub, Google, and anonymous auth. Apps that use Firebase's built-in auth services can handle
user login entirely with client-side code, saving you time and the headache of operating your own
backend. You can also integrate authentication with your existing backend servers using our custom
auth tokens.
Firebase Hosting
Deploy your web app in seconds with our production-grade static asset hosting. All of your content is
delivered over SSL from our global CDN.
Deploy in seconds
Deploy using the Firebase command line tools and rollback to previous versions with one click. Every
app gets its own firebaseapp.com domain, and paid apps can deploy to a custom domain.
SSL by default
Every app is served over a secure connection, and we take care of provisioning the SSL cert for you.
II. Yeoman
Yeoman is a generator that installs and combines the workflow of three different tools: Yo, Grunt, and
Bower. It is an open source client-side development stack that provides a generator ecosystem to
scaffold entire web applications or just useful parts and pieces. Yeoman is "a robust and opinionated set
of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web
apps."
The components and workflow of Yeoman provide a project’s basic framework and prescribe best
practices and fast, efficient solutions to increase development productivity. Running as a command-line
interface written in Node.js, Yeoman combines several functions into one place; it can generate a starter
template, manage dependencies, run unit tests, provide a local development server, and optimize
production code for deployment.
Yeoman’s structure is comprised of three different types of tools that improve productivity and app
quality: a scaffolding tool (Yo), a build tool (such as Grunt), and a package manager (like Bower).
Yo is a command line interface (CLI) for running Yeoman generators; more generally, it is a tool used for
scaffolding a new application. It provides an easy way to create all of the boilerplate code necessary to
start a project. It creates common project assets, writes your Grunt configuration, and pulls in relevant
Grunt tasks and Bower dependencies for your particular build.
III. Grunt
Built on the Node.js platform, Grunt is a task-based command line build tool for JavaScript projects.
With the scripting power of Grunt, you can automate repetitive tasks like minification, compilation, unit
testing, linting, and more. From running tests to concatenating files and minifying scripts, Grunt aims to
give developers a single unified set of commands for a variety of tasks that work for every single
JavaScript project. Grunt has many built-in tasks to streamline and automate most mundane processes
required to build a quality product in JavaScript, but its basic functionality can also be extended through
third party plugins and scripts.
IV. Bower
Bower is the most popular option for Yeoman’s Package Manager; it is used for dependency
management, so that you don’t have to worry about manually downloading and managing scripts.
Bower is a package manager, a command line utility that requires Node.js, npm, and Git. It fetches,
downloads, and installs all the packages required by your particular web application, searching and
finding everything you need and saving the contents in a manifest file for you to track.
V. Karma
Karma is a JavaScript command line tool that can be used to spawn a web server which loads your
application's source code and executes your tests. You can configure Karma to run against a number of
browsers, which is useful for being confident that your application works on all browsers you need to
support. Karma is executed on the command line and will display the results of your tests on the
command line once they have run in the browser. Karma is a NodeJS application, and should be installed
through npm.
VI. NoSQL
A NoSQL (originally referring to "non SQL" or "non relational") database provides a mechanism for
storage and retrieval of data which is modeled in means other than the tabular relations used in
relational databases. NoSQL databases are increasingly used in big data and real-time web applications.
NoSQL systems are also sometimes called "Not only SQL" to emphasize that they may support SQL-like
query languages.
The structure of our database is:
Users {
user_ID {
date:
email:
firstName:
lastName:
Garages: {
garage_ID: access_type
}
}
facebook_ID: {
date:
facebook_ID:
firstName:
lastName:
Garages: {
garage_ID: access_type
}
}
}
Garages {
garage_ID:
MAC:
admin_ID:
location:
name:
pair_key:
Users: {
resident_ID: {
guest_ID:
}
}
}
}
Access_History: {
access_history_ID: {
garage_ID:
user_ID:
access_date:
}
}
VII. Functionalities
Register admins through an administrator account. Website administrators have the
ability to add admins and their respective gates. Upon which the admins created will receive
the credentials and edit them themselves.
Admin add garages. Once an admin is given an account, he/she can add more gates to their
account.
Admin add residents to a garage gate. An admin has the ability to add residents to a
garage gate using their email.
Delete residents from a garage.
Delete garage gates. Upon which all other relevant information in the database is deleted.
View residents of a garage gate.
Logout from the web interface.

More Related Content

Similar to Final Report

Home automation system using arduino with android
Home automation system using arduino with androidHome automation system using arduino with android
Home automation system using arduino with androidrahul takalkar
 
Smart door lock
Smart door lockSmart door lock
Smart door lockaswin5432
 
IRJET - Smart Door System
IRJET - Smart Door SystemIRJET - Smart Door System
IRJET - Smart Door SystemIRJET Journal
 
PROJECT REPORT ON Home automation using by Bluetooth
 PROJECT REPORT ON Home automation using by Bluetooth PROJECT REPORT ON Home automation using by Bluetooth
PROJECT REPORT ON Home automation using by BluetoothAakashkumar276
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724PAVINRAJ5
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino AMIT SANPUI
 
WIRELESS LOCKSYSTEM THROUGH OTP.docx
WIRELESS LOCKSYSTEM THROUGH OTP.docxWIRELESS LOCKSYSTEM THROUGH OTP.docx
WIRELESS LOCKSYSTEM THROUGH OTP.docxAnimeshBasak13
 
IRJET- Wireless Home Automation System using OpenHAB
IRJET- Wireless Home Automation System using OpenHABIRJET- Wireless Home Automation System using OpenHAB
IRJET- Wireless Home Automation System using OpenHABIRJET Journal
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduinoIkram Arshad
 
Controlling Home Appliances adopting Chatbot using Machine Learning Approach
Controlling Home Appliances adopting Chatbot using Machine Learning ApproachControlling Home Appliances adopting Chatbot using Machine Learning Approach
Controlling Home Appliances adopting Chatbot using Machine Learning ApproachMinhazul Arefin
 
IntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProjectIntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProjectNicholas Parisi
 
IRJET- IOT Based Surveillance Robotic Car using Raspberry PI
IRJET- IOT Based Surveillance Robotic Car using Raspberry PIIRJET- IOT Based Surveillance Robotic Car using Raspberry PI
IRJET- IOT Based Surveillance Robotic Car using Raspberry PIIRJET Journal
 
Eckovation IoT internship Report PowerPoint presentation
Eckovation IoT internship Report PowerPoint presentationEckovation IoT internship Report PowerPoint presentation
Eckovation IoT internship Report PowerPoint presentationManoranjanMaharana7
 
The automatic and manual railroad door systems based on IoT
The automatic and manual railroad door systems based on IoTThe automatic and manual railroad door systems based on IoT
The automatic and manual railroad door systems based on IoTnooriasukmaningtyas
 
Voice controlled smart home
Voice controlled smart home Voice controlled smart home
Voice controlled smart home SrijanKumar18
 
Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...birsa institute of technical education
 
Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...chandan kumar
 

Similar to Final Report (20)

ppt2 (1).pptx
ppt2 (1).pptxppt2 (1).pptx
ppt2 (1).pptx
 
Home automation system using arduino with android
Home automation system using arduino with androidHome automation system using arduino with android
Home automation system using arduino with android
 
Smart door lock
Smart door lockSmart door lock
Smart door lock
 
IRJET - Smart Door System
IRJET - Smart Door SystemIRJET - Smart Door System
IRJET - Smart Door System
 
PROJECT REPORT ON Home automation using by Bluetooth
 PROJECT REPORT ON Home automation using by Bluetooth PROJECT REPORT ON Home automation using by Bluetooth
PROJECT REPORT ON Home automation using by Bluetooth
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino
 
WIRELESS LOCKSYSTEM THROUGH OTP.docx
WIRELESS LOCKSYSTEM THROUGH OTP.docxWIRELESS LOCKSYSTEM THROUGH OTP.docx
WIRELESS LOCKSYSTEM THROUGH OTP.docx
 
IRJET- Wireless Home Automation System using OpenHAB
IRJET- Wireless Home Automation System using OpenHABIRJET- Wireless Home Automation System using OpenHAB
IRJET- Wireless Home Automation System using OpenHAB
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduino
 
Controlling Home Appliances adopting Chatbot using Machine Learning Approach
Controlling Home Appliances adopting Chatbot using Machine Learning ApproachControlling Home Appliances adopting Chatbot using Machine Learning Approach
Controlling Home Appliances adopting Chatbot using Machine Learning Approach
 
Intelligent Controlled Residence and Face Recognition Technology
Intelligent Controlled Residence and Face Recognition TechnologyIntelligent Controlled Residence and Face Recognition Technology
Intelligent Controlled Residence and Face Recognition Technology
 
IntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProjectIntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProject
 
IRJET- IOT Based Surveillance Robotic Car using Raspberry PI
IRJET- IOT Based Surveillance Robotic Car using Raspberry PIIRJET- IOT Based Surveillance Robotic Car using Raspberry PI
IRJET- IOT Based Surveillance Robotic Car using Raspberry PI
 
technochamp123_2
technochamp123_2technochamp123_2
technochamp123_2
 
Eckovation IoT internship Report PowerPoint presentation
Eckovation IoT internship Report PowerPoint presentationEckovation IoT internship Report PowerPoint presentation
Eckovation IoT internship Report PowerPoint presentation
 
The automatic and manual railroad door systems based on IoT
The automatic and manual railroad door systems based on IoTThe automatic and manual railroad door systems based on IoT
The automatic and manual railroad door systems based on IoT
 
Voice controlled smart home
Voice controlled smart home Voice controlled smart home
Voice controlled smart home
 
Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...
 
Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...Speed and direction control of dc motor using android mobile application chan...
Speed and direction control of dc motor using android mobile application chan...
 

Final Report

  • 1. Faculty of Arts and Sciences Department of Computer Science CMPS 299 – Software Graduation Project Spring 2016 Final Report Students: Bassem Al Masri Fadi Hamad Reem Abou Ibrahim Advisor: Professor Ahmad Dhaini
  • 2. Executive Summary: Open Sesame is a project intended to facilitate the process of garage opening for users. With Open Sesame, opening a garage becomes an automated process handled by a smart application that users only need to download on their phones. No longer will there be a need to buy garage remote controls or worry about guest access, with Open Sesame, your garage will be directly controlled through your smartphone user can open his/her garage door through Bluetooth communication between his/her smartphone and the Bluetooth module of the garage. Moreover, this resident is able to give access to guest at specific time or unlimited access, to remove his/her access from a specific garage door, to remove a guest access given by him/her to a specific garage, and .to check access history on a given garage. Requirements and Deliverables: Requirements and Specifications: The system we are building through the android application and the hardware connected to the garage gate is designed in a way to facilitate the access to a resident or a guest to a garage gate where response time to connect to the gate ranges from one second to maximum of 6 seconds which depends on the smartphone. This system is automated and doesn’t depend on the user intervention since the user isn’t aware of all the background processes that connect the gate to his/her phone after checking the eligibility of this user to access this door with the server, establish the Bluetooth communication, and creates the Bluetooth socket to transfer data from the Android phone to the gate. Indeed, the user only realizes the appearance of the Button on the main page that indicates that all the processes succeeded and he/she able to open/close the gate. Other than that, the user is able to give or remove access to any guest he/she wants through email for specific duration of time on a specific gate where the guest will notice the grant or the removal of access instantly through notification. Deliverables: Automatic checking if the user has access to specific gate through contacting the server. Automatic pairing and connecting to a specific garage that the user has access to when the user is within the proximity of this gate. Button that is only shown when the user is connected to a gate to allow him/her to open/close the gate. User is able to list all the garages that the user has access to as a resident or as a guest. User is able to click on a specific garage of those that he/she has access to in order for him/her to check the info of this specific garage. User is able to add a guest to a specific garage where he/she is resident for through email where the user is able to determine the duration of this access or it can be unlimited access time.
  • 3. User is able to list all the guests that he/she gave them access to this gate when he/she is resident for. User is able to click on those guests to check their info. User is able to remove a guest access from a specific garage that he/she is resident for. User is able to remove his/her access for a given garage. User is able to display the access history for him/her when he/she is guest for this gate or also the guests’ accesses history that he/she gave them this access when he/she is resident for this gate. Notify guest when a resident granted his/her access to a given specific garage or in case the resident removes his/her access. Hardware is compatible with different types of gates. Those which require a 220V input are connected through the relay in the OpenSesame hardware. Others which have the relay and power source, connected to the gate already, are directly connected to the arduino. Hardware: The hardware parts needed for our project are: 1. Bluetooth Module HC-05. 2. Arduino Uno. 3. Bridge Rectifier L298N. 4. Relay 12 V. 5. DC Motor. I. Bluetooth Module HC-05: The Bluetooth module is connected to the Arduino board through four pins: VCC pin from the module to the 3.3 v pin in the board, GND pin from the module to the GND pin in the board, TXD pin in the module to the Digital pin 1 in the board, and RXD pin in the module to the Digital pin 0 in the board. This way of connection will allow the module to connect to any Bluetooth device, so that the android phone running our app can discover the module, pair with it, and establish a Bluetooth communication to send messages through Bluetooth sockets. This module is designed in such a way that it can only establish one communication at a time so that it can only be connected through one Bluetooth socket which is what is required in order to not allow two users to be connected to the same garage at the same time. II. Arduino Uno:
  • 4. The Arduino connected to the Bluetooth module will be always ready to read input and to analyze it. This input will be in form of messages received through the module. After the Arduino reads the input, it will do some authentication process to make sure that the input received is the same as the one expected which is unique for this garage. If the authentication succeeded, the Arduino will output one pin high and another pin low (12 and 13) for only one minute to open or close the gate depends on the order and then the two pins will become low, if not nothing will happen. This board is the only piece of hardware that is running software on it. This software, written using the Arduino IDE, will be always running on the Arduino to receive data, analyze it, and then do the appropriate task. III. Bridge Rectifier: The output from the Arduino is about 5 V only, so it can’t function neither the DC motor for testing nor a real garage motor. Thus, this rectifier is needed to transform the output of the Arduino from 5V to 12V. This rectifier will be connected to the Arduino through three pins: 2 for input which are the output pins of the Arduino (12 and 13) and another pin for power which is pin 5V in the Arduino board. Also, the rectifier will be connected to a 12V power source. Furthermore, this rectifier have an output gate of 12V. The 5V output coming from the board to the rectifier will trigger the internal switch inside the rectifier to allow the current to pass from the 12V power source to the output gate. Thus, in this way the output of the Arduino was transformed from 5V to 12V. This output of the rectifier will be connected to the DC motor for testing and demo, but in the real case it will be connected to a 12V relay which discussed in the next section. IV. 12V Relay: This relay has input gate to receive order through, com gate connected to power source of 220V, NC (Normally Close) gate which by default is the output gate connected directly to the com gate, and NO (Normally Open) gate which is an output gate but by default not connected to the com gate. When the input gate on the relay is not receiving any high and low input, the power coming to the com gate will be outputted through the NC gate, but when the input gate received high and low input, the power coming from the com gate will be redirected to the output gate NO. Thus, the connection between this relay, the bridge rectifier, and a real garage motor will be as follow: 1. The output of the bridge rectifier will be connected to the input of this relay. 2. The com gate will be always connected to the 220V source. 3. The NO gate will be connected to the garage motor.
  • 5. 4. The NC gate can be connected to a lamp but this connection is not necessary. The lamp will be always on if there is no order to open or close the garage, but it will be turn off when there is an order to open or close the garage. Android: I. Authentication Process: Open Sesame uses firebase authentication tokens in order to check whether a user is authenticated or not. It currently employs authentication via email and password, and via Facebook. Upon the user opening the app, the following occurs: 1- The app checks whether there exists a valid firebase token, if yes, then authentication succeeds. If that is not the case, it checks whether there exists a email and password(stored using a hashing mechanism) in the app’s cache, if yes then it attempts to revalidate the firebase token using the email and password fetched. If the validation is a success, it goes to the main page of the app, if not it goes to the login page. 2- If there is no valid firebase token, and no email and password stored in cache, the app checks if the user has a valid Facebook token, if there exists no token (token equals null) it proceeds to the login page, if there exists a token but is not valid, the app attempts to validate the facebook token by authenticating either with the facebook app, or opening facebook via the default web client. If the token is validated successfully, the app authenticates the firebase token using the facebook token, and if that succeeds the user goes to the main page of the app, and if not to the login page. 3-If there is no valid firebase token, no email and password stored in cache and also no facebook token at all, the app goes to the login page. 4- In the login page, the user can enter his email and password, if they succeed, this validate the firebase token, and stores them in the app cache. If the user chooses to authenticate via facebook, this opens the facebook app or facebook website and creates a facebook token that is authenticated. 5- If the user chooses to logout, the firebase reference is unauthenticated, email and password are deleted from cache and the facebook token is deleted. II. Connection to the Garage: After the login and the authentication process, the user will be redirected to the main page. In the background of the main page, a process will be always running in this page to discover Bluetooth devices to connect with. If this process finds a device, it will contact the cache to
  • 6. check if this user is eligible to connect to this gate which means if this user has an access to this garage gate(note that the cache updates automatically upon any change of access on the database. If the user has access to the garage, the user will try to connect to this garage if there is no other communication at the same time between the garage and another user, but if the response was no, the discovery process will continue indefinitely until it connects to a garage gate and a message will be displayed to the user “You are currently not connected to any garage”. If the user already paired with this gate before, a Bluetooth communication will be established between the gate and the user’s phone as soon as the user is in the range of a gate that he/she has access to and no one else is connected to this gate at this moment. However, if this is the first time the user try to connect to this garage gate, the response from the server will also include the Pairing Key (password) of this gate and the appropriate messages to be send to the Arduino to open or close the gate. This key will be automatically entered by the application when the user try to connect to this gate without the user intervention. After the communication link was established between the user’s phone and the Bluetooth module of the garage, a Bluetooth Socket will be created to transfer data between the two hosts and a button will appear in the middle of the page indicating the connection succeeded and the user is now able to open or close the gate. Once the user hits on the button, the appropriate message will be sent to the Arduino in order to open or close the gate. After the Arduino checks the message, it accepts it, and does the appropriate job. Also a history entry in the database with the current timestamp will be added to the database. III. Functionalities: Check the Garages that the User has Access to: The app uses the userID to query the database and get the list of garages the user has access to. User can see all the garages that he/she has access to either as a resident or as a guest. These garages will be displayed as a list where the name of the garage and the status of the user as a guest or resident appears. In case the user has no access to any garage, a message will be displayed that “You don’t have access to any garage yet”. Remove his/her Access from a Given Garage: The user has the right to remove his/her access from a given garage. Two cases: User is a guest to garage: his access to the garage is removed. User is a resident to garage: his access to the garage is removed, and whatever guests he had given access to will have their access removed, if this guest is granted access from another user, he will still have access to the garage even if the first user removes his access. Click on a Garage that the User has Access to: Once the user clicks on a garage that he/she has access to, he/she will redirected to another page based on his/her access type on this garage. If the user is resident on this gate, the page will has two functionalities: one to
  • 7. display the guests that he/she gave them on this gate and another one for the access history of him/her and his/her guests, but if the user is only guest on this gate, the page will only have one functionality to display only his/her access history on this gate. Specific Garage Page: If the user has resident access to the specific garage he/she clicks on, one functionality of the new page is to display all this/her guests on this garage, so a list of all the guests will be displayed with their names and the date when they got the access. However, if the user doesn’t have guests on this garage, a message will be displayed that “You have no guests at this garage”. Click on a Guest To Display Details: The user is able to click on one of the guests that he/she gave them access in order for him to display their info such as name, email, given access date and time remaining for access. Also, the user is able to delete the access of the given guest from his access list of guests. However, this doesn’t mean necessary that the guest doesn’t have any more access to this gate because maybe another resident also gave him/her access to the same gate, so there is always a query to check if the guest has given access to the gate from more than one user. If the query indicates that there is only one resident who gave him/her access the guest will not have any more access to the garage, otherwise he/she will remain with access to this gate. Give Access to a Guest Through email: A resident to a given garage can add guest to this specific gate during specific period for one hour, 2 hours, 3 hours, or unlimited access. When the guest gets access to this gate through a resident. This is done via a background process in the app, that sleeps for the specified time then wakes up and deletes the user access from the database. This mechanism takes the email of the user, queries the database, gets the userID of the potential guest, and adds him as a guest under the userID of the current app user. Give Access to a Guest Through facebook: if the user logs in via facebook, a blue button on the bottom left appears, this button allows the user to add his facebook friends that use the app as guests to the garage. This is done via the link between firebase and facebook allowed by firebase. Basically the firebase id of a user logged in via facebook is : “facebook:X” X being the facebook ID of the user. When a user adds one of his friends by clicking plus, the app takes the facebook id of the friend, and queries the firebase database with the firebase ID derived from the facebook id as explained above in a similar mechanism as the previous add mechanism. Check Access History For a Specific Garage: In the specific garage page, a user can switch to the history tab in order to view his access history. If he is a resident, the app queries the database for histories with the current garageID and with the userID of the user, and of the guests of the user. If he is a guest, the app queries the database for histories with the current garageID and with the userID of the user only.
  • 8. Push notifications: push notifications in open sesame are done via async post requests to a push notifications server using a service called Batch. This service is integrated with firebase in a way that you can send a post request with the firebase id in the header, and this request goes to the batch server and the batch server sends the push notification to the appropriate user. Push notifications are implemented such that upon : 1- adding a guest: “X added you to garage Y for Z hours” 2- removing a guest: “X has removed your access to garage Y” note: this push is also sent upon the expiration of a guest and when the resident who invited the guest removes his own access Offline Capabilities: The app has offline capabilities as the token provided by firebase allows the user to query the cache for 24 hours before it expires. The user can perform all the operations as if he is online except for: 1- Logging in from login page 2- Any database changing requests (Add guest, remove guest) Web: I. Firebase Firebase can power your app's backend, including data storage, user authentication, static hosting, and more. We provide these services so you can focus on creating extraordinary user experiences. Firebase Realtime Database Data in your Firebase database is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our Android, iOS, and JavaScript SDKs, all of your clients share one Firebase database and automatically receive updates with the newest data. Automatically scales with your app When your app is a breakout hit, you don't have to worry about scaling your server code or provisioning extra capacity — Firebase handles that automatically for you. Our servers manage millions of concurrent connections and billions of operations per month. First-class security features All of your data is transferred over a secure SSL connection with a 2048-bit certificate. Database access and validation is controlled at a granular level using our flexible security rules language. All of your data security logic is centralized in one place making it easy to update and verify. Works offline Your Firebase app will remain responsive regardless of network latency or Internet connectivity. All writes to a Firebase database will trigger local events immediately, before any data has been written to
  • 9. the server. Once connectivity is re-established, the client will receive any changes it missed, synchronizing it with the current server state. Firebase Authentication With Firebase, you can easily authenticate users from our Android, iOS, and JavaScript SDKs in just a few lines of code. We have built-in functionality for authenticating users with email & password, Facebook, Twitter, GitHub, Google, and anonymous auth. Apps that use Firebase's built-in auth services can handle user login entirely with client-side code, saving you time and the headache of operating your own backend. You can also integrate authentication with your existing backend servers using our custom auth tokens. Firebase Hosting Deploy your web app in seconds with our production-grade static asset hosting. All of your content is delivered over SSL from our global CDN. Deploy in seconds Deploy using the Firebase command line tools and rollback to previous versions with one click. Every app gets its own firebaseapp.com domain, and paid apps can deploy to a custom domain. SSL by default Every app is served over a secure connection, and we take care of provisioning the SSL cert for you. II. Yeoman Yeoman is a generator that installs and combines the workflow of three different tools: Yo, Grunt, and Bower. It is an open source client-side development stack that provides a generator ecosystem to scaffold entire web applications or just useful parts and pieces. Yeoman is "a robust and opinionated set of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web apps." The components and workflow of Yeoman provide a project’s basic framework and prescribe best practices and fast, efficient solutions to increase development productivity. Running as a command-line interface written in Node.js, Yeoman combines several functions into one place; it can generate a starter template, manage dependencies, run unit tests, provide a local development server, and optimize production code for deployment. Yeoman’s structure is comprised of three different types of tools that improve productivity and app quality: a scaffolding tool (Yo), a build tool (such as Grunt), and a package manager (like Bower). Yo is a command line interface (CLI) for running Yeoman generators; more generally, it is a tool used for scaffolding a new application. It provides an easy way to create all of the boilerplate code necessary to start a project. It creates common project assets, writes your Grunt configuration, and pulls in relevant Grunt tasks and Bower dependencies for your particular build.
  • 10. III. Grunt Built on the Node.js platform, Grunt is a task-based command line build tool for JavaScript projects. With the scripting power of Grunt, you can automate repetitive tasks like minification, compilation, unit testing, linting, and more. From running tests to concatenating files and minifying scripts, Grunt aims to give developers a single unified set of commands for a variety of tasks that work for every single JavaScript project. Grunt has many built-in tasks to streamline and automate most mundane processes required to build a quality product in JavaScript, but its basic functionality can also be extended through third party plugins and scripts. IV. Bower Bower is the most popular option for Yeoman’s Package Manager; it is used for dependency management, so that you don’t have to worry about manually downloading and managing scripts. Bower is a package manager, a command line utility that requires Node.js, npm, and Git. It fetches, downloads, and installs all the packages required by your particular web application, searching and finding everything you need and saving the contents in a manifest file for you to track. V. Karma Karma is a JavaScript command line tool that can be used to spawn a web server which loads your application's source code and executes your tests. You can configure Karma to run against a number of browsers, which is useful for being confident that your application works on all browsers you need to support. Karma is executed on the command line and will display the results of your tests on the command line once they have run in the browser. Karma is a NodeJS application, and should be installed through npm. VI. NoSQL A NoSQL (originally referring to "non SQL" or "non relational") database provides a mechanism for storage and retrieval of data which is modeled in means other than the tabular relations used in relational databases. NoSQL databases are increasingly used in big data and real-time web applications. NoSQL systems are also sometimes called "Not only SQL" to emphasize that they may support SQL-like query languages. The structure of our database is: Users { user_ID { date: email: firstName: lastName: Garages: { garage_ID: access_type } } facebook_ID: { date:
  • 11. facebook_ID: firstName: lastName: Garages: { garage_ID: access_type } } } Garages { garage_ID: MAC: admin_ID: location: name: pair_key: Users: { resident_ID: { guest_ID: } } } } Access_History: { access_history_ID: { garage_ID: user_ID: access_date: } } VII. Functionalities Register admins through an administrator account. Website administrators have the ability to add admins and their respective gates. Upon which the admins created will receive the credentials and edit them themselves. Admin add garages. Once an admin is given an account, he/she can add more gates to their account. Admin add residents to a garage gate. An admin has the ability to add residents to a garage gate using their email. Delete residents from a garage. Delete garage gates. Upon which all other relevant information in the database is deleted.
  • 12. View residents of a garage gate. Logout from the web interface.