diff --git a/README.rst b/README.rst index 5ddd4fb..69beed9 100644 --- a/README.rst +++ b/README.rst @@ -60,10 +60,9 @@ Usage Example import time import board - import busio import adafruit_dps310 - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() # uses board.SCL and board.SDA dps310 = adafruit_dps310.DPS310(i2c) diff --git a/adafruit_dps310.py b/adafruit_dps310.py index 1838832..6a372a9 100644 --- a/adafruit_dps310.py +++ b/adafruit_dps310.py @@ -114,7 +114,7 @@ class Mode(CV): class Rate(CV): - """Options for `pressure_rate` and `temperature_rate`""" + """Options for :attr:`pressure_rate` and :attr:`temperature_rate`""" pass @@ -134,7 +134,7 @@ class Rate(CV): class SampleCount(CV): - """Options for `temperature_oversample_count` and `pressure_oversample_count`""" + """Options for :attr:`temperature_oversample_count` and :attr:`pressure_oversample_count`""" pass @@ -157,7 +157,31 @@ class DPS310: """Library for the DPS310 Precision Barometric Pressure Sensor. :param ~busio.I2C i2c_bus: The I2C bus the DPS310 is connected to. - :param address: The I2C slave address of the sensor + :param int address: The I2C device address. Defaults to :const:`0x77` + + **Quickstart: Importing and using the DPS310** + + Here is an example of using the :class:`DPS310` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import adafruit_dps310 + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + dps310 = adafruit_dps310.DPS310(i2c) + + Now you have access to the :attr:`temperature` and :attr:`pressure` attributes. + + .. code-block:: python + + temperature = dps310.temperature + pressure = dps310.pressure """ # Register definitions @@ -219,7 +243,7 @@ def __init__(self, i2c_bus, address=_DPS310_DEFAULT_ADDRESS): 2088960, ) self.sea_level_pressure = 1013.25 - """Pressure in hectoPascals at sea level. Used to calibrate `altitude`.""" + """Pressure in hectoPascals at sea level. Used to calibrate :attr:`altitude`.""" self.initialize() def initialize(self): @@ -289,13 +313,13 @@ def pressure(self): @property def altitude(self): - """The altitude based on the sea level pressure (`sea_level_pressure`) - which you must - enter ahead of time)""" + """The altitude based on the sea level pressure (:attr:`sea_level_pressure`) - + which you must enter ahead of time)""" return 44330 * (1.0 - math.pow(self.pressure / self.sea_level_pressure, 0.1903)) @property def temperature(self): - """The current temperature reading in degrees C""" + """The current temperature reading in degrees Celsius""" _scaled_rawtemp = self._raw_temperature / self._temp_scale _temperature = _scaled_rawtemp * self._c1 + self._c0 / 2.0 return _temperature @@ -375,7 +399,7 @@ def pressure_rate(self, value): @property def pressure_oversample_count(self): - """The number of samples taken per pressure measurement. Must be a `SampleCount`""" + """The number of samples taken per pressure measurement. Must be a ``SampleCount``""" return self._pressure_osbits @pressure_oversample_count.setter @@ -400,7 +424,7 @@ def temperature_rate(self, value): @property def temperature_oversample_count(self): - """The number of samples taken per temperature measurement. Must be a `SampleCount`""" + """The number of samples taken per temperature measurement. Must be a ``SampleCount``""" return self._temp_osbits @temperature_oversample_count.setter diff --git a/docs/api.rst b/docs/api.rst index 0ead416..c41be33 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -6,3 +6,4 @@ .. automodule:: adafruit_dps310 :members: + :exclude-members: CV, SampleCount diff --git a/docs/examples.rst b/docs/examples.rst index 4c8130c..f38db7e 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,13 @@ Ensure your device works with this simple test. .. literalinclude:: ../examples/dps310_simpletest.py :caption: examples/dps310_simpletest.py :linenos: + +Lower Power Weather Station +--------------------------- + +Example showing how to configure the sensor for continuous measurement with rates, +sampling counts and mode optimized for low power + +.. literalinclude:: ../examples/dps310_low_power_weather_station.py + :caption: examples/dps310_low_power_weather_station.py + :linenos: diff --git a/docs/index.rst b/docs/index.rst index 5c28025..3b48c21 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,10 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit DPS310 Precision Barometric Pressure / Altitude Sensor Learning Guide .. toctree:: :caption: Related Products + Adafruit DPS310 Precision Barometric Pressure / Altitude Sensor .. toctree:: :caption: Other Links diff --git a/examples/dps310_low_power_weather_station.py b/examples/dps310_low_power_weather_station.py index 59ddd80..53b75e2 100644 --- a/examples/dps310_low_power_weather_station.py +++ b/examples/dps310_low_power_weather_station.py @@ -14,10 +14,9 @@ import time import board -import busio import adafruit_dps310 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # uses board.SCL and board.SDA dps310 = adafruit_dps310.DPS310(i2c) diff --git a/examples/dps310_simpletest.py b/examples/dps310_simpletest.py index 204e6ee..9245b70 100644 --- a/examples/dps310_simpletest.py +++ b/examples/dps310_simpletest.py @@ -3,11 +3,9 @@ import time import board -import busio import adafruit_dps310 -i2c = busio.I2C(board.SCL, board.SDA) - +i2c = board.I2C() # uses board.SCL and board.SDA dps310 = adafruit_dps310.DPS310(i2c) while True: