Freescale Semiconductor MPL115A2 topic

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

FreescaleMPL115A2::FreescaleMPL115A2(int8_t powerPin, uint8_t measurementsToAverage = 1) explicit

Construct a new FreescaleMPL115A2 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.

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

Construct a new FreescaleMPL115A2 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.

1#include <sensors/FreescaleMPL115A2.h>
2
3// NOTE: Use -1 for any pins that don't apply or aren't being used.
4const int8_t MPLPower = sensorPowerPin; // Power pin
5const uint8_t MPL115A2ReadingsToAvg = 1;
6
7// Create a FreescaleMPL115A2 barometer sensor object
8FreescaleMPL115A2 mpl115a2(MPLPower, MPL115A2ReadingsToAvg);
9
10// Create pressure and temperature variable pointers for the MPL
11Variable* mplPress = new FreescaleMPL115A2_Pressure(
12 &mpl115a2, "12345678-abcd-1234-ef00-1234567890ab");
13Variable* mplTemp = new FreescaleMPL115A2_Temp(
14 &mpl115a2, "12345678-abcd-1234-ef00-1234567890ab");

Classes

class FreescaleMPL115A2
The Sensor sub-class for the Freescale Semiconductor MPL115A2 sensor.
class FreescaleMPL115A2_Temp
The Variable sub-class used for the temperature output from a Freescale Semiconductor MPL115A2.
class FreescaleMPL115A2_Pressure
The Variable sub-class used for the pressure output from a Freescale Semiconductor MPL115A2.

Typedefs

using MPL115A2 = FreescaleMPL115A2 deprecated in v0.33.0
typedef for backwards compatibility; use the FreescaleMPL115A2 class in new code
using MPL115A2_Temp = FreescaleMPL115A2_Temp deprecated in v0.33.0
typedef for backwards compatibility; use the FreescaleMPL115A2_Temp class in new code
using MPL115A2_Pressure = FreescaleMPL115A2_Pressure deprecated in v0.33.0
typedef for backwards compatibility; use the FreescaleMPL115A2_Pressure class in new code

Sensor Variable Counts

The number of variables that can be returned by the MPL115A2

#define MPL115A2_NUM_VARIABLES = 2
Sensor::_numReturnedValues; the MPL115A2 can report 2 values.
#define MPL115A2_INC_CALC_VARIABLES = 0
Sensor::_incCalcValues; we don't calculate any additional 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

FreescaleMPL115A2_Temp::FreescaleMPL115A2_Temp(FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = "FreescaleMPL115A2_Temp") explicit

Construct a new FreescaleMPL115A2_Temp object.

Parameters
parentSense The parent FreescaleMPL115A2 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 "FreescaleMPL115A2_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 = "FreescaleMPL115A2_Temp"
Default variable short code; "FreescaleMPL115A2_Temp".

Pressure

The pressure variable from a Freescale MPL115A2

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

FreescaleMPL115A2_Pressure::FreescaleMPL115A2_Pressure(FreescaleMPL115A2* parentSense, const char* uuid = "", const char* varCode = "FreescaleMPL115A2_Pressure") explicit

Construct a new FreescaleMPL115A2_Pressure object.

Parameters
parentSense The parent FreescaleMPL115A2 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 "FreescaleMPL115A2_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 = "FreescaleMPL115A2_Pressure"
Default variable short code; "FreescaleMPL115A2_Pressure".

Typedef documentation

typedef FreescaleMPL115A2 MPL115A2

typedef for backwards compatibility; use the FreescaleMPL115A2 class in new code


typedef FreescaleMPL115A2_Temp MPL115A2_Temp

typedef for backwards compatibility; use the FreescaleMPL115A2_Temp class in new code


typedef FreescaleMPL115A2_Pressure MPL115A2_Pressure

typedef for backwards compatibility; use the FreescaleMPL115A2_Pressure class in new code


Define documentation

#define MPL115A2_NUM_VARIABLES = 2

Sensor::_numReturnedValues; the MPL115A2 can report 2 values.


#define MPL115A2_INC_CALC_VARIABLES = 0

Sensor::_incCalcValues; we don't calculate any additional values.


#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.


#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 = "FreescaleMPL115A2_Temp"

Default variable short code; "FreescaleMPL115A2_Temp".


#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 = "FreescaleMPL115A2_Pressure"

Default variable short code; "FreescaleMPL115A2_Pressure".