obniz developer team
Published © GPL3+

Google Home - Automatic Trash Can

"OK Google, open the trash!" By integrating obniz with Goole Home, your trash can will open/close automatically.

BeginnerFull instructions provided4 hours2,126

Things used in this project

Hardware components

obniz
Cambrian Robotics obniz
available at amazon.com
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Battery or USB adaptor & cable
×1
Battery
Battery or USB adaptor & cable
×1
Adafruit Servo motor
×1
Trash can
×1

Software apps and online services

Assistant SDK
Google Assistant SDK
Maker service
IFTTT Maker service
Webhooks

Story

Read more

Code

Program

HTML
HTML & Javascript
<!-- 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@1.9.1/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>

Credits

obniz developer team

obniz developer team

80 projects • 32 followers
Development board "obniz" is controlled via the internet.

Comments