Skip to content

improving_docs #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 68 additions & 5 deletions adafruit_bmp3xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
`adafruit_bmp3xx`
====================================================

CircuitPython driver from BMP3XX Temperature and Barometic Pressure sensor.
CircuitPython driver from BMP388 Temperature and Barometric Pressure sensor.

* Author(s): Carter Nelson

Expand Down Expand Up @@ -75,7 +75,7 @@ def pressure(self):

@property
def temperature(self):
"""The temperature in deg C."""
"""The temperature in degrees Celsius"""
return self._read()[1]

@property
Expand Down Expand Up @@ -220,8 +220,38 @@ def _write_register_byte(self, register, value):


class BMP3XX_I2C(BMP3XX):
"""Driver for I2C connected BMP3XX. Default address is 0x77 but another address can be passed
in as an argument"""
"""Driver for I2C connected BMP3XX.

:param ~busio.I2C i2c: The I2C bus the BMP388 is connected to.
:param int address: I2C device address. Defaults to :const:`0x77`.
but another address can be passed in as an argument

**Quickstart: Importing and using the BMP388**

Here is an example of using the :class:`BMP3XX_I2C` class.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_bmp3xx

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
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)


Now you have access to the :attr:`temperature` and :attr:`pressure` attributes

.. code-block:: python

temperature = bmp.temperature
pressure = bmp.pressure

"""

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


class BMP3XX_SPI(BMP3XX):
"""Driver for SPI connected BMP3XX."""
"""Driver for SPI connected BMP3XX.

:param ~busio.SPI spi: SPI device
:param ~digitalio.DigitalInOut cs: Chip Select


**Quickstart: Importing and using the BMP388**

Here is an example of using the :class:`BMP3XX_SPI` class.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_bmp3xx
from digitalio import DigitalInOut, Direction

Once this is done you can define your `board.SPI` object and define your sensor object

.. code-block:: python

spi = board.SPI()
cs = DigitalInOut(board.D5)
bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)


Now you have access to the :attr:`temperature` and :attr:`pressure` attributes

.. code-block:: python

temperature = bmp.temperature
pressure = bmp.pressure

"""

def __init__(self, spi, cs):
import adafruit_bus_device.spi_device as spi_device
Expand Down
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit BMP388 - Precision Barometric Pressure and Altimeter Learning Guide <https://learn.adafruit.com/adafruit-bmp388-bmp390-bmp3xx>

.. toctree::
:caption: Related Products

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

.. toctree::
:caption: Other Links
Expand Down
5 changes: 2 additions & 3 deletions examples/bmp3xx_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

import time
import board
import busio
import adafruit_bmp3xx

# I2C setup
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c)

# SPI setup
# from digitalio import DigitalInOut, Direction
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
# spi = board.SPI()
# cs = DigitalInOut(board.D5)
# bmp = adafruit_bmp3xx.BMP3XX_SPI(spi, cs)

Expand Down