Wemos Mini and LPS25H piezoresistive pressure sensor example

In this article we look at a pressure sensor – this time its the LPS25H and we will connect it to a Wemos Mini

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 List

Here are the parts I used

Name Links
Wemos Mini
LPS25H
Connecting cables

 

Schematic/Connection

 

Wemos mini Sensor
3.3v Vcc
Gnd Gnd
SDA (D2) SDA
SCL (D1) SCL

 

 

Code Example

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

[codesyntax lang=”cpp”]

#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(100);
}

[/codesyntax]

 

Output

Open the serial monitor and you should see something like this

p: 1016.05 mbar a: -23.26 m t: 26.85 deg C
p: 1016.04 mbar a: -23.22 m t: 26.89 deg C
p: 1016.04 mbar a: -23.21 m t: 26.93 deg C
p: 1016.05 mbar a: -23.32 m t: 27.00 deg C
p: 1015.99 mbar a: -22.80 m t: 27.03 deg C
p: 1016.05 mbar a: -23.26 m t: 27.08 deg C
p: 1016.01 mbar a: -22.98 m t: 27.15 deg C
p: 1016.02 mbar a: -23.06 m t: 27.18 deg C
p: 1015.95 mbar a: -22.49 m t: 27.21 deg C

 

Links

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