Skip to content

Commit 8fa6f96

Browse files
Merge pull request #16 from jposada202020/improving_docs
improving_docs
2 parents ff5b647 + 3097487 commit 8fa6f96

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

adafruit_bmp3xx.py

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
`adafruit_bmp3xx`
77
====================================================
88
9-
CircuitPython driver from BMP3XX Temperature and Barometic Pressure sensor.
9+
CircuitPython driver from BMP388 Temperature and Barometric Pressure sensor.
1010
1111
* Author(s): Carter Nelson
1212
@@ -75,7 +75,7 @@ def pressure(self):
7575

7676
@property
7777
def temperature(self):
78-
"""The temperature in deg C."""
78+
"""The temperature in degrees Celsius"""
7979
return self._read()[1]
8080

8181
@property
@@ -220,8 +220,38 @@ def _write_register_byte(self, register, value):
220220

221221

222222
class BMP3XX_I2C(BMP3XX):
223-
"""Driver for I2C connected BMP3XX. Default address is 0x77 but another address can be passed
224-
in as an argument"""
223+
"""Driver for I2C connected BMP3XX.
224+
225+
:param ~busio.I2C i2c: The I2C bus the BMP388 is connected to.
226+
:param int address: I2C device address. Defaults to :const:`0x77`.
227+
but another address can be passed in as an argument
228+
229+
**Quickstart: Importing and using the BMP388**
230+
231+
Here is an example of using the :class:`BMP3XX_I2C` class.
232+
First you will need to import the libraries to use the sensor
233+
234+
.. code-block:: python
235+
236+
import board
237+
import adafruit_bmp3xx
238+
239+
Once this is done you can define your `board.I2C` object and define your sensor object
240+
241+
.. code-block:: python
242+
243+
i2c = board.I2C() # uses board.SCL and board.SDA
244+
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
245+
246+
247+
Now you have access to the :attr:`temperature` and :attr:`pressure` attributes
248+
249+
.. code-block:: python
250+
251+
temperature = bmp.temperature
252+
pressure = bmp.pressure
253+
254+
"""
225255

226256
def __init__(self, i2c, address=0x77):
227257
import adafruit_bus_device.i2c_device as i2c_device
@@ -244,7 +274,40 @@ def _write_register_byte(self, register, value):
244274

245275

246276
class BMP3XX_SPI(BMP3XX):
247-
"""Driver for SPI connected BMP3XX."""
277+
"""Driver for SPI connected BMP3XX.
278+
279+
:param ~busio.SPI spi: SPI device
280+
:param ~digitalio.DigitalInOut cs: Chip Select
281+
282+
283+
**Quickstart: Importing and using the BMP388**
284+
285+
Here is an example of using the :class:`BMP3XX_SPI` class.
286+
First you will need to import the libraries to use the sensor
287+
288+
.. code-block:: python
289+
290+
import board
291+
import adafruit_bmp3xx
292+
from digitalio import DigitalInOut, Direction
293+
294+
Once this is done you can define your `board.SPI` object and define your sensor object
295+
296+
.. code-block:: python
297+
298+
spi = board.SPI()
299+
cs = DigitalInOut(board.D5)
300+
bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)
301+
302+
303+
Now you have access to the :attr:`temperature` and :attr:`pressure` attributes
304+
305+
.. code-block:: python
306+
307+
temperature = bmp.temperature
308+
pressure = bmp.pressure
309+
310+
"""
248311

249312
def __init__(self, spi, cs):
250313
import adafruit_bus_device.spi_device as spi_device

docs/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit BMP388 - Precision Barometric Pressure and Altimeter Learning Guide <https://learn.adafruit.com/adafruit-bmp388-bmp390-bmp3xx>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

29-
Adafruit BMP388 <https://www.adafruit.com/product/3966>
31+
Adafruit BMP388 - Precision Barometric Pressure and Altimeter <https://www.adafruit.com/product/3966>
3032

3133
.. toctree::
3234
:caption: Other Links

examples/bmp3xx_simpletest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33

44
import time
55
import board
6-
import busio
76
import adafruit_bmp3xx
87

98
# I2C setup
10-
i2c = busio.I2C(board.SCL, board.SDA)
9+
i2c = board.I2C() # uses board.SCL and board.SDA
1110
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)
1211

1312
# SPI setup
1413
# from digitalio import DigitalInOut, Direction
15-
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
14+
# spi = board.SPI()
1615
# cs = DigitalInOut(board.D5)
1716
# bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)
1817

0 commit comments

Comments
 (0)