Skip to content

Latest commit

 

History

History
83 lines (52 loc) · 1.45 KB

sensor-photon-weather-shield-moisture.md

File metadata and controls

83 lines (52 loc) · 1.45 KB

Photon Weather Shield: Moisture

Run this example from the command line with:

node eg/sensor-photon-weather-shield-moisture.js
var five = require("johnny-five");
var Photon = require("particle-io");
var board = new five.Board({
  io: new Photon({
    token: process.env.PARTICLE_TOKEN,
    deviceId: process.env.PARTICLE_PHOTON_1
  })
});

var period = process.argv[2] || 1000;

board.on("ready", function() {
  console.log("Connected");

  var moisture = new five.Sensor({
    pin: "A1",
    enabled: false
  });
  var power = new five.Pin("D5");

  moisture.on("data", function() {
    if (power.isHigh) {
      console.log("Moisture: ", this.value);
      power.low();
      moisture.disable();
    }
  });

  this.loop(period, function() {
    if (!power.isHigh) {
      power.high();
      moisture.enable();
    }
  });
});

Additional Notes

For this program, you'll need: Particle Photon SparkFun Photon Weather Shield SparkFun Soil Moisture Sensor

 

License

Copyright (c) 2012-2014 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.