Automate your gadgets with Voice Assistant on your smart phone in 4 simple steps

bensalcie
6 min readAug 12, 2020

Hello great friend, delighted that you landed on this tutorial.
In this tutorial, I will be showing you how to create your own Home Automation system with Google Voice Assistant on your phone.
If you are tech-savvy, you probably have heard of terms like ‘Google Home’, ‘Amazon Alexa’ just to mention a few. We will be focusing on the cheapest way possible to achieve this and save a few dollars. You will be able to customize this project to fit all your home appliances' needs, be it remote switching, lighting, cooking, etc.

Let's get into it!!!.

Before you get to this tutorial, you should be having a basic understanding of

Arduino
C++ (Embedded C++)
have worked with electronics.

Prerequisites.

1.Arduino IDE
2.Node MCU(Wifi Board)
3.Four-channel Relay
4.Jumper Wires (Any)
5.Your Phone
6.AC Bulb with plug (For testing)

First things first, before you begin developing for Node MCU with arduino IDE, you can follow a quick tutorial over here.

With this, you will be able to write code to the Node MCU just the same way you would for Arduino Micro-controller. I hope up to here you are good and set to get ourselves into deeper implementations. (Just make sure you install it correctly and that you ain’t getting any error)

Step 1: Create an account on adafruit

For this tutorial, we will be using two Web services to help us to get instructions from Google’s Natural Language Processing into our Microcontroller. So head over to https://io.adafruit.com. Create your account and verify.

Next, click on the Dashboard tab, you will meet “Welcome Dashboard”, this dashboard will enable us to create trigger actions for our board. Go ahead and click on “Actions”, create a new Dashboard Called “IOT Google Assistant Home Automation” > Click on the plus (+) button on your right. Here is where we will be adding our actions. In our context we will be adding a toggle action, so select on/off. It should appear like this:

Enter the name of the feed as Relay1, then hit create.Tick it then click Next, Here is where we specify the data to be sent to our board. (Text on button Write 1, and 0) They will be used to simulate our actions. Repeat the same process for the four Relays
and it should be like this:

Step 2:Configureyouractions

Head over to IFTT (If This Then That)

Create your account, if you haven’t done it yet. This second service will help us to listen to instructions from our voice assistant and relay those instructions to our Adafruit IO (The previous service we created).

You will meet this screen with “If This Then That”, SO hit on “If + “, Search for Google Assistant -> Say a simple Phrase, You will meet some input fields, these fields will enable us to train our assistant to learn our instructions. So type in anything that you feel will be comfortable for your appliances: For my case, I filled in as shown:

Click trigger.
You will be redirected to the previous page of “IF THIS THEN THAT”, this time around you will see the first “if +” has been replaced with Google Assitant Icon. If that's so, then we are on the right track.
Next, click on the “+That”, the search for Adafruit-> Send Data to Adafruit IO, You will then be taken to the feed page, where you will see the feeds we already created for adafruit IO. Select the first one, Data to save write :1, this means when you say “Bedroom lights on, it will send to adafruit a value of 1”.

We will repeat the same process, for the off to send a value of 0. Tap on your account avatar hit “Create”, Repeat the same process, but this time with the reverse of the previous commands. Select the same relay (Relay1) but this time the data to send it 0, for of.

Do this process for Relay2,3 and 4 Respectively attaching any action that you wish. When you click on my applets, you should have something close to this:

This was a hectic trivial one!!, if you made it …Congratulations!!!

Step 3
Once we have set up those, the rest will be a walk in the park.
Open up your Arduino IDE, download the Afafruit Library for Adruino Here.

https://github.com/bensalcie/Aysal-Tech-Voice-Remote-Control/blob/master/Adafruit_MQTT_Library-master.zip

Step 4
Create an empty Arduino Project and Write/Paste the following code.

As you can see in the code, you will need to provide parameters such as your Wifi name and password, please write them accordingly.
On the Adafruit Key and User name, you can find them on your Adafruit IO dashboard when you click “Adafruit IO Key”

What the code does, is to listen to any form of communication between your assistant and Adafruit IO, the response is then sent to our Microcontroller inform on 1/0 this is the language that micro-controller will understand.
I hope up to here you went success as well.

Step 4 (Wiring and Circuitry)
We will be using D0-D4 of our nodemcu and they will be connected to our 4-Channel Relay.

Finally
Power Your node MCU with any phone charger, (5V 3A) or using your pc. Connect to your wifi using the same username and password as in the code. Make sure to select the same email you used in the Adafruit and IFTT on your phone voice assistant.

You can now test and implementing your voice commands, for my case when I say “Bedroom Lights on”, it will trigger my relay right away.

That’s the end of our tutorial, I hope you enjoyed it.

--

--

bensalcie

Passionate; App,Arduino and IOT developer 📱📟🔋🔌. Currently an Android / IOS Developer at Kodally.