Cloud Execution by device trigger

Cloud execution can be triggered by triggers related to the installed device.

  • The device is now online.
  • The device has been switched on (obniz Board / 1Y and M5tickC only)

You can choose a trigger such as.

You can create an IoT device using a switch as a trigger for other hardware or APIs.

Also, you can use device online as a trigger for the sleep function of obniz board 1Y. Sleep=>Wake=>Run=>Run program in cloud=>Sleep again.

see documentation

Configuration and Execution.

Go to "Cloud Execution" in the app settings and check the one you want to use.
By installing that app, you can run the app in the cloud based on the device's triggers.

For example, you can make a motion to hit a URL just by pressing a switch.

if (Obniz.App.isCloudRunning()) {
  // move a motor for 1 second.
  try {
    fetch(`https://xxxxx/xxxx`)
  } catch(e) {
    console.error(e);
  }
  Obniz.App.done({
    status: 'success',
    text: `Pressed`
  })
}

Or it can be run intermittently in this way in combination with the sleep of obniz Board 1Y.

if (Obniz.App.isCloudRunning()) {
  // move a motor for 1 second.
  var motor = obniz.wired("DCMotor",  {forward:0, back:1});
  motor.forward();
  await obniz.wait(1000);
  // sleep 1 hour
  obniz.sleepMinute(60);
  Obniz.App.done({
    status: 'success',
    text: `Worked and Sleeped`
  })
}