Training Report Final
Training Report Final
1
Abstract
There has been an upsurge recently in the Industry of smart electronic devices that has
considerably eased their interfacing with each other. This is due to some common
elements in their hardware. In most cases, we found that the hardware stack across
various unrelated devices are perfectly compatible with each other which paves a way
to deploy a common mechanism for their interfacing. Controlling each of these devices
requires a central control unit; typically, a computer system which was difficult and
costly until a few years ago. Now, with the advent of the low cost, easy to deploy and
maintain Microcomputers like Raspberry Pi, it has become super easy even for a school
student to control high voltage devices without any huge risks involved in the wiring
and programming. Our work focuses on the idea of creating and deploying a simple
home automation system with minimum cost and simple programming.
Smart home is not a new term for science society, it is been used from decades. As
electronic technologies are advancing, the field of home automation is expanding
vastly. Automation or automatic means the use of systems for operating equipment
automatically or we can say without any manual effort. Home automation is exciting
because it tends to reduce human effort and hence will make things easier and faster.
Proposed implementation of home automation include control over electrical
appliances like fans, A.C. etc. where all the appliances (light bulb, fan, ac etc.) are
connected to the raspberry pi board and it is fully control by using Python GUI. This is
very useful for the aged as well as for the physically challenged people, easy to be used
for the long halls where no. of switches are more. To switch ON the ac we need the
remote control which we may forget where we had placed it the last time. To switch
ON the fan and to increase the speed of the fan we have to do it manually. We can use
this in everyone’s home, seminar halls, auditorium and long halls where no. of switches
are more.
2
The project developed is based on the concept of I.O.T (internet of things) which
employs the use of Hardware materials like Raspberry Pi, sensors etc. GUI was being
made using python and 000webhost server was being used as local server which helped
in connecting hardware and GUI.
3
Introduction
4
conditions it automatically close the curtains. Thus, home automation can be defined
as a mechanism removing as much human interaction as technically possible and
desirable in various domestic processes and replacing them with programmed
electronic systems. Ultimately it is a system that aims to heighten quality of life with
the automation of household activity that may be controlled over the Internet or
telephone.
5
System Overview
In this diagram the Raspberry PI is connected with electrical components via the help
of electronic switching system or relay system. One powerful feature of the Raspberry
Pi is the row of GPIO (general purpose input/output) pins along the edge of the board.
At the simplest levels, they are the switches that can turn on or off (input) or that the
Pi can turn on or off (output). Out of the 40 Pins, there are 17 GPIO pins. For practical
purposes a relay driver circuit and relays can be interfaced with Raspberry Pi and
appliances, respectively, for their controlling. Below is brief description of the
hardware components used:
6
1- Raspberry PI
Pi is based on a Broadcom SoC (System of Chip) with an ARM processor [~700 MHz],
a GPU and 256 to 512 MB RAM. The boot media is an SD card [which is not included],
and the SD card can also be used for persist data. Now that you know that the RAM
and processing power are not nearly close to the power house machines you might have
at home, these Pi’s can be used as a Cheap computer for some basic functions,
especially for experiments and education. The Pi comes in three Configurations and
we will discuss the specifications of those in the coming sections. The cost of a Pi is
around $35 for a B Model and is available through many online and physical stores.
The Raspberry Pi platform allows the user to create custom hardware and applications
to control it via its namesake programming language. Many software languages are
available on the Raspberry Pi like C++, Python, SQL, and HTSQL. Operating systems
that are available to install the Raspberry is Raspbian. Raspbian is based upon the
Debian Wheezy Linux operating system and has been optimized for use with Raspberry
Pi. The Raspberry Pi is connected to the Raspberry Pi's GPIO pins, and with the
inclusion of the software will be able to communicate between electronic devices, the
Raspberry Pi's operating system, and web-based proposed model.
7
Fig 1.1- Raspberry PI description
Below are the basic things you would need to get started with using a Pi:
Computer A Raspberry Pi
Storage SD Card and a SD card reader to image the OS
[These days laptops have inbuilt card readers]
Power supply 5 volt micro USB adapter, mostly your android
phone charger would work
Display An TV/Monitor with DVI or HDMI port
Display connector HDMI cable or HDMI to DVI converter cable
Input USB Mouse
Input USB Keyboard
Network Ethernet cable
Case If you really need one, you can get them online
based on the model you have
8
The Linux option called Raspbian is a greatmatch for Raspberry Pi because it’s
free and open source,keeping the price of the platform low, and making it more
hackable. There are also a few non-Linux OS options available.One of the great things
about the Raspberry Pi is that it has a wide range of usage. What enables it, as well as
performances and constraints of Raspberry Pi will be described in rest of the paper.
The Raspberry Pi performances will be compared with Aurdino another IoT prototype
platform :
9
SET UP YOUR RASPBERRY PI
CONNECT THE CABLES: Take the SD card adaptor out, retrieve the
microSD card, and slot it into the Raspberry Pi; this is very important, as the
Raspberry Pi won’t be able to turn on properly otherwise. To start with, you’ll
need to plug in an HDMI cable between the Raspberry Pi and your screen, an
Ethernet cable for your router (or a USB WiFi dongle), along with a mouse and
keyboard. Finally, when everything you need is plugged in, you can attach the
power cable to the Raspberry Pi
10
INSTALL RASPBIAN: The Raspberry Pi will turn on and display some text
on the screen – you can ignore this until it gets to a menu which lists all the
available operating systems. It allows you to select multiple OSes at once, but
right now we just want to use the one that’s called Raspbian. This is the main
operating system for the Raspberry Pi, with all the official apps, software, and
learning documents. Upon selecting Raspbian, click on Install and it will begin
the Raspbian installation process, which may take a little while to complete.
PIDORA: A bit like Raspbian, but based on a different core operating system.
This is something people a bit techy can use for a slightly different Raspberry
Pi.
ARCH: A very basic operating system that works entirely from a command
line, no mouse and keyboard required. You’ll really need to know your
computers to start with this.
USE OF GPIO
The GPIO port is one of the most powerful tools at the Raspberry Pi’s disposal,
allowing you to connect directly to an electronic circuit to control it. In such a system,
11
the Pi is referred to as a microcontroller. This is what makes the Raspberry Pi great for
big projects, as you can use it to program a machine or circuit, and even have it connect
to the internet via the other Raspberry Pi functions so that it can control contraptions
with web data. Each of the GPIO pins can do something different and very specific. At
the basic core, though, you can have them provide power consistently to part of a
circuit, program a power switch to one of the pins, and even have it sense a change
over the pins (thanks to resistance). These three basic functions allow you to do a lot,
and can be programmed with Python
2- Raspbian OS
Raspbian OS is the operating system that is available for Raspberry Pi. Raspbian is
based upon the Debian Wheezy Linux operating system and has been optimized for its
usage with Raspberry Pi.
Let’s first connect the board with all the necessary accessories to install and run an
operating system.
Step 1: Take the Pi out of its anti static cover and place it on the non-metal table.
Step 2: Connect the display – Connect the HDMI cable to the HDMI port on the Pi and
the other end of the HDMI cable to the HDMI port of the TV.
Step 3: Connect your Ethernet cable from the Router to the Ethernet port on the Pi
Step 4: Connect your USB mouse to one of the USB ports on the Pi
Step 5: Connect your USB Keyboard to the other USB port on the Pi
12
Step 6: Connect the micro USB charger to the Pi but don’t connect it to the power
supply yet
1. To prepare the car for use with the Pi we will need to put a OS on the card. We certainly
cannot drag and drop the OS files on to the card but the flashing the card is not too
difficult either.
2. Since we have already decided to install Raspbian, lets download the RASPBIAN
image from the following link. http://www.raspberrypi.org/downloads/.
3. Unzip the contents of the Zip file into a folder on your machine, one of the unzipped
files would be a .img file which is what needs to be flashed on to the SD card.[In case
there are more than one file, the current version of the zip has only this file and none
other.
4. Flashing from Linux instructions.
Start the terminal on your Linux OS
Insert the empty SD Card into the card reader of your machine.
Type sudo fdisk -l to see all the disks listed. Find the SD card by its size,
and note the device address (/dev/sdX, where X is a letter identifying
the storage device. Some systems with integrated SDcard readers may
use /dev/mmcblkX— format, just change the target in the following
instructions accordingly).
Use cd to change to the directory with the .img file you extracted from
the Zip archive.
13
3- Relay Driver
The relay module is a separate hardware device used for remote device switching. With
it you can remotely control devices over a network or the Internet. Devices can be
remotely powered on or off with commands coming from Clock Watch Enterprise
delivered over a local or wide area network. You can control computers, peripherals
or other powered devices from across the office or across the world.
The Relay module can be used to sense external On/Off conditions and to control a
variety of external devices. The PC interface connection is made through the serial port.
For a relay to operate a suitable pull in and holding current should be passed through
its coil. Relay coils are designed to operate from a particular voltage often its 5V or
12V. The function of relay driver circuit is to provide the necessary current energize
the relay coil, when a LOGIC 1 is written on the PORT PIN thus turning on the relay.
The relay is turn off by writing LOGIC 0 on the port pin. In our system four relays are
used for device control.
14
4- HDMI Cable
To connect the Raspberry Pi to the display monitor or a TV set. HDMI stands for "High
Definition Media Interface." But, it's not just a type of cable, cord, or connector. It's a
technology standard that's designed to transmit high-definition audio and video signals.
5- VGA Cable
The 15-pin VGA connector was provided on many video cards, computer monitors,
laptop computers, projectors, and high definition television sets. A VGA cable is used
to connect your computer to your computer monitor. It transfers the picture signal from
the computer to the monitor so it can be displayed. A VGA cable usually has a screw
on either side of the plug to mount it to the matching plug on the back of a computer
system. The inside of the plug has pins that fit into the pattern of holes in the back of
the computer.
15
Fig 5.1-VGA Cable
6- Breadboard
A breadboard is a rectangular plastic board with a bunch of tiny holes in it. These holes
let you easily insert electronic components to prototype (meaning to build and test an
early version of) an electronic circuit, like this one with a battery, switch, resistor, and
an LED (light-emitting diode). To learn more about individual electronic components,
see our Electronics Primer.
Fig 6.1-Breadboard
16
Fig 6.2-Vertical connections Fig 6.3-Horizontal connection
7- Jump Wires
Jump wire is an electrical wire, or group of them in a cable, with a connector or pin at
each end (or sometimes without them – simply "tinned"), which is normally used to
interconnect the components of a breadboard or other prototype or test circuit,
internally or with other equipment or components, without soldering
Individual jump wires are fitted by inserting their "end connectors" into the slots
provided in a breadboard, the header connector of a circuit board, or a piece of test
equipment.
17
System Design
The proposed System incorporates basically with the following four modules.
A web server is needed to create a link between the remote user and the Raspberry Pi.
A Web server is a program that, using the client/server model and the World Wide
Web's Hypertext Transfer Protocol (HTTP), serves the files that form Web pages to
Web users (whose computers contain HTTP clients that forward their requests).The
user can access the webserver using the port number of the respective raspberry PI. The
webserver used here is 000webhost.com.
3) User Interface
The user interface is on Python. The user interface(UI) is everything designed into an
information device with which a human being may interact including display screen,
keyboard, mouse, light pen, the appearance of a desktop, illuminated characters, help
messages, and how an application program. Later the user interface is linked with the
webserver.
18
Python offers multiple options for developing GUI (Graphical User Interface). Out of
all the GUI methods, tkinter is most commonly used method. It is a standard Python
interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the
fastest and easiest way to create the GUI applications.
To create a tkinter:
1. Importing the module – tkinter
2. Create the main window (container)
3. Add any number of widgets to the main window
4. Apply the event Trigger on the widgets.
Importing tkinter is same as importing any other module in the python code. Note that
the name of the module in Python 2.x is ‘Tkinter’ and in Python 3.x is ‘tkinter’.
There are a number of widgets which you can put in your tkinter application. Some of
the major widgets are explained below:
w=Button(master, option=value)
w = CheckButton(master, option=value)
w = Frame(master, option=value)
19
master is the parameter used to represent the parent window.
Label: It refers to the display box where you can put any text or image
which can be updated any time as per the code.
The general syntax is:
w=Label(master, option=value)
4) Linking Module
The last module is to link the python GUI with the script. This link is done by using
PHP.
20
Implementation of Home Automation System
The Raspberry Pi is connected to the Monitor using a HDMI cable and is provided with
the mouse and keyboard to give inputs. A micro SD card preinstalled with NOOBS
(New Out of the Box System) containing the Raspbian Linux distribution is inserted in
the memory card slot.
2) Installing Raspbian
The Raspbian Linux distribution is installed via the NOOBS with the prescribed
configuration settings.
The 000webhost server is being used as a server. It performs the task of connectivity.
4) Setting up PHP
The PHP which serves as a backend technology is used to collect status of devices and
corresponding device details.
The python script for each GPIO is written in the text editor available in the Raspbian.
The python scripts are stored in the folder with an extension .py. Before linking the
script.
21
6) Creation of the GUI and linking the python scripts
The GUI for the control of the GPIO is designed using Python. The PHP links all the
python scripts to the respective control button.
22
Coding
<?php
$con=mysqli_connect(“localhost”,”id6445346_chandrikadalakoti2”,”diyadalakoti”,”i
d6445346_abc”);
if($conn)
{
echo “connected”;
$sql=’’UPDATE `device` SET `status`=”on” where `id`=100”;
$req=mysqli_query($conn,$sql);
if($req)
{
echo “device in on”;
}
}
else
{
echo “some error”;
}
?>
2- Python GUI
23
root[“bg”]=”yellow”
btn1=Button(root, text =”on”, bg=”green”)
btn1.pack()
btn2=Button(root,text=”off”,bg=”red”)
btn2.pack()
root.mainloop()
<?php
$status_var=$_GET[‘status’];
$con=mysqli_connect(“localhost”,”id6445346_chandrikadalakoti2”,”diyadalakoti”,”i
d6445346_abc”);
if($conn)
{
echo “connected”;
$sql=’’UPDATE `device` SET `status`=’$status_var’ where `id`=100”;
$req=mysqli_query($conn,$sql);
if($req)
{
echo “device in ”.$status_var;
}
}
else
{
echo “some error”;
}
?>
24
4- Python script
import urllib as ur
ur.urlopen(“http://mywebsiteatcd.000webhostapp.com/second.php?status=off”)
ur.urlopen(“http://mywebsiteatcd.000webhostapp.com/second.php?status=on”)
import RPi.GPIO as io
import time
io.setwarnings(False)
io.setmode(io.BOARD)
a=3
b=5
c=11
io.setup(a,io.OUT)
io.setup(b,io.OUT)
io.setup(c,io.OUT)
def on_a():
io.output(a,1)
def on_b():
io.output(b,1)
def on_c():
io.output(c,1)
def off_a():
25
io.output(a,0)
def off_b():
io.output(b,0)
def off_c():
io.output(c,0)
while(1):
print(“enter your choice”)
print(“1-on a”)
print(“2-on b”)
print(“3-on c”)
print(“4-off a”)
print(“5-off b”)
print(“6-off c”)
x=input(“enter your choice”)
if (x==1):
on_a()
elif (x==2):
on_b()
elif (x==3):
on_c()
elif (x==4):
off_a()
elif (x==5):
off_b()
elif (x==6):
off_c()
else:
print(“invalid choice”)
26
Snapshots
27
Fig 10- Code for sending data from server to change the status of device
28
Fig 12-- Code in Python for GUI
Fig 13- The status of device changed on button clock from GUI
29
Fig 14- Status of device changed
30
Fig 16- Coding in Python on Raspbian OS for controlling the devices (Fig 16. And Fig 17.)
Fig 17.
31
Fig 18- Fig 18 and Fig 19 shows the LED automated such that the intensity of first LED is dim while
second is bright.
Fig 19.
32
Limitations
Human errors: If the human does not handle the kit safely or if he/she does not use
the correct keys to perform the operations, human errors may occur. Human errors also
lead to destructions of the machine. Then there will be a huge system crash.
Reliability: In very rare cases, the reliability of the home automated devices
varies (decreases). It depends mostly on the technology used and the advancements
being done.
33
Conclusion
The application of the IoT technology, in home automation means combination of all
electrical devices like smart mobile phone, personal computer, tablet and their
monitoring, controlling and alerting in ways not possible before. This proposed system
provides many advantages including, safety, security, improved comfort, energy and
cost savings. In order to address the issues of flexibility and functionality, a novel,
standalone, flexible and low cost home controlling and monitoring system using Web
services as an interoperable layer for communicating between the remotely present user
and the home devices, have been designed. Performed research have shown that by
using the Raspberry Pi and open source software it is possible to programmatically
control many devices in a home in such a way that user can create his/her own solution
customized to meet his/her individual needs. Thus, the proposed system is better from
the scalability, flexibility and security point of view. These kinds of home automation
systems are required because human can make mistakes and forgot to switch off the
appliances when there is no use and in this case, they are useful in order to utilize the
power effectively and also in a secured manner.
These kinds of home automation systems are required because human can make
mistakes and forgot to switch off the appliances when there is no use and in this case,
they are useful in order to utilize the power effectively and also in a secured manner.
34
Future Enhancement
IoT devices are becoming a part of the mainstream electronics culture and people are
adopting smart devices into their homes faster than ever. By 2020, it is estimated that
there will be up to 21 billion connected devices to the internet. IoT devices will be a
huge part of how we interact with basic everyday objects.
In just one year alone, we went from having 5 million IoT devices connected to the
internet to billions. The future is happening now, and these devices are getting smarter
every day through machine learning and artificial intelligence. To prove that IoT is
taking off rapidly, Target opened up a store in San Francisco that exclusively sells IoT
devices. There is big money in the IoT space currently, and it will only continue to
grow as technology improves.
The more data that IoT devices collect, the smarter they will become. Cities will
transform into smart cities through the use of IoT connected devices. Think of smart
traffic lights that collect data on traffic, and use that data to sync lights to peak traffic
times.
Overall, this improves cities overall efficiency and saves the government money since
everything can be remotely managed. Smart homes, thermostats, lighting systems and
coffee makers will all collect data on your habits and patterns of usage. All this data
will be collected to help facilitate machine learning.
With the mercurial rise of the Internet of Things (IOT), there has been a substantial
increase in the development of home automation and smart home technologies. What
was earlier an expensive proposal or even just a fantasy, is now an affordable option
for many homeowners and technology enthusiasts. The key reason for this is the
development of consumer devices that can harness wired or wireless internet
35
connectivity as well as improvements in other communications technologies such as
Near Field Communication (NFC) and Bluetooth.
So, what will smart home automation look like in the future? Much of this may revolve
around data about our appliance usage patterns. Each equipment manufacturer or
provider of home automation devices can, in theory, collect all of this data and use it
to create flexible modular solutions.
Unlike a few years ago, smart home technologies will become more accessible,
integrated and economical to purchase as the industry develops over time and matures
into the consumer market. Eventually, all of the automation possibilities will reach a
point where one single device is required to control our homes. This may eventually be
a communications or control center of its own, dealing with multitudes of peripheral
devices and ensuring they are operating as they should and when they should.
This future would involve trusting computers and robotics to manage our households
and all of our habits and data. Security of this data is, therefore, an area that will need
to grow with this sector. Ultimately the consumer will always be in charge,
programming their personal needs and ensuring that any automation enhances their
lifestyle. As technologies improve, automation of certain time-consuming or
unproductive tasks will be the norm. In many ways, it seems like future is not distant.
36
References
[1] Hari Charan Tadimeti, Manas Pulipati, “Overview of Automation Systems and
Home Appliances Control using PC and Microcontroller”, Volume 2 Issue 4, April
2013.
[3] Raspberry Pi as a Sensor Web node for home automation Vladimir Vujovic ,
Mirjana Maksimovic http://dx.doi.org/10.1016/j.compeleceng.2015.01.019
[4] Home automation using Raspberry Pi Monika M Patel a, Mehul A Jajal, Dixita B
vataliya - International Journal of Innovative and Emerging Research in Engineering
Volume 2, Issue 3, 2015.
[7] https://www.forbes.com/sites/andrewweinreich/2017/12/18/the-future-of-the-smart-
home-smart-homes-iot-a-century-in-the-making/1
37
[9] Home Automation Using Raspberry Pi 2 And Windows 10 IoT - Hackster.io
[10] What is a Smart Home? The Basics of Home Automation | CEDIA Blog
[11]https://www.codeproject.com/Articles/839230/Introduction-to-Raspberry-Pi-
with-Raspbian-OS
[12] www.geeksforgeeks.com
38