Home Circuitpython Adafruit Feather M0 and LPS25HB absolute pressure sensor circuitpython example

Adafruit Feather M0 and LPS25HB absolute pressure sensor circuitpython example

by shedboy71

In this example we connect a LPS25HB absolute pressure sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the sensor from the manufacturer

The LPS25HB is a 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 LPS25HB is available in a full-mold, holed LGA package (HLGA).

It is guaranteed to operate over a temperature range extending from -30 to +105 °C. The package is holed to allow external pressure to reach the sensing element.


260 to 1260 hPa absolute pressure range
High-resolution mode: 0.01 hPa RMS
Low power consumption – Low-resolution mode: 4 μA – Low current & noise mode with FIFO: 4.5 μA
High overpressure capability: 20x full scale
Embedded temperature compensation
24-bit pressure data output
ODR from 1 Hz to 25 Hz
SPI and I2C interfaces
Embedded FIFO
Interrupt functions: Data Ready, FIFO flags, pressure thresholds
Supply voltage: 1.7 to 3.6 V
High shock survivability: 10,000 g

This was my sensor of choice that I used

Parts Required


Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
LPS25HB LPS25HTR Height Pressure Sensor Module
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire



feather and LPS25

feather and LPS25

Code Example

I used Mu for development

The following is based on a library , I copied the LPS25HB library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

import time
import board
import busio
import adafruit_lps2x
i2c = busio.I2C(board.SCL, board.SDA)
lps = adafruit_lps2x.LPS2X(i2c)
while True:
    print("Pressure: %.2f hPa" % lps.pressure)
    print("Temperature: %.2f C" % lps.temperature)


Here is what I saw in Mu REPL window, I moved my closer to the sensor and away from the sensor to change the values

Pressure: 756.50 hPa
Temperature: 42.50 C
Pressure: 1011.19 hPa
Temperature: 21.85 C
Pressure: 1011.27 hPa
Temperature: 21.82 C
Pressure: 1011.26 hPa
Temperature: 21.78 C



You may also like

Leave a Comment