Share Octave applications - box opening alarm (light sensor)

Hi there,

Playing with Octave since the general availability in October, many of us did come up with a numerous of sample apps that I’m suggesting the share here, in Octave forum.

Here’s a very simple first app, “box opening alarm” using a mangOH Yellow in a dark box and its light sensor to detect whenever the box is opened. Upon box opening detection, the light level is detected ubove some threshold and the app sends light values to the cloud and turns the buzzer ON on mangOH Yellow.

Feel free to try it and comment below!

Prerequisites
Before starting, make sure you already followed the getting started with mangOH Yellow and Octave: https://mangoh.io/mangoh-yellow-resources-getting-started

Octave concepts used
In this application, I’m using the following Octave components:

Implementation

1. Resources

Enable the light resource:

  • light/enable: true

2. Observations


3. Edge Actions

function(event) {

  // Reads a value from the light sensor right away
  var light = Datahub.read("/light/value", 0);
  light = light ? light.value : 0;

  // Is light above the detection threshold?
  var alarm = light > 1.0;

  return {
	"dh://buzzer/enable": [alarm],
	"dh://buzzer/percent": [60],
	"dh://buzzer/period": [1]
  }
}

Make sure to enable your edge action, and check the Streams for light values while the mangOH Yellow buzzer is ON. You can now tune your threshold value in the edge action and the light_to_cloud observation.

Does this simple app run well for you? Let me know in the comments! Enhancements proposals are welcome too!

Feel free to share your own app in a new topic! (please mention what device your Octave app is using (mangOH Red, mangOH Yellow, FX30, etc…)

Nice work ! Great to see an octave app implementation.

If you want to see another simple application, let’s click on that link below:
share-octave-applications-c02-alarm

1 Like