“Ok Google, close the cover of trash can!”

Controlling a trash can by just saying “Ok Google, close the cover of the trash can!”

What’s this?

GoogleHome already has integration with IFTTT, which has Webhooks integration. Therefore, we used IFTTT to control an obniz.

An obniz has a messaging API. It is easy to send message from any other webservices to obniz. Add Webhooks to obniz on IFTTT. That makes GoogleHome integration as easy as possible.

Materials

  • obniz x1
  • power supply for obniz x1
  • Servo Motor x1
  • Trash can x1

Steps

Step 1

Wire a Servo Motor and an obniz like the table and the image below.

obniz Servo Motor
0 GND
1 Vcc
2 signal

Then, supply power to your obniz.

Step 2

Add Webhook on IFTTT.

Step 3

Write a program below. At the end, run it on HTML.

Program

<!-- HTML Example -->
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script src="https://unpkg.com/obniz@2.0.2/obniz.js"></script>
</head>

<body>
<div id="obniz-debug"></div>
<br>
<div class="text-center">
  <h1> Talk with google home </h1>
</div>

<div id="text">
  <ul>
    <li>Open the trash</li>
    <li>Close the trash</li>
  </ul>
</div>

<script>

/* This will be over written on obniz.io webapp page */
var obniz = new Obniz("OBNIZ_ID_HERE");

obniz.onconnect = async function () {
  var servo = obniz.wired("ServoMotor", {gnd:0, vcc:1, signal:2});
  obniz.onmessage = function(message, from) {
    if(message === "googlehomeOpen"){
      obniz.display.clear();
      obniz.display.print("open the trash");
        servo.angle(80.0); 
    }
    if(message === "googlehomeClose"){
      obniz.display.clear();
      obniz.display.print("close the trash");
      servo.angle(0.0); 
    }
  };
}
    
</script>
</body>
</html>
 

 

 

Recommended