MicroPython DPS310 Library¶
dps310¶
MicroPython Driver for the DP310 Barametric Sensor
Author: Jose D. Montoya
Implementation Notes¶
Software and Dependencies:
This library depends on Micropython
-
class micropython_dps310.dps310.DPS310(i2c, address=
0x77)[source]¶ Main class for the Sensor
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
micropython_dps310.DPS310class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C import micropython_dps310.dps310 as dps310Once this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) dps = dps310.DPS310(i2c)Now you have access to the
pressureattributepress = dps.pressure- property altitude : float¶
The altitude in meters based on the sea level pressure (
sea_level_pressure) - which you must enter ahead of time
- property mode : str¶
Mode
Description
dps310.IDLEPuts the sensor into a shutdown state
dps310.ONE_PRESSURESetting
modetodps310.ONE_PRESSUREtakes a single pressure measurement then switches todps310.IDLEdps310.ONE_TEMPERATURESetting
modetodps310.ONE_TEMPERATUREtakes a single temperature measurement then switches todps310.IDLEdps310.CONT_PRESSURETake pressure measurements at the current
pressure_rate.temperaturewill not be updateddps310.CONT_TEMPTake temperature measurements at the current
temperature_rate.pressurewill not be updateddps310.CONT_PRESTEMPTake temperature and pressure measurements at the current
pressure_rateandtemperature_rate
- property pressure_oversample : str¶
Pressure Oversample. In order to achieve a higher precision, the sensor DPS310 will read multiple times ( oversampling ), and combine the readings into one result. This increases the current consumption and also the measurement time, reducing the maximum possible measurement rate. It is necessary to balance the accuracy and data rate required for each application with the allowable current consumption.
Mode
Value
dps310.SAMPLE_PER_SECOND_10b000# 1 time (Pressure Low Precision)dps310.SAMPLE_PER_SECOND_20b001# 2 times (Pressure Low Power)dps310.SAMPLE_PER_SECOND_40b010# 4 timesdps310.SAMPLE_PER_SECOND_80b011# 8 timesdps310.SAMPLE_PER_SECOND_160b100# 16 times (Pressure Standard).**dps310.SAMPLE_PER_SECOND_320b101# 32 times **dps310.SAMPLE_PER_SECOND_640b110# 64 times (Pressure High Precision) **dps310.SAMPLE_PER_SECOND_1280b111# 128 times **
- property pressure_rate : str¶
Mode
Value
dps310.RATE_1_HZ0b000dps310.RATE_2_HZ0b001dps310.RATE_4_HZ0b010dps310.RATE_8_HZ0b011dps310.RATE_16_HZ0b100dps310.RATE_32_HZ0b101dps310.RATE_64_HZ0b110dps310.RATE_128_HZ0b111
- 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_oversample : str¶
Temperature Oversample. In order to achieve a higher precision, the sensor DPS310 will read multiple times ( oversampling ), and combine the readings into one result. This increases the current consumption and also the measurement time, reducing the maximum possible measurement rate. It is necessary to balance the accuracy and data rate required for each application with the allowable current consumption.
Mode
Value
dps310.SAMPLE_PER_SECOND_10b000# 1 timedps310.SAMPLE_PER_SECOND_20b001# 2 timesdps310.SAMPLE_PER_SECOND_40b010# 4 timesdps310.SAMPLE_PER_SECOND_80b011# 8 timesdps310.SAMPLE_PER_SECOND_160b100# 16 timesdps310.SAMPLE_PER_SECOND_320b101# 32 timesdps310.SAMPLE_PER_SECOND_640b110# 64 timesdps310.SAMPLE_PER_SECOND_1280b111# 128 times