Back to Johnny Five

Altimeter - MPL3115A2

docs/altimeter-mpl3115a2.md

2.1.01.7 KB
Original Source
<!--remove-start-->

Altimeter - MPL3115A2

<!--remove-end-->
MPL3115A2

Fritzing diagram: docs/breadboard/barometer-mpl3115a2.fzz

 

Run this example from the command line with:

bash
node eg/altimeter-mpl3115a2.js
javascript
const { Altimeter, Board } = require("../");
const board = new Board();

board.on("ready", () => {
  const altimeter = new Altimeter({
    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
  });

  altimeter.on("change", () => {
    const {feet, meters} = altimeter;
    console.log("Altimeter:");
    console.log("  feet         : ", feet);
    console.log("  meters       : ", meters);
    console.log("--------------------------------------");
  });
});



Additional Notes

Learn More

 

<!--remove-start-->

License

Copyright (c) 2012-2014 Rick Waldron [email protected] Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.

<!--remove-end-->