Voice Control Home Automation Using Raspberry PI With Code.
Voice Control Home Automation Using Raspberry PI With Code.
List Of Contents
1.1 Introduction 3
1.4 Scopes 8
1
Voice Control Home Automation Using Raspberry Pi
Chapter-6 28
6.2 Limitations 28
Chapter-7 Conclusion 29
References 30
2
Voice Control Home Automation Using Raspberry Pi
CHAPTER-1
1.1 Introduction
The “Home Automation” concept has existed for many years. The terms “Smart Home”,
“Intelligent Home” followed and has been used to introduce the concept of networking
appliances and devices in the house. Home automation Systems (HASs) represents a great
research opportunity in creating new fields in engineering, and Computing. HASs
includes centralized control of lighting, appliances, security locks of gates and doors and
other systems, to provide improved comfort, energy efficiency and security system. HASs
becoming popular nowadays and enter quickly in this emerging market. However, end
users, especially the disabled and elderly due to their complexity and cost, do not always
accept these systems.
Due to the advancement of wireless technology, there are several different connections are
introduced such as GSM, WIFI, and Bluetooth. Each of the connection has their own
unique specifications and applications. Among the four popular wireless connections that
often implemented in HAS project, WIFI is being chosen with its suitable capability. The
capabilities of WIFI are more than enough to be implemented in the design. Also, most of
the current laptop/notebook or Smartphone come with built-in WIFI adapter. It will
indirectly reduce the cost of this system. This project forwards the design of home
automation and security system using Raspberry pi, a credit sized computer. Raspberry pi
provides the features of a mini computer, additional with its GPIO pins where other
components and devices can be connected. GPIO registers of raspberry pi are used for
output purposes. We have to design a power strip that can be easily connected to GPIO
Pins of the Raspberry pi. The home appliances are connected to the input/output ports of
Raspberry pi along with the power strip and their status is passed to the raspberry pi. The
android running OS in any phone connected to a network can access the status of the
home appliances via an application.
3
Voice Control Home Automation Using Raspberry Pi
1.2What is the Raspberry Pi?
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer
monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that
enables people of all ages to explore computing, and to learn how to program in languages
like Scratch and Python.
While the RPi can be used without any additional hardware (except perhaps a power
supply of some kind), it won't be much use as a general computer. As with any normal
PC, it is likely you will need some additional hardware.
Raspberry Pi board
Prepared Operating System SD Card
USB keyboard
Display (with HDMI, DVI, Composite or SCART input)
Power Supply
Cables
USB mouse
Internet connectivity- a USB WiFi adaptor (Model A/B) or a LAN cable (Model
B)
Powered USB Hub
Connecting Together
You can use the diagram to connect everything together, or use the following instructions:
4
Voice Control Home Automation Using Raspberry Pi
Plug your extras into the Pi (USB WiFi, Ethernet cable, hard drive etc.). This is
where you may really need a USB Hub.
Ensure that your USB Hub (if any) and screen are working.
Plug the power source into the main socket.
With your screen on, plug the other end of the power source into the Pi.
The Pi should boot up and display messages on the screen. It is always
recommended to connect the Micro USB Power to the unit last (while most
connections can be made live, it is best practice to connect items such as
displays/h/w pin connections with the power turned off).
As the RPi has no internal storage or built-in operating system it requires an SD-Card
that isset up to boot the RPi.You can create your own preloaded card using any
suitableSD card you have. Be sure to backup any existing data on the card.Preloaded SD
cards will be available from the RPi Shop. This guide will assume you have preloaded SD
card.
5
Voice Control Home Automation Using Raspberry Pi
Display
There are two main connection options for the RPi display, HDMI (high definition)and
HD TVs and most LCD Monitors can be connected using a full-size 'male' HDMIcable,
and with an inexpensive adaptor if DVI is used. HDMI versions 1.3 and 1.4 are
supported, and a version 1.4 cable is recommended. The RPi outputs audio and video via
HDMI, but does not support HDMI input.
Older TVs can be connected using Composite (a yellow-to-yellow cable) or via SCART
(using a Composite to SCART adaptor). PAL and NTSC TVs are supported. When using
composite video, audio is available from a 3.5mm (1/8 inch) socket, and can be sent to
your TV, headphones, or to an amplifier. To send audio your TV, you will need a cable
which adapts from 3.5mm to double (red and white) RCA connectors. Using an HDMI to
DVI-D (digital) adaptor plus a DVI to VGA adaptor will not work. HDMIdoes not supply
the DVI-A (analogue) needed to convert to VGA - converting an HDMI or
DVI-D source to VGA (or component) needs an active converter. The lack of VGA has
been acknowledged as a priority issue.
Power Supply
The unit uses a Micro USB connection to power itself. A standard modern phone charger
with a micro-USB connector will do, but needs to produce at least 700mA at 5 volts.
Check your powersupply's ratings carefully. Suitable mains adaptors will be available
from the RPi Shop andare recommended if you are unsure what to use.
Keyboard & Mouse
Most standard USB keyboards and mice will work with the RPi. Wireless
keyboard/mouse should also function, and only require a single USB port for an RF
dongle. In order to use aBluetooth keyboard or mouse you would need to use a Bluetooth
dongle, which again uses a single port.
Remember that the Model A has a single USB port and the Model B only has two
(typically keyboard and mouse will use a USB port each).
6
Voice Control Home Automation Using Raspberry Pi
You can use a range of other power sources (assuming they are able to provide enough
current ~700mA):
Computer USB Port or powered USB hub (will depend on power output)
Mobile Phone Backup Battery (will depend on power output) (in theory confirmation)
To use the above, you'll need a USB A 'male' to USB micro 'male' cable - these are
oftenshipped as data cables with MP3 players.
Cables
You will probably need a number of cables in order to connect your RPi up.
HDMI-A or Composite cable, plus DVI adaptor or SCART adaptor if required, toconnect
your RPi to the Display/Monitor/TV of your choice.
Ethernet/LAN Cable.
Android controlled Smart Home Automation should be able to control the home
appliances wirelessly with effectively and efficiently.
To develop an application that includes the features of switches and voice mode
application. Switch Mode or Voice Mode can be used to control the switches of home
appliances.
To receive the quality video from the camera to the android application.
7
Voice Control Home Automation Using Raspberry Pi
Secure Connection Channels between Application and Raspberry pi
Use of secure protocols over Wi-Fi so that other devices cannot control the appliances.
Options for secure connection is SSL over TCP, SSH
To make the home appliances flexible in control, any device capable of Wi-Fi
connectivity will able to control the home appliances from remote locations.
The application is to be highly extensible, with possibility of adding features in the future
as needed.
1.4 Scopes
The project aims at designing a prototype for controlling the home appliances that can be
controlled wirelessly via an application that provides the features of speech recognition,
video streaming, and switch mode. An application is run on android device. The system
can be used in a wide range of areas.
The system integrated with different features can be applied in the following fields.
The system can be used in home, small offices to the big malls
The system can be used from home to offices to control the electrical appliances.
The home/office appliances can be controlled in intra-network or can be accessed via the
internet.
For the development of technology friendly environment
The system incorporates the use of technology and making smart home automation. By
the use of day to day gadgets we can utilize them for different prospective.
8
Voice Control Home Automation Using Raspberry Pi
Interfacing Wireless Adapter to Raspberry pi.
Interfacing relays with ac and dc power sources.
Using Transistor as a Switch.
Embedded programming.
This project constituted development of application as its major part as well as the
hardware to control home appliances. Management of any project has several steps or
processes in it. So, our projects can be described under the following steps-:
9
Voice Control Home Automation Using Raspberry Pi
Experimentation
In this step, we were discussing about the necessary equipments and materials. We were
studying about the similar projects, gathering the information of programming language
to be used. We were developing simple algorithms and flowcharts.
Design
In this phase, we were designing the layout of the application. The necessary
features to be included. We were designing the power strip to connect the home
appliances that can be controlled via GPIO pins.
In this phase, the development of application was performed. The bugs were
identified and removed. We consulted many software experts for the evaluation
of our application. Hardware design includes the design of power strip.
1.7 The Importance of the Raspberry Pi
10
The original goal of the Raspberry Pi (Rpi) was to get inexpensive computers into the
hands of kids, so they could tinker and learn to code. Since it’s inception it has been
picked up by engineers, designers, and everybody inbetween. But did they succeed at
their original goal?
I’ve been unable to find solid figures on the number of RPis finding their way into
schools and the hands of children, however they have now sold over five million, so
presumably at least some of these are reaching the intended market.
I do think it’s very important that children get their hands on RPis, and here’s the reason
why.
When my family got our first computer it was something we all used, and was in the
lounge, and later the dining room. It wasn’t something you messed around with — if the
computer was put out of comission through a hack gone wrong, it would’ve meant my
sister couldn’t have done her homework for example. The computer was an appliance.
You used it, but certainly didn’t experiment with it.
I’ve heard stories from people who enjoy coding, who recount how they got their first
computer at an early age, and that really turned them on to programming. I think that was
a very priviledged situation, at least until recently. A lot of the tech entrepreneurs who
have shaped the internet in the last decade or so were programming from a young age.
They may have been programming for a decade before starting their first companies in
their early twenties.
The RPi gives all children the opportunity to experiment with programming. ARPi costs
around £25, but realistically you need a screen, keyboard, mouse, power supply, and SD
card to really get going. At a push you could do that for around £100. That’s an order of
magnitude less than what computers were selling for a decade ago. And if something
breaks, so what — aRPi can be replaced inexpensively.
In 5 to 10 years time, I think there will be a flood of young programmers, who cut their
teeth from a young age. Anyone who wants to learn to program can now learn.
11
Voice Control Home Automation Using Raspberry Pi
CHAPTER-2
2. Literature Review
As per our survey, there exist many systems that can control home appliances using
android based phones/tablets. Each system has its unique features. Currently certain
companies are officially registered and are working to provide better home automation
system features. Following models describes the work being performed by others.
Having explained the model for home automation using bluetooth via PC. But
unfortunately the system lacks to support mobile technology.
Having designed a prototype electrical device control system using Web. They also set
the server with auto restart if the server is currently down.
Having developed a telephone and PIC remote controlled device for controlling the
devices pin check algorithm has been introduced where it was with cable network but not
wireless communication.
Having developed an application in a universal XML format which can be easily ported
to any other mobile devices rather than targeting a single platform.
Each of these systems has their own unique features and in comparison to one another
lacks some advancement.
Our designed system has application layer prototype. The application is able to
synthesize the speech data with the help of Google Voice Reorganization. The
synthesized data are analyzed and further processing is carried out. In layman words, our
design system provides features of controlling the home appliances using voice
commands.
The use of socket programming is performed to connect the android application with the
raspberry pi. This further adds security to our system. The data are received only by the
server at the specified port and data are further analyzed. Our project is different in a
sense it has its own software level application to control the home appliances.
12
Voice Control Home Automation Using Raspberry Pi
CHAPTER-3
Circuit of this project is very simple, which contains Raspberry Pi 3 Board, LEDs and
Bluetooth Module (HC-06). Raspberry Pi reads the Bluetooth Module and control the
LEDs accordingly. LEDs Blue, Red and Green are connected at GPIO 17, 27 and 22. Rx
and Tx of Bluetooth Module are directly connected to Tx and Rx pins of Raspberry Pi.
Remaining connections are shown in circuit diagram.
13
Voice Control Home Automation Using Raspberry Pi
We are using Python language here for the Program. Before coding, user needs to
configure Raspberry Pi.
After that you need to run following commands to run latest updates on Raspbian Jessie:
import serial
14
Voice Control Home Automation Using Raspberry Pi
importRPi.GPIO as GPIO
importos, time
led1=17
led2=27
led3=22
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(led1, GPIO.OUT)
GPIO.setup(led2, GPIO.OUT)
GPIO.setup(led3, GPIO.OUT)
GPIO.output(led1 , 0)
GPIO.output(led2 , 0)
GPIO.output(led3 , 0)
data1=""
data=''
while 1:
data = Serial.read(1)
data1+=data
print data1
GPIO.output(led1 , 1)
15
Voice Control Home Automation Using Raspberry Pi
if data1.find("red light off")>0:
GPIO.output(led1 , 0)
GPIO.output(led2 , 1)
GPIO.output(led2 , 0)
GPIO.output(led3 , 1)
GPIO.output(led3 , 0)
GPIO.output(led1 , 1)
GPIO.output(led2 , 1)
GPIO.output(led3 , 1)
GPIO.output(led1 , 0)
GPIO.output(led2 , 0)
GPIO.output(led3 , 0)
16
Voice Control Home Automation Using Raspberry Pi
print "All Light Off"
if data1.find("blink")>0:
GPIO.output(led1 , 1)
GPIO.output(led2 , 1)
GPIO.output(led3 , 1)
time.sleep(0.1)
GPIO.output(led1 , 0)
GPIO.output(led2 , 0)
GPIO.output(led3 , 0)
time.sleep(0.1)
Serial.flush();
data="";
data1="";
The android OS provides the flexibility of using the open source. The inbuilt sensors can
be accessed easily. We have built an application with following features. Android Phone
acts as a client and data are sent via sockets programming.
Switch Mode
Voice Mode
Video Mode
Switch mode uses the radio buttons that are used to control the home appliances. The
radio button sends the status of the switch.
17
Voice Control Home Automation Using Raspberry Pi
Voice Mode is used to control the home appliances using voice command. Using the
inbuilt microphone of Smartphone, the application creates an intent that fetches the
speech data to the Google server which responds with a string data. The string data are
further analyzed and then processed.
Video Mode shows the video stream of the room. The captured video is streamed at the
android application.
All the devices are connected to a common network. Smartphone, raspberry pi and IP
camera are connected to the common network Router is used to create a common
network.
Inbuilt Microphone and Mic. These provide two way communications between remote
user and the person standing in front of a camera.
Alarm Service Setting provides the features of alarm while detecting unauthorized
movement of user.
File Transfer Protocol Setting and Email Setting Provides the features of emailing the
video stream or images at the regular interval of time.
3.4 Advantages of Bluetooth over other wireless technologies like Wifi and ZigBee:
Bluetooth is generally used for point to point networks and Bluetooth operates at a much
slower rate of around 720 Kbps which is very small for video transfer or moving large
amounts of data like the image captured from a camera, whereas the bandwidth of Wi-Fi
can be up to 150Mbps and very ideal for video transmission. Wi-Fi is very much secure
means of communication than Bluetooth.
Wi-Fi connection to send video, audio, and telemetry operation, while accepting remote
control commands from an operator who can be located virtually anywhere in the world.
18
Voice Control Home Automation Using Raspberry Pi
Robots are already being eyed for obvious tasks like conducting search-and rescue
missions during emergencies or hauling gear for soldiers in the jungle or woods. The
mechanics of the robot uses the concept that has been developed to ensure robust
navigation, search and transportation in rough terrain.
19
Voice Control Home Automation Using Raspberry Pi
CHAPTER-4
4.Hardware Environment
Raspberry Pi as the controller for its processing power and large developer community.
4 relays are connected to power strips.
To build the android application to receive the live video feed from the camera and to
send the control signals to control the robot.
RPI-GPIO library GPIO interface library for the Raspberry Pi.
Application Description:
Application Consists of Graphical User Interfaces. It consists of following different
activities.
20
Voice Control Home Automation Using Raspberry Pi
Figure 4.2.1: Start Mode Activity Figure 4.2.2: Option Mode Activity
21
Voice Control Home Automation Using Raspberry Pi
4.2.1 Start Mode Activity:
In this mode, all the rooms of the home are displayed. The user can select the necessary
room from the option to control the appliances connected to specified room.
This mode provides the user for the option to control. The user can select either switch
mode or voice mode to control the appliances.
This mode provides the user to give the speech feedback to the application. The speech
data are processed and required appliances are controlled.
Figure 4.2.3: Voice Mode Activity Figure 4.2.4: Switch Mode Activity
22
Voice Control Home Automation Using Raspberry Pi
4.2.4 Switch Mode Activity:
This mode provides the user with on/off buttons to control the required home appliances.
This mode displays the video of the IP cameras connected at the rooms of the home.
23
Voice Control Home Automation Using Raspberry Pi
CHAPTER-5
5.Hardware and Programming Language Description
The power strip is designed and relays are connected to a power strip. The home
appliances are connected to the power strip. The Relays are connected to the GPIO pins
of the raspberry pi.
24
Voice Control Home Automation Using Raspberry Pi
5.2 Software Description
We have used two different programming languages for our project. For the development
of the application on android, we have used Java Platform. Android Software
Development kit incorporates Eclipse software where Java programming is performed.
Eclipse software is used to write the codes for the application under Java Platform.
Raspbian OS is used at the raspberry pi. Server is established at raspberry pi. Python
Language is used to write the codes of server, and to control the GPIO Pins of OS.
5.2.1 Java:
Java is a set of several computer software products and specifications from Oracle
Corporation that provides a system for developing application software and deploying it
in a cross-platform computing environment. Java is used in a wide variety of computing
platforms from embedded devices and mobile phones on the low end, to enterprise
servers and supercomputers on the high end.
5.2.2 Python:
5.2.3 Raspbian:
Raspbian is a free Operating System based on Debian optimized for the raspberry pi
hardware. Raspbian comes with more than 35000 packages; pre-combined software
bundled in a nice format for easy installation on Raspberry pi.
25
Voice Control Home Automation Using Raspberry Pi
Part List with Cost Estimation
1 1500 Available
WiFi Adapter
SD card 8GB(bigger size) 1 1000 Available
26
Voice Control Home Automation Using Raspberry Pi
CHAPTER-6
6.1 Scope and Application
This system is designed to assist and provide support in order to fulfill the needs of
elderly and disabled at home. Household appliances can be easily controlled via a
Mobile/Tablet. Status of light, fan and other electrical appliances can be known. With the
help of IP camera, video of rooms or certain areas of a house can be recorded. This helps
to provide security.
6.2 Limitations
Android devices having lower API version than 16 requires internet access to convert the
speech data to string data. Currently, the application is made for Android Smartphones;
other OS platform doesn’t support our application.
During voice mode, external noises (voice) may affect our results. The speech instruction
that we command in our voice mode may not give exact result as expected.
Looking at the current situation we can build cross platform system that can be deployed
on various platforms like iOS, Windows. Limitation to control only several devices can
be removed by extending automation of all other home appliances. Network can be
connected to internet and Security cameras can be controlled from other places, allowing
the user to observe activity around a house or business. Security systems can include
motion sensors that will detect any kind of unauthorized movement and notify the user.
Scope of this project can be expanded to many areas by not restricting to only home.
27
Voice Control Home Automation Using Raspberry Pi
CHAPTER-7
Conclusion:
The prime objective of our project is to use the Smartphone to control the home
appliances effectively. The switch mode and voice mode are used to control the home
appliances. The video feedback is received in the android app which streams the video of
IP- Camera.
This project is based on the Raspberry pi, Android platform Java and Python. These
platforms are Free Open Source Software. So the overall implementation cost is low and
can be easily configured.
User can easily interact with the android phone/tablet. The user can send commands via
the switch mode or speech mode. The data are being analyzed by the application and are
sent over a network. The Raspberry pi acts as a server, analyses the data and activates the
GPIO (General Purpose Input Output) Pins. The GPIO Pins are connected to the relays
switch which activated the required home appliances.
In this way, automation process is carried out. This is a simple prototype. Using this as a
reference further it can be expanded to many other programs.
28
Voice Control Home Automation Using Raspberry Pi
8. References
1. https://docs.python.org/
2. http://developer.android.com/training/index.html
3. http://elinux.org/RPi_Hub
4. http://www.raspberrypi.org/
5. http://stackoverflow.com/
6. http://electronics.howstuffworks.com/
7. N. Sriskanthan and Tan Karand. “Bluetooth Based Home Automation System”.
Journal of Microprocessors and Microsystems, Vol. 26, pp.281-289, 2002.
8. Muhammad IzharRamli, MohdHelmyAbdWahab, Nabihah, “TOWARDS
SMART HOME: CONTROL ELECTRICAL DEVICES ONLINE”
9. Nornabihah Ahmad International Conference on Science and Technology:
Application in Industry and Education (2006)
10. E. Yavuz, B. Hasan, I. Serkan and K. Duygu. “Safe and Secure PIC Based
Remote Control Application for Intelligent Home”. International Journal of
Computer Science and Network Security, Vol. 7, No. 5, May 2007
11. AmulJadhav, S. Anand, NileshDhangare, K.S. Wagh “Universal Mobile
Application Development (UMAD) On Home Automation” MarathwadaMitra
Mandal’s Institute of Technology, University of Pune, India Network and
Complex Systems ISSN 2224-610X (Paper) ISSN 2225-0603 (Online) Vol 2,
No.2, 2012
29