Skip to content

This is a firmware library for the MPL3115A2 on the SparkFun Photon Weather Shield.

License

Notifications You must be signed in to change notification settings

sparkfun/SparkFun_MPL3115A2_Particle_Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SparkFun MPL3115A2 Particle Library

Firmware library SparkFun's Photon Weather Shield and the MPL3115A2 Breakout.

About

This is a firmware library for SparkFun's Photon Weather Shield.

Photon Battery Shield.

The MPL3115A2 is a MEMS pressure sensor that provides Altitude data to within 30cm (with oversampling enabled). The sensor outputs are digitized by a high resolution 24-bit ADC and transmitted over I2C, meaning it’s easy to interface with most controllers. Pressure output can be resolved with output in fractions of a Pascal, and Altitude can be resolved in fractions of a meter. The device also provides 12-bit temperature measurements in degrees Celsius.

Repository Contents

  • /doc - Additional documentation for the user. These files are ignored by the IDE.
  • /firmware - Source files for the library (.cpp, .h).
  • /firmware/examples - Example sketches for the library (.cpp). Run these from the Particle IDE.
  • spark.json - General library properties for the Particel library manager.

Example Usage

Include the MPL3115A2 library:

#include "SparkFunMPL3115A2.h" // Include the SparkFun MPL3115A2 library

Then use the MPL3115A2 object to interact with it. Begin by initializing the IC:

MPL3115A2 baro = MPL3115A2();//create instance of MPL3115A2 barrometric sensor

void setup()
{
    Serial.begin(9600);   // open serial over USB at 9600 baud

    //Initialize
  	while(! baro.begin()) {
          Serial.println("MPL3115A2 not found");
          delay(1000);
     }
     Serial.println("MPL3115A2 OK");

    //MPL3115A2 Settings
    //baro.setModeBarometer();//Set to Barometer Mode
    baro.setModeAltimeter();//Set to altimeter Mode

    baro.setOversampleRate(7); // Set Oversample to the recommended 128
    baro.enableEventFlags(); //Necessary register calls to enble temp, baro ansd alt
}

Then you can read various data like this:

  baroTemp = baro.readTempF();//get the temperature in F

  pascals = baro.readPressure();//get pressure in Pascals

  altf = baro.readAltitudeFt();//get altitude in feet

Check out the example files in the examples directory for more guidance.

Recommended Components

License Information

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com.

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

About

This is a firmware library for the MPL3115A2 on the SparkFun Photon Weather Shield.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages