STM32 Nucleo and LPS22HB absolute pressure sensor example using the Arduino IDE

In this article we look at another absolute pressure sensor – this time its the LPS22HB and once again we will connect this to a STM32 nucleo

The LPS22HB is an ultra-compact piezoresistive absolute pressure sensor which functions as a digital output barometer. The device comprises a sensing element and an IC interface which communicates through I2C or SPI from the sensing element to the application.

The sensing element, which detects absolute pressure, consists of a suspended membrane manufactured using a dedicated process developed by ST.
The LPS22HB is available in a full-mold, holed LGA package (HLGA). It is guaranteed to operate over a temperature range extending from -40 °C to +85 °C. The package is holed to allow external pressure to reach the sensing element.

Features

  • 260 to 1260 hPa absolute pressure range
  • Current consumption down to 3 μA
  • High overpressure capability: 20x full-scale
  • Embedded temperature compensation
  • 24-bit pressure data output
  • 16-bit temperature data output
  • ODR from 1 Hz to 75 Hz
  • SPI and I²C interfaces
  • Embedded FIFO
  • Interrupt functions: Data Ready, FIFO flags, pressure thresholds
  • Supply voltage: 1.7 to 3.6 V
  • High shock survivability: 22,000 g

 

Parts Required

 

NameLink
NUCLEO-L496ZG1/PCS LOT NUCLEO-L496ZG Nucleo development board STM32L4 series development board
LPS22HBSemoic Lps22Hb Pressure Resistance Pressure Sensor Module for High Intensity Industrial Control
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

I used 3v3, there is a Vin pin and I could have quite easily used 5v

NucleoSensor
3v33v3
GndGnd
I2C1_SCLSCL
I2C1_SDASDA

 

Code Example

This uses the library from hhttps://github.com/adrien3d/IO_LPS22HB

/***************************************************************************
This is a library for the LPS22HB Absolute Digital Barometer

Designed to work with all kinds of LPS22HB Breakout Boards

These sensors use I2C, 2 pins are required to interface, as this :
VDD to 3.3V DC
SCL to A5
SDA to A4
GND to common groud

Written by Adrien Chapelet for IoThings
***************************************************************************/

#include <Wire.h>

#include "IO_LPS22HB.h"

IO_LPS22HB lps22hb;

void setup()
{
Serial.begin(9600);
Serial.println("IoThings LPS22HB Arduino Test");

lps22hb.begin(0x5D);

byte who_am_i = lps22hb.whoAmI();
Serial.print("Who Am I? 0x");
Serial.print(who_am_i, HEX);
Serial.println(" (expected: 0xB1)");
if (who_am_i != LPS22HB_WHO_AM_I_VALUE) {
Serial.println("Error while retrieving WHO_AM_I byte...");
while (true) {
// loop forever
}
}
}

void loop()
{
Serial.print("P=");
Serial.print(lps22hb.readPressure());
Serial.print(" mbar, T=");
Serial.print(lps22hb.readTemperature());
Serial.println("C");
delay(300);
}

 

Output

Open the serial monitor and you should see something like this

IoThings LPS22HB Arduino Test
Who Am I? 0xB1 (expected: 0xB1)
P=954.86 mbar, T=27.43C
P=954.91 mbar, T=27.40C
P=954.86 mbar, T=27.37C
P=954.88 mbar, T=27.34C
P=954.89 mbar, T=27.34C
P=954.88 mbar, T=27.33C
P=954.90 mbar, T=27.27C
P=954.87 mbar, T=27.22C

Links

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

Share
This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :