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.DPS310
class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C import micropython_dps310.dps310 as dps310
Once this is done you can define your
machine.I2C
object and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) dps = dps310.DPS310(i2c)
Now you have access to the
pressure
attributepress = 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.IDLE
Puts the sensor into a shutdown state
dps310.ONE_PRESSURE
Setting
mode
todps310.ONE_PRESSURE
takes a single pressure measurement then switches todps310.IDLE
dps310.ONE_TEMPERATURE
Setting
mode
todps310.ONE_TEMPERATURE
takes a single temperature measurement then switches todps310.IDLE
dps310.CONT_PRESSURE
Take pressure measurements at the current
pressure_rate
.temperature
will not be updateddps310.CONT_TEMP
Take temperature measurements at the current
temperature_rate
.pressure
will not be updateddps310.CONT_PRESTEMP
Take temperature and pressure measurements at the current
pressure_rate
andtemperature_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_1
0b000
# 1 time (Pressure Low Precision)dps310.SAMPLE_PER_SECOND_2
0b001
# 2 times (Pressure Low Power)dps310.SAMPLE_PER_SECOND_4
0b010
# 4 timesdps310.SAMPLE_PER_SECOND_8
0b011
# 8 timesdps310.SAMPLE_PER_SECOND_16
0b100
# 16 times (Pressure Standard).**dps310.SAMPLE_PER_SECOND_32
0b101
# 32 times **dps310.SAMPLE_PER_SECOND_64
0b110
# 64 times (Pressure High Precision) **dps310.SAMPLE_PER_SECOND_128
0b111
# 128 times **
- property pressure_rate : str¶
Mode
Value
dps310.RATE_1_HZ
0b000
dps310.RATE_2_HZ
0b001
dps310.RATE_4_HZ
0b010
dps310.RATE_8_HZ
0b011
dps310.RATE_16_HZ
0b100
dps310.RATE_32_HZ
0b101
dps310.RATE_64_HZ
0b110
dps310.RATE_128_HZ
0b111
- 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_1
0b000
# 1 timedps310.SAMPLE_PER_SECOND_2
0b001
# 2 timesdps310.SAMPLE_PER_SECOND_4
0b010
# 4 timesdps310.SAMPLE_PER_SECOND_8
0b011
# 8 timesdps310.SAMPLE_PER_SECOND_16
0b100
# 16 timesdps310.SAMPLE_PER_SECOND_32
0b101
# 32 timesdps310.SAMPLE_PER_SECOND_64
0b110
# 64 timesdps310.SAMPLE_PER_SECOND_128
0b111
# 128 times