A simple, server-less program for regular watering.
Contents
Make things
We will create a program to water regularly and easily by using the obniz Board and serverless.

Materials
- obniz Board
- pump : Amazon
- hose
- plant
How to make
Hardware Connection
Connect the obniz to the pump as shown in the following table.
| obniz | pump |
|---|---|
| 0 | white |
| 1 | red |
Software
Register your obniz Board!
Go to the developer console in obniz and click on “Devices” → “Add Device”. When the dialog opens, click on “Use OBNIZ Official Device”. Follow the instructions on the screen to register.
▼

Let’s write a program.
Save the program to a repository for use in serverless events. Go to the developer console of obniz and select “Repository” → “New”.
A dialog will appear, and you can set it as follows
- Type : WebApp
- Access level : private
- File name : As you like (this time it’s REMOTE_WATER)
Once configured, click “Create”. Then, the program input screen will appear, and you can replace it with the next program.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Routine watering devices</title>
<script src="https://unpkg.com/[email protected]/obniz.js" crossorigin="anonymous"></script>
</head>
<body>
<script>
//-----------------------------
// obniz setting
//-----------------------------
let obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async () => {
var motor = obniz.wired("DCMotor", {forward:0, back:1});
motor.forward();
//10 seconds to move the motor.
await obniz.wait(10000);
motor.stop();
if(typeof done === "function"){
done();
}
}
</script>
</body>
</html>
When the program is ready, hover your mouse over the file name in the upper left corner, and click “Save” to display “Save”.
Configuring a Serverless Event
Serverless events are a feature that makes it easy to use obniz without having to prepare the servers that each one of you will need. From the obniz console, click on “Serverless Events” → “New”.
Let’s set them in order.
- Name : As you like (in this case, Remote_water_Event)
- WebApp to run : Name of the program you just saved
- Trigger : Repeat
- Event : 6 hour
Once you’re set up, click “Create”! Now you’re ready to go.
Excute
I started watering them once every 6 hours. I was able to build a watering device very easily using a serverless system.
You can easily create a serverless watering device like this one. You can change the sleep interval, even if it’s in a remote location, and you have the advantage of being able to easily update the program with a different kind of sensor replacement.