LPS331AP Pressure/Altitude Module Features
This small board has an LPS331AP pressure sensor or barometer. The communication protocol of this module is I2C and SPI. In addition to measuring pressure and altitude, this module can also measure temperature.
LPS331AP Sensor Pinout
This sensor has 9 pins. 4 pin are more useful:
- +5V: Module power supply – 5 V
- GND: Ground
- SLC: I2C Clock
- SDA: I2C data
You can see pinout of this module in the image below.
You can download the datasheet of this module here.
LPS331AP Pressure/Altitude Module Datasheet
1 file(s) 447.75 KB
Required Materials
Hardware Components
Software Apps
Interfacing LPS331AP Sensor with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to LPS331AP module. Connect wires accordingly.
Step 2: Installing Library
Install following library on your Arduino.
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 8, 2020
Modified by MohammedDamirchi from https://github.com/pololu/lps-arduino.git
Home
*/
#include <Wire.h>
#include <LPS.h>
LPS ps;
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!ps.init())
{
Serial.println("Failed to autodetect pressure sensor!");
while (1);
}
ps.enableDefault();
}
void loop()
{
float pressure = ps.readPressureMillibars();
float altitude = ps.pressureToAltitudeMeters(pressure);
float temperature = ps.readTemperatureC();
Serial.print("p: ");
Serial.print(pressure/33.77);
Serial.print(" Inches (Hg)\ta: ");
Serial.print(altitude);
Serial.print(" m\tt: ");
Serial.print(temperature);
Serial.println(" deg C");
delay(100);
}
After running the code, you will see the following image in the serial output.