STM32 Nucleo and LPS25H pressure sensor example using the Arduino IDE

0

In this article we look at a LPS25H pressure sensor and we will use an STM32 Nucleo and will look at an example of using this sensor with the Arduino IDE

Lets look at the sensor

The LPS25H is an ultra-compact absolute piezoresistive pressure sensor. It includes a monolithic sensing element and an IC interface able to take the information from the sensing element and to provide a digital signal to the external world.

The sensing element consists of a suspended membrane realized inside a single mono-silicon substrate. It is capable of detecting pressure and is manufactured using a dedicated process developed by ST.
The membrane is very small compared to the traditionally built silicon micromachined membranes. Membrane breakage is prevented by an intrinsic mechanical stopper.
The IC interface is manufactured using a standard CMOS process that allows a high level of integration to design a dedicated circuit which is trimmed to better match the sensing element characteristics.
The LPS25H is available in a cavity holed LGA package (HLGA). It is guaranteed to operate over a temperature range extending from -30 °C to +105 °C. The package is holed to allow external pressure to reach the sensing element.

Features

260 to 1260 mbar absolute pressure range
High-resolution mode: 1 Pa RMS
Low power consumption
Low-resolution mode: 4 μA
High-resolution mode: 25 μA
High overpressure capability: 20x full scale
Embedded temperature compensation
Embedded 24-bit ADC
Selectable ODR from 1 Hz to 25 Hz
SPI and I²C interfaces
Supply voltage: 1.7 to 3.6 V
High shock survivability: 10,000 g

 

Parts Required

 

Name Link
NUCLEO-L496ZG 1/PCS LOT NUCLEO-L496ZG Nucleo development board STM32L4 series development board
LPS25H Diybigworld LPS25HTR ST CJMCU-25 Miniature high Precision Pressure Sensor Temperature Compensation
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

Nucleo Sensor
3v3 Vcc
Gnd Gnd
I2C1_SCL SCL
I2C1_SDA SDA

 

Code Example

This uses the library from https://github.com/pololu/lps-arduino

#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);
Serial.print(" mbar\ta: ");
Serial.print(altitude);
Serial.print(" m\tt: ");
Serial.print(temperature);
Serial.println(" deg C");
delay(1000);
}

 

Output

Open the serial monitor and you should see something like this

p: 954.97 mbar a: 496.80 m t: 24.23 deg C
p: 954.99 mbar a: 496.62 m t: 24.20 deg C
p: 954.93 mbar a: 497.17 m t: 24.18 deg C
p: 954.94 mbar a: 497.08 m t: 24.14 deg C
p: 954.95 mbar a: 497.01 m t: 24.11 deg C

 

Links

https://www.st.com/resource/en/datasheet/lps25h.pdf

Share