Home CodeArduino Due Arduino Due and MPL3115A2 example

Arduino Due and MPL3115A2 example

by shedboy71

In this example we connect a MPL3115A2 to an Arduino Due

The MPL3115A2 is a compact, piezoresistive, absolute pressure sensor with an I2C digital interface. MPL3115A2 has a wide operating range of 20 kPa to 110 kPa, a range that covers all surface elevations on earth. The MEMS is temperature compensated utilizing an on-chip temperature sensor. The pressure and temperature data is fed into a high resolution ADC to provide fully compensated and digitized outputs for pressure in Pascals and temperature in °C.

The compensated pressure output can then be converted to altitude, utilizing the formula stated in Section 9.1.3 “Pressure/altitude” provided in meters.The internal processing in MPL3115A2 removes compensation and unit conversion load from the system MCU, simplifying system design

• Operating range: 20 kPa to 110 kPa absolute pressure
• Calibrated range: 50 kPa to 110 kPa absolute pressure
• Calibrated temperature output: −40 °C to 85 °C
• I2C digital output interface
• Fully compensated internally
• Precision ADC resulting in 0.1 meter of effective resolution
• Direct reading
– Pressure: 20-bit measurement (Pascals) 20 to 110 kPa
– Altitude: 20-bit measurement (meters) –698 to 11,775 m
– Temperature: 12-bit measurement (°C) –40 °C to 85 °C
• Programmable interrupts
• Autonomous data acquisition
– Embedded 32-sample FIFO
– Data logging up to 12 days using the FIFO
– One-second to nine-hour data acquisition rate
• 1.95 V to 3.6 V supply voltage, internally regulated
• 1.6 V to 3.6 V digital interface supply voltage
• Operating temperature from −40 °C to +85 °C

Parts List

 

Amount Part Type
1 MPL3115A2 I2C Intelligent Temperature Pressure Altitude Sensor V2.0 For Arduino
1 Compatible DUE R3 Board SAM3X8E 32-bit ARM Cortex-M3

 

Schematics/Layout

 

arduino due and mpl3115a2

arduino due and mpl3115a2

 

Code

Again we use a library and again its an adafruit one – https://github.com/adafruit/Adafruit_MPL3115A2_Library

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <Adafruit_MPL3115A2.h>

// Power by connecting Vin to 3-5V, GND to GND
// Uses I2C - connect SCL to the SCL pin, SDA to SDA pin
// See the Wire tutorial for pinouts for each Arduino
// http://arduino.cc/en/reference/wire
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
}

void loop() {
  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
    return;
  }
  
  float pascals = baro.getPressure();
  // Our weather page presents pressure in Inches (Hg)
  // Use http://www.onlineconversion.com/pressure.htm for other units
  Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

  float altm = baro.getAltitude();
  Serial.print(altm); Serial.println(" meters");

  float tempC = baro.getTemperature();
  Serial.print(tempC); Serial.println("*C");

  delay(250);
}

[/codesyntax]

 

Output

Open the serial monitor – here are my results

 

 

Links

https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

 

Share

You may also like