adafruit_dps310

Library for the DPS310 Precision Barometric Pressure Sensor

  • Author(s): Bryan Siepert, Jose David M.

adafruit_dps310.basic

Library for the DPS310 Precision Barometric Pressure Sensor

  • Author(s): Bryan Siepert, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_dps310.basic.DPS310(i2c_bus: I2C, address: int = micropython.const)

Library for the DPS310 Precision Barometric Pressure Sensor. Depending on your board memory availability you could use DPS310_Advanced.

Parameters:
  • i2c_bus (I2C) – The I2C bus the DPS310 is connected to.

  • address (int) – The I2C device address. Defaults to 0x77

Quickstart: Importing and using the DPS310

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

import board
from adafruit_dps310.basic import DPS310

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
dps310 = DPS310(i2c)

Now you have access to the temperature and pressure attributes.

temperature = dps310.temperature
pressure = dps310.pressure
property altitude: float

The altitude in meters based on the sea level pressure (sea_level_pressure) - which you must enter ahead of time

initialize() None

Initialize the sensor to continuous measurement

property pressure: float

Returns the current pressure reading in hectoPascals (hPa)

reset() None

Reset the sensor

property sea_level_pressure: float

The local sea level pressure in hectoPascals (aka millibars). This is used for calculation of altitude. Values are typically in the range 980 - 1030.

property temperature: float

The current temperature reading in degrees Celsius

wait_pressure_ready() None

Wait until a pressure measurement is available

wait_temperature_ready() None

Wait until a temperature measurement is available.

adafruit_dps310.advanced

Library for the DPS310 Precision Barometric Pressure Sensor. This is the advanced version. Includes some features not present in adafruit_dps310.basic

  • Author(s): Bryan Siepert, Jose David M.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_dps310.advanced.DPS310_Advanced(i2c_bus: I2C, address: int = micropython.const)

Library for the DPS310 Precision Barometric Pressure Sensor. This class contains some of other configurable features

Parameters:
  • i2c_bus (I2C) – The I2C bus the DPS310 is connected to.

  • address (int) – The I2C device address. Defaults to 0x77

Quickstart: Importing and using the DPS310

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

import board
from adafruit_dps310.dps310_advanced import DPS310_Advanced as DPS310

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
dps310 = DPS310(i2c)

Now you have access to the temperature and pressure attributes.

temperature = dps310.temperature
pressure = dps310.pressure
initialize() None

Initialize the sensor to continuous measurement

property mode: int

The measurement mode. Must be a Mode. See the Mode documentation for details

property pressure_oversample_count: int

The number of samples taken per pressure measurement. Must be a SampleCount

property pressure_rate: int

Configure the pressure measurement rate. Must be a Rate

property pressure_ready: bool

Returns true if pressure readings are ready

property temperature_oversample_count: int

The number of samples taken per temperature measurement. Must be a SampleCount

property temperature_rate: int

Configure the temperature measurement rate. Must be a Rate

property temperature_ready: bool

Returns true if there is a temperature reading ready

wait_pressure_ready() None

Wait until a pressure measurement is available

To avoid waiting indefinitely this function raises an error if the sensor isn’t configured for pressure measurements, ie. Mode.ONE_PRESSURE, Mode.CONT_PRESSURE or Mode.CONT_PRESTEMP See the Mode documentation for details.

wait_temperature_ready() None

Wait until a temperature measurement is available.

To avoid waiting indefinitely this function raises an error if the sensor isn’t configured for temperate measurements, ie. Mode.ONE_TEMPERATURE, Mode.CONT_TEMP or Mode.CONT_PRESTEMP. See the Mode documentation for details.

class adafruit_dps310.advanced.Mode

Options for mode

Mode

Description

Mode.IDLE

Puts the sensor into a shutdown state

Mode.ONE_PRESSURE

Setting mode to Mode.ONE_PRESSURE takes a single pressure measurement then switches to Mode.IDLE

Mode.ONE_TEMPERATURE

Setting mode to Mode.ONE_TEMPERATURE takes a single temperature measurement then switches to Mode.IDLE

Mode.CONT_PRESSURE

Take pressure measurements at the current pressure_rate. temperature will not be updated

Mode.CONT_TEMP

Take temperature measurements at the current temperature_rate. pressure will not be updated

Mode.CONT_PRESTEMP

Take temperature and pressure measurements at the current pressure_rate and temperature_rate

class adafruit_dps310.advanced.Rate

Options for pressure_rate and temperature_rate