Content uploaded by Ahmed Hashim Mohammed
Author content
All content in this area was uploaded by Ahmed Hashim Mohammed on Oct 21, 2019
Content may be subject to copyright.
XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE
Controlling Smart Home Activities Using IoT
Rafidh Khalaf
Computer Science Department
AL-Mustansiriyah University
Baghdad, Iraq
ieee.rafidh86@outlook.com
Ahmed Mohammed
Computer Science Department
AL-Mustansiriyah University
Baghdad, Iraq
mscahmedhm@gmail.com
Hussein Ali
Networks Department
Kirkuk University
Kirkuk, Iraq
hussienalwaise@gmail.com
Essa Essa
Networks Department
Kirkuk University
Kirkuk, Iraq
dr.essa@uokirkuk.edu.iq
Abstract—The fast development in the field of
communications and semiconductors has led to increasing the
Internet of things (IoT) applications used in all areas of life
(such as industry, agriculture, transportation, health, and
smart cities). IoT devices like (sensors, actuators, embedded
devices, and RFID) may suffer from inadequate processing,
memory, and energy therefore. Designing and implementing
smart home is a very complicated work because of the
diversity of sensor, actuator technologies, and connected
services that may be tangled in smart home. The aim of this
paper monitoring and controlling smart home activities using
internet of things to support client anywhere an ability to
monitor data of temperature, humidity and ultrasonic sensors
constantly of home furthermore client can control many types
of actuator such air condition, room light, refrigerator and
water pump by changing on/off relays through exchange of
data among the things through server. Smart monitoring for
home application based IoT was decreased the person labor
to control home devices and made living easier and simpler
throughout raspberry Pi3 as microcontroller for controlling
various types of actuator and monitoring different types of
sensor data in addition all activities of visitors whom interred
to this system were registered.
Keywords—IoT, Smart Home, Confidentiality, Integrity,
OTP, Client, Server, PIR, DHT22, Actuators.
I. INTRODUCTION
The Internet of Things, commonly referred as IoT is an
ubiquitous concept where physical objects are connected to
the Internet and have an ability to communicate over a
network[1]. also, can be defined the IoT is a system of
physical objects that can be discovered, monitored,
controlled, or interacted with by electronic devices that
communicate over various networking interfaces and
eventually can be connected to the wider internet [2].Such
networked objects or things are referred as IoT devices and
are deployed universally[3]. The penetration of IoT has
been seen across numerous sectors such as building home
automation, smart cities, smart manufacturing, industrial
automation, automobiles, wearables, healthcare, farming
etc. The power of connectivity offered by IoT has been
utilized in various use cases related [4].
The IoT devices communicate using a different set of
protocols available for communication. Different wireless
standards like Wi-Fi , Bluetooth LE , ZigBee , Z-Wave
etc, exist are used to make IoT Smart home automation
feasible [5] . According to studies of As per Gartner
company, 25 billion devices it is expected that, while Cisco
expects 50 billion devices and Intel expects 28 billion
devices and iData expects 80 billion devices will be
connected to the Internet by 2020 [6].
Therefore, IoT is one of the most current and popular
areas of research in which many big companies are
investing billions in research and development
[7].According to Accenture research report, the global
industrial Internet of Things market size in 2012 reached
20 billion US dollars, expected in 2020 will be more than
500 billion US dollars in recent years will have a high
growth. At the same time, based on the current level of
input, by 2030, industrial Internet of things is expected to
bring at least $10 trillion to the world economy, while
investment based on sustained increases suggests that by
2030, Reaching 14 trillion dollars [8].
Having the extremely large number of interconnected
devices, configuration and management of these devices
do not seem feasible if we do not have automated
approaches. One of the application areas of IoT is Smart
home. A smart home is a home with intelligent IoT
household devices, which provides better living conditions
to the owner [9].The applicability of IoT devices in the
home can be seen in different scenarios, for example,
controlling of home lights efficiently using smart bulbs,
automatically main-training the temperature and humidity
of the house using smart thermostats, securing the
entrances etc.
People store lots of confidential and personal
information across such smart household devices. Such
devices are connected to the Internet via the home network
using the router equipment [10]. Maintaining the privacy
of the user and securing the home network is an important
task. Increases in using and applying the IoT in all areas of
daily life. And may directly or indirectly affect the lives of
the individual such as health applications as well as smart
home, smart cities, and others. Also, we must consider
several things the most important of which is security. That
With reference the two security, data anonymity,
confidentiality and integrity need to be guaranteed, as well
as authentication that is and authorization mechanisms in
order to prevent unauthorized users (i.e., humans and
devices) to access the system [11].
Whereas, concerning privacy requirement, both data
protection and users personal information confidentiality
have to be ensured, since devices may manage sensitive
information (e.g., user habits). Finally, trust is a
fundamental issue since the IoT environment is
characterized by different devices which have to process
and handle the data in compliance with user needs and
rights. The Note that adaptation and to the self-healing
play a key role in IoT infrastructures which must be able to
face normal and unexpected changes of the target
environment. Accordingly, privacy and security issues
should be treated with a high degree of flexibility [12].
II. INTERNET OF THING APPLICATIONS
There are a number of criteria to conFigure IoT
application layer. It is the application layered are the
uppermost layer and is visible to the end user [13]. There
are many areas of life in which Internet of things is
applied. An application layer typically comprises a
middleware or machine-to-machine communication
protocol, cloud computing, and a service support platform.
With the passage of time, more and more devices are
getting connected to the Internet[14] . The earth will be
blanketed with millions of sensors gathering information
from physical objects and will upload it to the Internet with
so many applications eying to adapt the technology with
the intentions to contribute to the growth of economy he
facility transportation and a better lifestyle for the public,
IoT must offer adequate security to their data to encourage
the adaptation process [15] [16].Figure 1 shows the IoT
application.
Figure 1. Internet-of-Things Applications[17]
III. THE PROPOSED ARCHITECTURE OF SMART
HOME
The proposed system consists of software components
as well as the hardware components that are combined
together to form smart home system to be used in the
monitoring activities of all the users entering of the IoT
applications. The system consists of Raspberry pi, two
sensors (the first is sensor is for temperature and humidity
and the second for measuring distances for proximity
measurement), four actuators (12V coil type, 10A) were
used to control four household appliances that run from
220V AC mains voltage, RGB LED for system status,
buzzer and expansion headers for future development.
Since the actuators relays (relays) operates from a 12V
signal, the Raspberry can’t drive them directly because all
GPIO pins is 3.3V capable, so a current buffer is needed to
interface the Raspberry pi GPIO pin that controls the relay
and the relay coil.
An integrated circuit (IC) that is well suited for the
driving of the relays coils and current buffering named
ULN2003A is used. Because the Raspberry pi needs 5V
source to run and there must be 12V source for the relays
to operate, it is inconvenient to have two separate sources
to feed the board. A 12V source is used as the only source
required for the system.
A circuit known as voltage regulator is added to the
overall circuit to down level voltage from 12v input to 5V
for powering Raspberry Pi and other sensors while the 12V
is fed directly to the relay driver IC. The voltage regulator
should have the ability to deliver at least 3 amperes of
current with five volts output voltage to power the
Raspberry Pi and all connected sensors and LED’s , the
main problem was the conventional linear regulators (such
as LM7805) cannot handle that current. Therefore, a
switching regulator of type (Buck converter) was used to
minimize the power conversion losses and achieving high
efficiency. A regulator that meets all these above
requirements is LM2596S switching step down converter,
which we used, in the power circuit part of the proposed
system.
All these components should be mounted and
connected together to form our system, so they should be
as compact as possible. For this reason, a printed circuit
board (PCB) is designed and printed for assembling the
hardware components together. The circuit diagram
containing all electronic devices firstly drawn using a
popular electronics simulation and drawing software
named Proteus.By using Proteus electronics design and
simulation software, the overall electrical circuit schematic
and the PCB design of the proposed system were designed
converted to a real electronic circuit board. The complete
circuit schematic of the proposed system is shown in
Figure 2.
Figure 2. The complete circuit schematic of the proposed system.
The artwork generated by Proteus is then converted to a
real PCB and then all components were placed and
soldered and the final circuit is shown in Figure 2.
Figure 2.The completed circuit for the proposed system
IV. HARDWARE COMPONENT
in this paper a number of software components used such
as (Node.js, JavaScript, HTML, CSS, AJAX and jQuery)
besides many hardware components such as Raspberry Pi
with two type of Sensors (e.g., DHT22 and ultrasonic
sensor), and four type of Actuators(relay), the details of
hardware components are illustrated in this section.
A. Types of Sensors
In the proposed system, two types of sensors were
used, the first is a temperature and a humidity sensor, the
second is an ultrasonic sensor. The details of each sensor
and how it is connected to the circuit is as follows.
1) Temperature and Humidity Sensor (DHT22):The
DHT22 is a low-cost and popular digital sensor for
measuring temperature and humidity. It uses a capacitive
humidity sensor and a thermal resistor (thermistor) for
measuring the temperature and humidity of the
surrounding air. It outputs a digital signal on the data pin
(pin number 2), thus; no analog to digital converter (ADC)
is required. It’s a fairly straightforward to deal with the
sensor and use it but its only flaw is that it can read new
data each two seconds but in our design it is more than
sufficient. The sensor is connected to the Raspberry Pi as
in Figure 3.
Figure 3. DHT22 sensor connected to the Raspberry Pi
Reading the temperature and humidity from the sensor
using the Raspberry Pi is done by using a npm model
library with NodeJS named rpi-dht-sensor, after installing
the model we can use the following initiation code to load
the library and define the GPIO data pin (GPIO23 pin is
used as data pin).The server program is reading the sensor
each two seconds and sends the encrypted reading to the
clients continuously as will be explained later in the
security section in this paper.
2) Ultrasonic sensor (HC-SR04): HC-SR04 is an
ultrasonic sensor or ranging module that provides 2 cm to
400 cm measurement without contact function. The
accuracy of measurements of ranges can reach down to
3mm and the effective angle is about 15°. The sensor is
operated from 5V power supply and has two data pins: one
for trigger and the other pin is the echo pin. When the
trigger pin is supplied with a pulse longer than 10ms, it
will start calculating the distance between the sensor and
the nearest obstacle by sending an ultrasonic waves and
waits for the wave to be back as shown in Figure 4.
Figure 4.The principle of operation for the ultrasonic sensor
The sensor will generate a pulse on the echo pin with a
duration that is equal to the travelling time of the ultrasonic
wave from the sensor to the obstacle and back to the
sensor.
The speed of the transmitted wave is the same as the
speed of sound in the air. If we want to measure the
accurate distance between the sensor and the desired object
we should measure the pulse of the echo pin accurately and
then find the distance (in meters) by the Equation (1).
distance=(echo pulse time)*(speed of sound)/2 …(1)
The basic electrical connection between the HC-SR04
sensor and Raspberry Pi is shown in in Figure 5.
Figure 5. Ultrasonic sensor connected to the Raspberry Pi
The hardware implementation of the proposed system
includes the electrical connections of the actuators (relays)
to the raspberry Pi as well as the connections between the
Raspberry Pi and the electronic sensors used in the system.
B. Types of Actuators
As mentioned earlier in this chapter, the actuator can be
a mechanic, electric hydraulic or pneumatic. An electric
actuator called “relay” has been used in our proposed
system to enable us to control household appliances by
using a small control signal from the Raspberry Pi. A relay
is switch that is electrically operated.
The popular and mostly used type of relays is the
electromagnet relay, which we used. The relay is used if it
is desired to control a circuit or a device that delivers
higher voltages or currents by a using a separate low-
power signal. When a small electrical current flows
through the relay’s coil, the coil will have a magnetic force
that causes the switch to conducts. The amount of voltage
that is required to turn on the relay depends on relay’s
type. We used the most popular and available type, which
is the 12V relay. Figure 6. Shows the proper way of
connecting a relay to the Raspberry Pi.
Figure 6. Connecting a relay to the Raspberry Pi.
Controlling the Raspberry Pi GPIO’s is done by using a
library called pigpio in NodeJS. Since the proposed system
have four actuators (relays), each of the four relays needs a
driver circuit. The integrated circuit (IC) is designed for
this purpose of driving multiple relays (up to seven relays)
named ULN2003 and is connected as shown in the overall
circuit design schematic in Figure (4.xx). Four GPIO pins
from the Raspberry Pi have been assigned for driving the
actuators (4, 17, 22 and 27). Controlling a specific
actuator, for example, Actuator 1 that is connected to the
GPIO4 Pin of raspberry Pi is done by firstly loading the
pigpio library and defining the GPIO type, then defining a
variable named relay1 that is connected to the GPIO4 and
setting the GPIO mode.
V. SYSTEM IMPLEMENTATION AND RESULT
The proposed system consists of two main branches;
the hardware side that is described and discussed, and
the software side implementation, which will be
divided into the following:
A.Visitor Sign up Mechanism
For security reasons, there is no sign up form
created for users to sign up for new account. Instead, they
get their accounts from admin which in role, take their
information like username, and email address and choses a
password for each user. Generating the user accounts is
done by admin programmatically by developing a function
that is called by admin each time a new user is requested to
be added. A lightweight database engine named NeDB was
used. The user information will be saved in a database file
in the local storage as one line per user. The user
information in the database file will be as shown in Figure
7.
Figure 7. A sample user sign up information is stored in the database.
The database module must be loaded and the storage
database file name is defined before we can use the
database as shown in the code in Figure 8.
Figure8. The code for loading the database and defining its storage
file.
Now, the administrator of the system have the code
already setup and all he have to do when adding new users
is to call the function add User() that is shown in Figure 9.
For example, if a user named Ahmed is desired to be sign
up to the system with basic permissions (is allowed to
control single actuator as will be discussed in the access
control section), the admin will write the following code.
As shown in the Figure9.
Figure 9. The code for adding a new user to the database
B .Visitor Sign in Page
A sign in page is created by using HTML markup
language and CSS for new comers that are not already
signed in. When any user attempts to enter the main
server’s page, He will be asked for an authentication token
in order for the server to check whether the request is from
an already signed in visitor or not, if the token is invalid or
has been expired then the visitor is asked to enter his
credentials. This mechanism is used for avoiding an
already signed in visitor from re-entering his login
information in case of re-visiting the page later within the
allowed session timeout, or in case he wants to refresh the
webpage. Figure (10) shows the sign in page.
Figure10. The sign in page.
When the visitor attempts to access the main page for
the first time, he will be re-directed to the sign in page
automatically by the server. By using AJAX’s
XMLHttpRequest modified jQuery function jQuery.ajax()
the client will ask the server for one time password (OTP)
to use it in the hashing process alongside with sign in
information. After the server responds to the client and
reply with an OTP the client will constructs a JSON that
contains the user name, password, AES secret key and the
provided OTP as shown in Figure 11.
Figure11. The JSON that contains user login information before hashing
The client will digest the constructed JSON string by
using the SHA-256 algorithm and produce a 256-bit hash
code and sends it to the server. In this novel technique, the
client does not have to expose such sensitive information;
instead, he sends only the hash code for the login
information plus the OTP. Therefore, it is impossible for
hackers to steal user’s credentials when he sends them to
the server because he did not send any information but a
hash code that contains an expired OTP once it arrives to
the server. When the server receive the login request from
the client that contains the sha-256 code. The login request
from client will looks like the content of Figure 12.
Figure 12. A sample login request from client
After the server receives the login request from the client
(the hash code), it will construct a JSON in the same
manner the client did with the user login information. The
server will compute the hash code from the last OTP that
was given to the user and searches the database of user’s
login information one by one. If a match between the
computed hash and the received hash is found, then that
user, whose login information caused the hash match, must
be the user that requested the login request. The user is
then allowed to access the main page and redirected to it.
The matched hash code will be saved in a temporary
list in the server as a token for that particular user at the
current session. If no match found between the hash of
each individual user in the database (in additional to the
last OTP that the server sent) then the user is redirected to
an error page which warns him that he entered incorrect
information.
The log in time is limited by the session timeout, which
is set to five minutes. As long as the user is logged in, he
must include his token as his only identifier in each data
transactions. For example, if some user wants to turn one
of the actuators on or off, he must append the request with
his token so the server knows which user requested that
command. Figure 13 shows the main page after a
successful login by user “Admin”.
C. The Server Web Page
The server webpage designed in by using HTML
markup language and CSS. The scripts of the page is
implemented with JavaScript. The layout of the webpage is
chosen to be tabbed navigation layout; Tabs are ideal
choice for single webpage servers as tabbed webpages are
capable of displaying different, each tab contains different
functionality.
1) The Main (Monitor) Tab :After the user is logged, he
will automatically redirected to the main page, which
displays live readings from the sensors that are connected
to the system in the way described in details in the
hardware implementation section. The page contains two
gauges: one for Temperature and the other is for humidity
reading. It also contains two animated charts, one for
temperature and humidity, the other is for distance
measured by the ultrasonic sensor. These charts are used
for displaying sensor’s reading in a timely manner. The
page also displays the raw encrypted data received from
the server. Figure 13 shows the main tab after logging in.
Figure 13. The main page after a successful login by user “Admin”.
2) Control Tab: The control tab contains a group of
buttons with explanation labels assigned for each
individual button to describe its function. Each button is
dedicated for controlling a specific actuator (Electronic
relay that drives larger AC 220V household appliances)
connected to the Raspberry Pi in a way that is described
in the hardware section. Depending to the type of
permission that the user have, the interface is different
from user to user. Each user can control a specified
actuator by his permission granted by the admin in the
sign up process described in the sign up section. If the
user have the permission to control a particular actuator,
a label contains “Enabled” is put right next to the button.
If the user does not have the permission to control that
actuator, a “Disabled” text with red color is placed on the
right side of that button to indicate the permissions of
that user. Figure 14. shows an example of a logged in
user where his permission is limited to control one
actuator (Water pump in our example).
Figure 14. A sample logged in user with limited permissions
When the user tries to turn one actuator on or off but he
does not have the permission, an alert will be displayed
telling him that he cannot control that actuator as shown in
Figure 15.
Figure 15.The action when a user tries to control an unpermitted actuator
The administrator, after logging in will have all the
buttons activated as he have the full permission on
actuators control as shown in Figure 16.
Figure 16 .The administrator user interface shows the full controllable
actuators
3) The Log Tab: The log tab contains logged data
reading from sensors that were previously saved in the
server’s database file specified for this purpose. The tab
also displays all the activities that happened before like
users signing in/out and controlling actuators by users with
the time of that event. Only the administrator can see this
data log and all other users will get a blank charts. Figure
17 shows the content of this tab after a login from
administrator.
Figure 17 shows the content of this tab after a login from administrator
4) Server status tab: This tab is the fourth one and
contains the important parameters of the server like the
server’s operating system type and version, kernel version,
CPU temperature, CPU load, total available and used
RAM as shown in Figure 18.
Figure 18. Server status tab.
5) About tab: This tab is dedicated to display a short
review about the developer and can contain a basic
overview about the developed project and future possible
enhancements and to-do’s.
VI. CONCLUSION
The monitoring of smart home activities providing a
facility to the user where one can continuously monitor
the surrounding parameters inside the house (like
temperature, smoke and light intensity) and can control
them by collection and exchange of data between the
things for example switching on/off devices (like fan and
light based on these parameters).The proposed system
resulted a high efficiency IoT server with a relatively
high-speed response; much less memory consumption
and lower CPU load were noticed in spite of using
various encryption methods of data between server and
clients.
REFERENCES
[1] Z. Zhu, J. Tang, S. Lambotharan, W. H. Chin, and Z. Fan, “An
integer linear programming based optimization for home demand-
side management in smart grid,” Innov. Smart Grid Technol.
(ISGT), 2012 IEEE PES, pp. 1–5, 2012.
[2] A. Longo et al., Cloud Infrastructures, Services, and IoT Systems
for Smart Cities, vol. 189. 2018.
[3] S. Pirbhulal et al., “A Novel Secure IoT-Based Smart Home
Automation System Using a Wireless Sensor Network,” Sensors,
vol. 17, no. 1, p. 69, 2016.
[4] N. Barodawala, B. Makwana, and Y. Punjabi, “Home Automation
Using IoT,” pp. 219–242.
[5] S. M. Brundha, P. Lakshmi, and S. Santhanalakshmi, “Home
Automation in Client-Server Approach with User Notification
along with Efficient Security Alerting system,” pp. 596–601, 2017.
[6] J. Granjal, E. Monteiro, and J. Sa Silva, “Security for the Internet
of Things: A Survey of Existing Protocols and Open Research
Issues,” IEEE Commun. Surv. Tutorials, vol. 17, no. 3, pp. 1294–
1312, 2015.
[7] Z. Kamal, A. Mohammed, E. Sayed, and A. Ahmed, “Internet of
Things Applications, Challenges and Related Future
Technologies,” WSN World Sci. News, vol. 67, no. 672, pp. 126–
148, 2017.
[8] V. Adat and B. B. Gupta, “Security in Internet of Things: issues,
challenges, taxonomy, and architecture,” Telecommun. Syst., vol.
67, no. 3, pp. 423–441, 2018.
[9] A. A. Diro and N. Chilamkurti, “Distributed attack detection
scheme using deep learning approach for Internet of Things,”
Futur. Gener. Comput. Syst., vol. 82, pp. 761–768, 2018.
[10] A. Gantait, J. Patra, and A. Mukherjee, “Design and build secure
IoT solutions , Part 1 : Securing IoT devices and gateways,” IBM
Dev., no. May, pp. 1–20, 2016.
[11] M. Conti, A. Dehghantanha, K. Franke, and S. Watson, “Internet of
Things security and forensics: Challenges and opportunities,”
Futur. Gener. Comput. Syst., vol. 78, pp. 544–546, 2018.
[12] K. Shingala and J. Patel, “Automatic Home Appliances and
Security of Smart Home with RFID, SMS, Email and Real Time
Algorithm Based on IOT,” Int. Res. J. Eng. Technol., vol. 4, no. 4,
pp. 1958–1964, 2017.
[13] A. Dorri, S. S. Kanhere, R. Jurdak, and P. Gauravaram,
“Blockchain for IoT security and privacy: The case study of a
smart home,” 2017 IEEE Int. Conf. Pervasive Comput. Commun.
Work. (PerCom Work., pp. 618–623, 2017.
[14] C. Science and C. Science, “Proposal to Develop Web of Things
for Secure E-Health Service,” 2017.
[15] Y. Yang, L. Wu, G. Yin, L. Li, and H. Zhao, “A Survey on
Security and Privacy Issues in Internet-of-Things,” IEEE Internet
Things J., vol. 4, no. 5, pp. 1250–1258, 2017.
[16] C. Stergiou, K. E. Psannis, B. G. Kim, and B. Gupta, “Secure
integration of IoT and Cloud Computing,” Futur. Gener. Comput.
Syst., vol. 78, pp. 964–975, 2018.
[17] J. Lin, W. Yu, N. Zhang, X. Yang, H. Zhang, and W. Zhao, “A
Survey on Internet of Things: Architecture, Enabling Technologies,
Security and Privacy, and Applications,” IEEE Internet Things J.,
vol. 4, no. 5, pp. 1125–1142, 2017.