|
7 | 7 | ==================================================== |
8 | 8 |
|
9 | 9 | CircuitPython module for the MPL3115A2 barometric pressure & temperature sensor. |
10 | | -See examples/simpletest.py for a demo of the usage. |
11 | 10 |
|
12 | 11 | * Author(s): Tony DiCola |
| 12 | +
|
| 13 | +Implementation Notes |
| 14 | +-------------------- |
| 15 | +
|
| 16 | +**Hardware:** |
| 17 | +
|
| 18 | +* `Adafruit MPL3115A2 - I2C Barometric Pressure/Altitude/Temperature Sensor |
| 19 | + <https://www.adafruit.com/product/1893>`_ |
| 20 | +
|
| 21 | +**Software and Dependencies:** |
| 22 | +
|
| 23 | +* Adafruit CircuitPython firmware for the supported boards: |
| 24 | + https://circuitpython.org/downloads |
| 25 | +
|
| 26 | +* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice |
| 27 | +
|
13 | 28 | """ |
14 | 29 | import time |
15 | 30 |
|
|
80 | 95 |
|
81 | 96 |
|
82 | 97 | class MPL3115A2: |
83 | | - """Instance of the MPL3115A2 sensor. Must specify the following parameters |
84 | | - when creating an instance of this device: |
85 | | - - i2c: The I2C bus connected to the sensor. |
| 98 | + """Instance of the MPL3115A2 sensor. |
| 99 | +
|
| 100 | + :param ~busio.I2C i2c: The I2C bus the MPL3115A2 is connected to. |
| 101 | + :param int address: The I2C device address. Defaults to :const:`0x60` |
| 102 | +
|
| 103 | + **Quickstart: Importing and using the MPL3115A2** |
| 104 | +
|
| 105 | + Here is an example of using the :class:`MPL3115A2` class. |
| 106 | + First you will need to import the libraries to use the sensor |
| 107 | +
|
| 108 | + .. code-block:: python |
| 109 | +
|
| 110 | + import board |
| 111 | + import adafruit_mpl3115a2 |
| 112 | +
|
| 113 | + Once this is done you can define your `board.I2C` object and define your sensor object |
| 114 | +
|
| 115 | + .. code-block:: python |
| 116 | +
|
| 117 | + i2c = board.I2C() # uses board.SCL and board.SDA |
| 118 | + sensor = adafruit_mpl3115a2.MPL3115A2(i2c) |
| 119 | +
|
| 120 | + Now you have access to the :attr:`temperature`, :attr:`pressure` |
| 121 | + and :attr:`altitude` attributes |
| 122 | +
|
| 123 | + .. code-block:: python |
| 124 | +
|
| 125 | + temperature = sensor.temperature |
| 126 | + pressure = sensor.pressure |
| 127 | + altitude = sensor.altitude |
86 | 128 |
|
87 | | - In addition you can specify the following optional keyword arguments: |
88 | | - - address: The I2C address of the device if it's different from the default. |
89 | 129 | """ |
90 | 130 |
|
91 | 131 | # Class level buffer to reduce memory usage and allocations. |
@@ -184,7 +224,7 @@ def altitude(self): |
184 | 224 | """Read the altitude as calculated based on the sensor pressure and |
185 | 225 | previously configured pressure at sea-level. This will return a |
186 | 226 | value in meters. Set the sea-level pressure by updating the |
187 | | - sealevel_pressure property first to get a more accurate altitude value. |
| 227 | + :attr:`sealevel_pressure` property first to get a more accurate altitude value. |
188 | 228 | """ |
189 | 229 | # First poll for a measurement to be finished. |
190 | 230 | self._poll_reg1(_MPL3115A2_CTRL_REG1_OST) |
@@ -230,7 +270,7 @@ def temperature(self): |
230 | 270 | @property |
231 | 271 | def sealevel_pressure(self): |
232 | 272 | """Read and write the pressure at sea-level used to calculate altitude. |
233 | | - You must look this up from a local weather or meteorlogical report for |
| 273 | + You must look this up from a local weather or meteorological report for |
234 | 274 | the best accuracy. This is a value in Pascals. |
235 | 275 | """ |
236 | 276 | # Read the sea level pressure in bars. |
|
0 commit comments