LPS28 Library

lps28

LPS28 pressure sensor drive for CircuitPython

  • Author(s): Jose D. Montoya

class lps28.LPS28(i2c_bus: busio.I2C, address: int = 0x5D)[source]

Driver for the LPS28 Sensor connected over I2C.

Parameters:
i2c_bus : I2C

The I2C bus the LPS28 is connected to.

address : int

The I2C device address. Defaults to 0x5D

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the LPS28 class. First you will need to import the libraries to use the sensor

import board
import lps28

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
lps28 = LPS28.lps28(i2c)

Now you have access to the attributes

press = lps28.pressure
property data_rate : str

Sensor data_rate

Mode

Value

lps28.ONE_SHOT

0b0000

lps28.RATE_1_HZ

0b0001

lps28.RATE_4_HZ

0b0010

lps28.RATE_10_HZ

0b0011

lps28.RATE_25_HZ

0b0100

lps28.RATE_50_HZ

0b0101

lps28.RATE_75_HZ

0b0110

lps28.RATE_100_HZ

0b0111

lps28.RATE_200_HZ

0b1000

property full_scale : None

Sensor full_scale (0: mode 1, full scale up to 1260 hPa; 1: mode 2, full scale up to 4060 hPa)

Mode

Value

lps28.FULL_SCALE

0b1

lps28.NORMAL

0b0

property high_threshold_enabled : bool

Set to True or False to enable or disable the high pressure threshold

property high_threshold_exceeded : bool

Returns True if the pressure high threshold has been exceeded. Must be enabled by setting high_threshold_enabled to True and setting a pressure_threshold.

property low_threshold_enabled : bool

Set to True or False to enable or disable the low pressure threshold.

property low_threshold_exceeded : bool

Returns True if the pressure low threshold has been exceeded. Must be enabled by setting high_threshold_enabled to True and setting a pressure_threshold.

property pressure : float

Pressure value in hPa

property pressure_threshold : float

The high pressure threshold. Use high_threshold_enabled or high_threshold_enabled to use it

property resolution : None

Sensor resolution

Mode

Value

lps28.RES_4

0b000

lps28.RES_8

0b001

lps28.RES_16

0b010

lps28.RES_32

0b011

lps28.RES_64

0b100

lps28.RES_128

0b101

lps28.RES_512

0b111

property temperature : float

The current temperature measurement in Celsius