johnny-five
Version:
The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!
37 lines (31 loc) • 1.42 kB
JavaScript
var five = require("../");
var board = new five.Board();
board.on("ready", function() {
var multi = new five.Multi({
controller: "MPL3115A2",
// Change `elevation` with whatever is reported
// on http://www.whatismyelevation.com/.
// `12` is the elevation (meters) for where I live in Brooklyn
elevation: 12,
});
multi.on("change", function() {
console.log("temperature");
console.log(" celsius : ", this.temperature.celsius);
console.log(" fahrenheit : ", this.temperature.fahrenheit);
console.log(" kelvin : ", this.temperature.kelvin);
console.log("--------------------------------------");
console.log("barometer");
console.log(" pressure : ", this.barometer.pressure);
console.log("--------------------------------------");
console.log("altimeter");
console.log(" feet : ", this.altimeter.feet);
console.log(" meters : ", this.altimeter.meters);
console.log("--------------------------------------");
});
});
// @markdown
// - [MPL3115A2 - I2C Barometric Pressure/Altimiter/Temperature Sensor](https://www.adafruit.com/products/1893)
// - [SparkFun Altitude/Pressure Sensor Breakout - MPL3115A2](https://www.sparkfun.com/products/11084)
// - [SparkFun Weather Shield](https://www.sparkfun.com/products/12081)
// - [SparkFun Photon Weather Shield](https://www.sparkfun.com/products/13630)
// @markdown