CircuitPython BMP581 Driver

bmp581

CircuitPython Driver for the Bosch BMP581 pressure sensor

  • Author(s): Jose D. Montoya

class bmp581.BMP581(i2c_bus: busio.I2C, address: int = 0x47)[source]

Driver for the BMP581 Sensor connected over I2C.

Parameters:
i2c_bus : I2C

The I2C bus the BMP581 is connected to.

address : int

The I2C device address. Defaults to 0x47

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

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

import board
import bmp581

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
bmp = bmp581.BMP581(i2c)

Now you have access to the attributes

press = bmp.pressure
property altitude

With the measured pressure p and the pressure at sea level p0 e.g. 1013.25hPa, the altitude in meters can be calculated with the international barometric formula

With the measured pressure p and the absolute altitude the pressure at sea level can be calculated too. See the altitude setter for this calculation

property output_data_rate : int

Sensor output_data_rate. for a complete list of values please see the datasheet

property power_mode : str

Sensor power_mode

Mode

Value

bmp581.STANDBY

0x00

bmp581.NORMAL

0x01

bmp581.FORCED

0x02

bmp581.NON_STOP

0X03

property pressure : float

The sensor pressure in kPa :return: Pressure in kPa

property pressure_oversample_rate : str

Sensor pressure_oversample_rate

Mode

Value

bmp581.OSR1

0x00

bmp581.OSR2

0x01

bmp581.OSR4

0x02

bmp581.OSR8

0x03

bmp581.OSR16

0x04

bmp581.OSR32

0x05

bmp581.OSR64

0x06

bmp581.OSR128

0x07

property temperature : float

The temperature sensor in C :return: Temperature

property temperature_oversample_rate : str

Sensor temperature_oversample_rate

Mode

Value

bmp581.OSR1

0x00

bmp581.OSR2

0x01

bmp581.OSR4

0x02

bmp581.OSR8

0x03

bmp581.OSR16

0x04

bmp581.OSR32

0x05

bmp581.OSR64

0x06

bmp581.OSR128

0x07