adafruit_dps310

Library for the DPS310 Precision Barometric Pressure Sensor

  • Author(s): Bryan Siepert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_dps310.DPS310(i2c_bus, address=119)

Library for the DPS310 Precision Barometric Pressure Sensor.

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
import adafruit_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 = adafruit_dps310.DPS310(i2c)

Now you have access to the temperature and pressure attributes.

temperature = dps310.temperature
pressure = dps310.pressure
altitude

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

initialize()

Initialize the sensor to continuous measurement

mode

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

pressure

Returns the current pressure reading in hPA

pressure_oversample_count

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

pressure_rate

Configure the pressure measurement rate. Must be a Rate

pressure_ready

Returns true if pressure readings are ready

reset()

Reset the sensor

sea_level_pressure = None

Pressure in hectoPascals at sea level. Used to calibrate altitude.

temperature

The current temperature reading in degrees Celsius

temperature_oversample_count

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

temperature_rate

Configure the temperature measurement rate. Must be a Rate

temperature_ready

Returns true if there is a temperature reading ready

wait_pressure_ready()

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()

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.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.Rate

Options for pressure_rate and temperature_rate