Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
obniz developer team
Published

Power-saving watering device using the sleep function of...

Use the sleep function of the obniz board 1Y to create a program to water your plants regularly.

BeginnerFull instructions provided2 hours237
Power-saving watering device using the sleep function of...

Things used in this project

Hardware components

obniz
Cambrian Robotics obniz
×1
pump
×1

Story

Read more

Code

source code

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

    <link
      rel="stylesheet"
      href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
    />
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

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

  <body>
    <div id="obniz-debug"></div>
    <script>
      //Timeout 25s
      let tid = setTimeout(() => {
        //activated every 12 hours.
        obniz.sleepMinute(720);
      }, 25000);
      //-----------------------------
      // obniz setting
      //-----------------------------
      let obniz = new Obniz("OBNIZ_ID_HERE");
      obniz.onconnect = async () => {
        var motor = obniz.wired("DCMotor", { forward: 0, back: 1 });
        motor.forward();
        //move moter 10 minutes.
        await obniz.wait(10000);
        motor.stop();
        //activated every 12 hours.
        obniz.sleepMinute(720);
        //program finish wait...
        await obniz.wait(1000);
        clearTimeout(tid);
        if (typeof done === "function") {
          done();
        }
      };

    </script>
  </body>
</html>

Credits

obniz developer team
80 projects • 35 followers
Development board "obniz" is controlled via the internet.
Contact

Comments

Please log in or sign up to comment.