ModularSensors > Modules > Supported Sensors > Freescale Semiconductor MPL115A2

Freescale Semiconductor MPL115A2 module

Classes for the Freescale Semiconductor MPL115A2 digital barometer.

Introduction

The Freescale Semiconductor MPL115A2 is a low-cost, low-power absolute pressure sensor with a digital I2C output. It is optimized for barometric measurements. Because this sensor can have only one I2C address (0x60), it is only possible to connect one of these sensors to a single I2C bus. This sensor should be attached to a 2.375-5.5V power source and the power supply to the sensor can be stopped between measurements. Communication with the MPL115A2 is managed by the Adafruit MPL115A2 library.

Sensor Datasheet

Documentation for the sensor can be found at: https://www.adafruit.com/product/992 and https://github.com/adafruit/Adafruit-MPL115A2-Breakout-PCB

A copy of the datasheet is available here: https://github.com/EnviroDIY/ModularSensors/wiki/Sensor-Datasheets/Freescale-Semiconductor-MPL115A2.pdf)

Sensor Constructors

MPL115A2(int8_t powerPin, uint8_t measurementsToAverage = 1) explicit

Construct a new MPL115A2 using the primary hardware I2C instance.

Parameters
powerPin

The pin on the mcu controlling power to the MPL115A2 Use -1 if it is continuously powered.

  • The MPL115A2 requires a 2.375 - 5.5V power source
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.

MPL115A2(TwoWire* theI2C, int8_t powerPin, uint8_t measurementsToAverage = 1)

Construct a new MPL115A2 using a secondary hardware I2C instance.

Parameters
theI2C A TwoWire instance for I2C communication. Due to the limitations of the Arduino core, only a hardware I2C instance can be used. For an AVR board, there is only one I2C instance possible and this form of the constructor should not be used. For a SAMD board, this can be used if a secondary I2C port is created on one of the extra SERCOMs.
powerPin

The pin on the mcu controlling power to the MPL115A2 Use -1 if it is continuously powered.

  • The MPL115A2 requires a 2.375 - 5.5V power source
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.


Example Code

The Freescale Semiconductor MPL115A2 is used in the menu a la carte example.

#include <sensors/FreescaleMPL115A2.h>

const int8_t  MPLPower = sensorPowerPin;  // Power pin (-1 if unconnected)
const uint8_t MPL115A2ReadingsToAvg = 1;

// Create an MPL115A2 barometer sensor object
MPL115A2 mpl115a2(MPLPower, MPL115A2ReadingsToAvg);

// Create pressure and temperature variable pointers for the MPL
Variable* mplPress =
    new MPL115A2_Pressure(&mpl115a2, "12345678-abcd-1234-ef00-1234567890ab");
Variable* mplTemp = new MPL115A2_Temp(&mpl115a2,
                                      "12345678-abcd-1234-ef00-1234567890ab");

Classes

class MPL115A2
The Sensor sub-class for the Freescale Semiconductor MPL115A2 sensor.
class MPL115A2_Temp
The Variable sub-class used for the temperature output from a Freescale Semiconductor MPL115A2.
class MPL115A2_Pressure
The Variable sub-class used for the pressure output from a Freescale Semiconductor MPL115A2.

Defines

#define MPL115A2_NUM_VARIABLES = 2
Sensor::_numReturnedValues; the MPL115A2 can report 2 values.

Sensor Timing

The sensor timing for a Freescale MPL115A2

#define MPL115A2_WARM_UP_TIME_MS = 6
Sensor::_warmUpTime_ms; the MPL115A2 takes about 6 ms to respond.
#define MPL115A2_STABILIZATION_TIME_MS = 0
Sensor::_stabilizationTime_ms; the MPL115A2 is stable as soon as it warms up (0ms stabilization).
#define MPL115A2_MEASUREMENT_TIME_MS = 3
Sensor::_measurementTime_ms; the MPL115A2 takes 3ms to complete a measurement.

Temperature

The temperature variable from a Freescale MPL115A2

  • Range is -20°C to 85°C
  • Accuracy is not specified on the sensor datasheet

MPL115A2_Temp(MPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_TEMP_DEFAULT_CODE) explicit

Construct a new MPL115A2_Temp object.

Parameters
parentSense The parent MPL115A2 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "MPL115A2_Temp".

#define MPL115A2_TEMP_RESOLUTION = 2
Decimals places in string representation; temperature should have 2 - resolution is 0.01°C.
#define MPL115A2_TEMP_VAR_NUM = 0
Sensor variable number; temperature is stored in sensorValues[0].
#define MPL115A2_TEMP_VAR_NAME = "temperature"
Variable name in ODM2 controlled vocabulary; "temperature".
#define MPL115A2_TEMP_UNIT_NAME = "degreeCelsius"
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define MPL115A2_TEMP_DEFAULT_CODE = "MPL115A2_Temp"
Default variable short code; "MPL115A2_Temp".

Pressure

The pressure variable from a Freescale MPL115A2

  • Range is 500-1150 hPa
  • Accuracy ±10 hPa

MPL115A2_Pressure(MPL115A2* parentSense, const char* uuid = "", const char* varCode = MPL115A2_PRESSURE_DEFAULT_CODE) explicit

Construct a new MPL115A2_Pressure object.

Parameters
parentSense The parent MPL115A2 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "MPL115A2_Pressure".

#define MPL115A2_PRESSURE_RESOLUTION = 2
Decimals places in string representation; pressure should have 2 - resolution is 1.5 hPa.
#define MPL115A2_PRESSURE_VAR_NUM = 1
Sensor variable number; pressure is stored in sensorValues[1].
#define MPL115A2_PRESSURE_VAR_NAME = "atmosphericPressure"
Variable name in ODM2 controlled vocabulary; "atmosphericPressure".
#define MPL115A2_PRESSURE_UNIT_NAME = "kilopascal"
Variable unit name in ODM2 controlled vocabulary; "kilopascal" (kPa)
#define MPL115A2_PRESSURE_DEFAULT_CODE = "MPL115A2_Pressure"
Default variable short code; "MPL115A2_Pressure".