Contents

Interfacing MPL3115A2 Pressure / Altitude Sensor with Arduino

MPL3115A2 Pressure/Altitude Sensor Features

The MPL3115A2 pressure and altitude sensor is a MEMS pressure sensor that generates altitude data. The sensor outputs are converted to digital data by high-resolution 24bit ADC and transfer over I2C, which means that this module easily communicates with most microcontrollers. The unit of pressure and height is Pascal and meter respectively. The module also measures 12-bit temperature in degrees Celsius.

MPL3115A2 Module Pinout

This sensor has 7 pins:

  • VIN: Module power supply – 5 V
  • +3V3: Module power supply – 3.3 V
  • GND: Ground
  • SLC: I2C Clock
  • SDA: I2C data
  • INT: Adjusting address for I2C communication

You can see pinout of this module in the image below.

You can download the datasheet of this module here.

Required Materials

Hardware Components

Arduino UNO R3 × 1
MPL3115A2 Module × 1
Male Female Jumper Wire × 1

Software Apps

Arduino IDE

Interfacing MPL3115A2 Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to MPL3115A2 module. Connect wires accordingly.

Step 2: Code

Install following library on your Arduino.

https://github.com/adafruit/Adafruit_MPL3115A2_Library

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Upload the following code to your Arduino.
/*   
modified on Sep 21, 2020
Modified by MohammedDamirchi from https://github.com/adafruit/Adafruit_MPL3115A2_Library
Home
*/ #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.print(" Inches (Hg)\t"); float altm = baro.getAltitude(); Serial.print(altm); Serial.print(" meters\t"); float tempC = baro.getTemperature(); Serial.print(tempC); Serial.println("*C"); }
After running the code, you will see the following image in the serial output.
Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

Your email address will not be published. Required fields are marked *