Multi-Language Voice Control IOT Home Automation System Using Google Assistant and Raspberry Pi

Ashwini kumar sinha

1590
Advertisement

Today, home automation using Internet of things (IoT) is one of the major domains which is attracting attention from large tech companies.

We all want to own a smart home, but sometimes language becomes a barrier in setting up IOT home automation system. Most of the existing home automation systems support only a few languages, generally English.

Wouldn’t it be nice if we can control our home with multiple languages like Hindi, Bengali, Marathi and so on?

Yes, it’s possible now! In this DIY project, we are going to make an IOT home automation system that will allow you to control your home with voice commands given in your preferred language.

Advertisement

This home automation system uses google assistant to control the smart devices at home. So, it also supports all the languages supported by the google assistant. We will also make an app to control the system.

 

Let’s start the project –

Bill of Material

Setting Raspberry Pi

The first thing we need to do is to set up an Apache server in Raspberry Pi. To do it, open the terminal window and run the following command.

sudo apt-get install apache2 -y

After successful installation of the server, we can check it by typing the I.P address of your Raspberry Pi in any web browser. If the server is working fine, we will get the Apache page in the web browser. Now, we will use our Apache server to process PHP Files, for this you need to have the latest version of PHP module for Apache. To get this module run this command –

sudo apt-get install php libapache2-mod-php -y

 

Next, we will create a PHP file to control the GPIO of Raspberry Pi. To do so, open terminal in Raspberry Pi and go to its html directory by  this command as you can see in Fig 1.

Fig 1. Creating php file from terminal

Next create a PHP file by using “sudo nano lightsoff.php” command

and write the following piece of code in it,

<?php

System    (“gpio -g mode 27 out”);

System   (“gpio -g write 27   0”);

?>

Then press Ctrl+X  to save and exit from the editor.

After this create a lightson.php file for turning the lights on and paste the following code in it.

<?php

System    (“gpio -g mode 27 out”);

System   (“gpio -g write 27   1”);

?>

Repeat the same process for controlling other GPIO of Raspberry Pi.

Fig 2. Code In PHP

You can download the whole code for turning lights on and off from the link below.

Setting Google Assistant

Now, we are going to prepare the google assistant for our voice command. First open the language settings of google assistant and select the language of your choice. Then open the google assistant settings and go to “Routines” option. You will get a plus floating button in the menu of Routines, click on that and then set the voice command that you want to create. For example, if you want to control lights, you can set the voice commands in your preferred language to turn on the lights. After this, set the action for that voice command in the given format (Refer Fig. 3,4,5,6,7)

“search Rpi IP address/ PHP file name”.

Search 192.168……../ lightsoff.php.

Fig 3. Setting language in google assistant.
Fig 4. Going to google assistant settings
Fig 5. Google assistant setting menu

 

Fig 6. Google assistant Routines setting
Fig 7. Google assistant command setting

Connection

Now connect the components as illustrated below.

Raspberry pi           Relay Board

GPIO 13                    Relay IN 1

GPIO 15                    Relay IN  2

5V                            Relay 5V

GND                          GND

 

Fig 8. Connection
Fig 9. Setting everything in enclosure

App Making

We can also create an app to control the lights. Let’s make the app.

Open Android studio and create a new project with bottom navigation bar and do coding as illustrated below (Refer Fig. 10 ,11,12,13,14).

First of all, set the permission in app to access the internet because we are going to use Wi-Fi to control GPIO of RPi.

Fig 10. Setting permission in manifest

Then go to Mainactivity.java and create a WebView and String variables as in the picture below.

Fig 11. Creating WebView
Fig 12. Creating code to load URLs of RPi server

Fig 14. Creating Navigation bar

Fig 13. Creating app layout.
Fig 14. Creating Navigation bar

Testing :

Power the Raspberry Pi with 5V DC. Then connect Raspberry Pi and your phone to your Wi-Fi network or you can also use phone HOTSPOT. Then say “hey google” followed by the voice command that we have set in our preferred language. For example, say “hey google light on kar do”

And it will turn on the lights. You can also control lights with the app we have just created. Open the app and press the icons in navigation to turn the lights on/off

DOWNLOAD

Advertisement


2 COMMENTS

  1. Howdy I am so grateful I found your webpage, I really
    found you by accident, while I was searcing on Google for something else,
    Anyways I am herre now aand would just ike to say thanks a lot for a
    fantastjc post and a all round interesting blog (I also love
    the theme/design), I don’t have time to read through
    it all at the moment but I have bookmarked iit and also added iin your RSS feeds, so when I have time I
    will be back tto read a lot more, Pleaae do keep up the excellent job.

  2. I have to express my appreciation to this writer just for rescuing me from such a
    matter. Right after scouting throughout the the web and finding proposals which are not beneficial, I assumed my entire life was gone.

    Living devoid of the answers to the issues you have
    resolved through your good blog post is a serious case, as well
    as those which might have negatively damaged my
    career if I hadn’t encountered your blog. The knowledge and
    kindness in controlling the whole lot was helpful. I don’t know what I
    would have done if I hadn’t come upon such a step like this.
    It’s possible to at this moment look forward to my
    future. Thanks so much for this reliable and result oriented guide.
    I will not hesitate to endorse your blog post to anyone who would like support about this
    area.

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here