Home LCD Projects MPL3115A2 pressure sensor readings on LCD

MPL3115A2 pressure sensor readings on LCD

by shedboy71

In this project we will get the current altitude and temperature using an MPL3115A2 pressure sensor connected to an LCD keypad shield fitted to an Arduino Uno

Here is a little information regarding the sensor.

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

Parts List

I used the following parts for this project

Description Link
Arduino Uno 1pcs UNO R3 CH340G+MEGA328P for Arduino UNO R3 (NO USB CABLE)
LCD Keypad shield 1PCS LCD Keypad Shield LCD 1602 Module Display For Arduino
MPL3115A2 MPL3115A2 I2C Intelligent Temperature Pressure Altitude Sensor V2.0 For Arduino
connecting wire 40pcs Dupont jumper wire cable 30cm male to male,female to female,male to female Dupont jump wire line 2.54mm breadboard cable

 

 

Schematics/Layout

 

lcd shield and MPL3115A2 layout

lcd shield and MPL3115A2 layout

 

Code

We need to add a library via the library manager or download it from – https://github.com/adafruit/Adafruit_MPL3115A2_Library

[codesyntax lang=”cpp”]

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

//setup for the LCD keypad shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

void setup() 
{
  //init serial for some debug
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");

  //init LCD
  lcd.begin(16,2);
  //line 1 - temperature
  lcd.setCursor(0,0);
  lcd.print("ALTITUDE");
  //line 2 - humidity
  lcd.setCursor(0,1);
  lcd.print("TEMPERATURE");
}

void loop() 
{
  if (! baro.begin()) 
  {
    Serial.println("Couldnt find sensor");
    return;
  }
  float pascals = baro.getPressure();
  float altm = baro.getAltitude();
  float tempC = baro.getTemperature();
  //display readings on lcd  
  lcd.setCursor(0,0);
  lcd.print("Alt = ");
  lcd.print(altm);
  lcd.print(" m");
  lcd.setCursor(0,1);
  lcd.print("Temp = ");
  lcd.print(tempC);
  lcd.print(" *c");

  delay(500);
}

[/codesyntax]

 

Output

Here is a video showing my results, you should get similar results on your LCD

 

Links

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

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More