Introduction: Google Home Controlled Power Outlet

Picture of Google Home Controlled Power Outlet

My girlfriend always wanted to build a smart home.

So we build the infrastructure and first item of the smart home, a remote controlled outlet switch that you can control using a control panel or using voice commands (if you have google home or google assistant)

Here you can find step by step of what we did.

Step 1: Required Component

Step 2: Setup the PI

Picture of Setup the PI

First thing that we need is a server for your smart home .

This server will host your smart home control panel , and will link the control panel to the smart home items.

The easiest way to setup the server is using the openhabian PI image for RaspberryPI .

You can find the complete instruction on openhab website

Step 3: Program Your Microcontroller (WiFi Module)

Picture of Program Your Microcontroller (WiFi Module)

The cool thing about the microcontroller part of this project is that we are using a WiFi module that have a microcontroller in, so you can write your program using arduino and upload your program to the microcontroller of the WiFi module.

I am using a very basic program for my project so if I call the http://IP_ADDRESS_OF_THE_MODULE/on will turn on relay pin 1 and http://IP_ADDRESS_OF_THE_MODULE/off will turn the relay pin 0.

I also add some fancy code to make the RGB led of the board red if the relay is off and green if it is on and flashing red while connecting to wifi and .5 second green after connection successful.

NOTE:

  1. How to configure arduino IDE to program esp8266
  2. You have to hold flash button of the esp8266 board before programming and release that immediately after you see the small blue led of the wifi board flashed once.
  3. The module should connect to 2.4 GHz wifi and can't connect to 5 GHz networks.

Step 4: Configure Openhab to Send On/Off Requests

Picture of Configure Openhab to Send On/Off Requests

You should be able to access you OpenHab control panel using http://openhabianpi:8080 url.

We will use HTTP binding so you have to install that on your openhab

  • Go to paperUI on your openhabianpi
  • Configuration>Bindings add HTTP binding

Time to configure your openhab,

  1. ssh to your openhab box using [ssh openhabian@openhabianpi]
  2. Go to openhab items folder [cd /etc/openhab2/items]
  3. Read the readme file ! [cat readme.txt]
  4. Create your items file [light2.items]
    • content of my items file is
      • Switch Kitchen_Light "Kitchen Light" {http=">[ON:GET:http://192.168.1.132/on] >[OFF:GET:http://192.168.1.132/off]"}
    • read it like :
      • Swith NAME_OF_THE_SWITCH "LABEL OF THE SWITCH" {BINDING_TYPE=">[COMMAND:METHOD:URL_TO_FETCH] .... " }
        • NAME_OF_THE_SWITCH is just a name

        • LABEL OF THE SWITCH is what you will see in the panel (I am not using that in my panel)

        • BINDING_TYPE is the binding that we use (HTTP here)

        • > is for output (< is for input, let say read temperature in another project)

        • COMMAND is the command name (I picked OFF)

        • METHOD is the call method (GET or POST)

        • URL_TO_FETCH is the url that we want to fetch to perform the command

  5. If previous step is not clear, go back to step 3 !
  6. Go to habpanel http://openhabianpi:8080/habpanel/index.html#/ and add some button to the panel

What is happening here is we define a http binding for the OpenHab to Arduino module , so when you trigger that switch it will fetch that url .

Step 5: Link Your Openhab to the Cloud

Picture of Link Your Openhab to the Cloud

Create an account in https://myopenhab.org website, you will require UUID and secret from your openhab

To get those values you have to install "openHAB Cloud connector" from http://openhabianpi:8080/paperui/index.html#/exten... ->MISC and restart your openhab.

https://docs.openhab.org/addons/ios/openhabcloud/r...

  • to see those values
    • cat /var/lib/openhab2/uuid
    • cat /var/lib/openhab2/openhabcloud/secret

Step 6: Link Your Openhab to Your Google Assistant (IFTTT)

Now it is time to link your openhab to google assistant, so we can say "Hey google, turn on the light" and it will send your message to openhab and as result some fancy smart thing will happen in your home.

We are using IFTTT to link the google assistant to openhab

Let's do that

  1. Create/Login to your account in IFTTT
  2. Create a new applet
  3. For "THIS" pick "Google Assistant" and "Say a simple phrase" and pick what is your voice commands and voice response (like "Hey google turn on the light") .
  4. For "THAT" pick "openHAB" and "send a command" then select your item and the command (remember the ON and OFF commands in binding part ? it should be same value )
  5. Finish.
  6. Now scream "Hey Google." and "Turn on the light" , look at your board, it should do something (The RGB led should turn green)
  7. You are done,

Step 7: Wiring the Things Together

Picture of Wiring the Things Together

So far we should be able to turn on and off a pin from arduino using the panel and voice commands.

Next step is to wire everything together, so your arduino will send a signal to relay to connect and disconnect the power.

VERY IMPORTANT NOTE : Here we are using high voltage and you may burn yourself your house or kill yourself if do things wrong. so you have to be very careful or just ignore this part if you don't have any experience.

Step 8: The Box

Now it is time to put everything in a box, so find a box and put everything inside the box (make sure you are not making any short circuit).

We have a 3d printer at home, so I designed and print a the box for my kit.

TinkerCad Link

Step 9:

Picture of

Comments

KipA2 (author)2018-01-15

Nice work, if excessively complicating the end goal of having a Google Home Assistant switched outlet.

Swansong (author)2018-01-11

That's a neat setup :)

About This Instructable

1,401views

55favorites

License:

More by Amirm24:Google Home Controlled Power Outlet
Add instructable to: