Skip to content

aligning_example_code and adding_library_usage_explanation, updating PyPI_packaging_Info #54

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 3 commits into from
Jun 10, 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
31 changes: 29 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Introduction
:target: https://github.com/adafruit/Adafruit_CircuitPython_BME280/actions/
:alt: Build Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: Black

I2C and SPI driver for the Bosch BME280 Temperature, Humidity, and Barometric Pressure sensor

Installation and Dependencies
Expand Down Expand Up @@ -54,18 +58,41 @@ To install in a virtual environment in your current project:
source .env/bin/activate
pip3 install adafruit-circuitpython-bme280


Installing to a connected CircuitPython Device
==============================================
Some devices, eg. the QT-PY, are very limited in memory. The BME280 library contains
two variants - basic and advanced - which give different levels of functionality.

Installing the BME280 library could have the following outcomes:

* It installs successfully and your code runs successfully. Woo-hoo! Continue with
your amazing project.
* It installs successfully and your code fails to run with a memory allocation
error. Try one of the following:

* If your ``code.py`` is large, especially if it has lots of comments, you
can shrink it into a ``.mpy`` file instead. See the Adafruit
`Learn Guide <https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/non-volatile-not-enough-disk-space>`_
on shrinking your code.
* Only use the basic BME280 implementation, and remove the following file:
``<CIRCUITPY>/lib/adafruit_bme280/advanced.mpy`` where <CIRCUITPY> is the
mounted location of your device. Make sure that your code only uses the basic
implementation.


Usage Example
=============

.. code-block:: python3

import board
import time
from adafruit_bme280 import basic
from adafruit_bme280 import basic as adafruit_bme280

# Create sensor object, using the board's default I2C bus.
i2c = board.I2C() # uses board.SCL and board.SDA
bme280 = basic.Adafruit_BME280_I2C(i2c)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

# change this to match the location's pressure (hPa) at sea level
bme280.sea_level_pressure = 1013.25
Expand Down
8 changes: 4 additions & 4 deletions adafruit_bme280/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ class Adafruit_BME280_I2C(Adafruit_BME280_Advanced):
.. code-block:: python

import board
from adafruit_bme280 import advanced
import adafruit_bme280.advanced as adafruit_bme280

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
bme280 = advanced.Adafruit_BME280_I2C(i2c)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level

Expand Down Expand Up @@ -349,15 +349,15 @@ class Adafruit_BME280_SPI(Adafruit_BME280_Advanced):

import board
from digitalio import DigitalInOut
from adafruit_bme280 import advanced
import adafruit_bme280.advanced as adafruit_bme280

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

.. code-block:: python

cs = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = advanced.Adafruit_BME280_SPI(spi, cs)
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)

You need to setup the pressure at sea level

Expand Down
8 changes: 4 additions & 4 deletions adafruit_bme280/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,14 @@ class Adafruit_BME280_I2C(Adafruit_BME280):
.. code-block:: python

import board
from adafruit_bme280 import basic
from adafruit_bme280 import basic as adafruit_bme280

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
bme280 = basic.Adafruit_BME280_I2C(i2c)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

You need to setup the pressure at sea level

Expand Down Expand Up @@ -402,15 +402,15 @@ class Adafruit_BME280_SPI(Adafruit_BME280):

import board
from digitalio import DigitalInOut
from adafruit_bme280 import basic
from adafruit_bme280 import basic as adafruit_bme280

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

.. code-block:: python

cs = digitalio.DigitalInOut(board.D10)
spi = board.SPI()
bme280 = basic.Adafruit_BME280_SPI(spi, cs)
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)

You need to setup the pressure at sea level

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
keywords="adafruit bme280 sensor hardware micropython circuitpython",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
py_modules=["adafruit_bme280"],
packages=["adafruit_bme280"],
)