Skip to content

Commit 898df9d

Browse files
committed
aligning_example_code and adding_library_usage_explanation
1 parent ccb982d commit 898df9d

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

README.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Introduction
1313
:target: https://github.com/adafruit/Adafruit_CircuitPython_BME280/actions/
1414
:alt: Build Status
1515

16+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
17+
:target: https://github.com/psf/black
18+
:alt: Code Style: Black
19+
1620
I2C and SPI driver for the Bosch BME280 Temperature, Humidity, and Barometric Pressure sensor
1721

1822
Installation and Dependencies
@@ -54,18 +58,41 @@ To install in a virtual environment in your current project:
5458
source .env/bin/activate
5559
pip3 install adafruit-circuitpython-bme280
5660
61+
62+
Installing to a connected CircuitPython Device
63+
==============================================
64+
Some devices, eg. the QT-PY, are very limited in memory. The BME280 library contains
65+
two variants - basic and advanced - which give different levels of functionality.
66+
67+
Installing the BME280 library could have the following outcomes:
68+
69+
* It installs successfully and your code runs successfully. Woo-hoo! Continue with
70+
your amazing project.
71+
* It installs successfully and your code fails to run with a memory allocation
72+
error. Try one of the following:
73+
74+
* If your :data:`code.py` is large, especially if it has lots of comments, you
75+
can shrink it into a :data:`.mpy` file instead. See the Adafruit
76+
`Learn Guide <https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/non-volatile-not-enough-disk-space>`_
77+
on shrinking your code.
78+
* Only use the basic BME280 implementation, and remove the following file:
79+
:data:`<CIRCUITPY>/lib/adafruit_bme280/advanced.mpy` where <CIRCUITPY> is the
80+
mounted location of your device. Make sure that your code only uses the basic
81+
implementation.
82+
83+
5784
Usage Example
5885
=============
5986

6087
.. code-block:: python3
6188
6289
import board
6390
import time
64-
from adafruit_bme280 import basic
91+
from adafruit_bme280 import basic as adafruit_bme280
6592
6693
# Create sensor object, using the board's default I2C bus.
6794
i2c = board.I2C() # uses board.SCL and board.SDA
68-
bme280 = basic.Adafruit_BME280_I2C(i2c)
95+
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
6996
7097
# change this to match the location's pressure (hPa) at sea level
7198
bme280.sea_level_pressure = 1013.25

adafruit_bme280/advanced.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ class Adafruit_BME280_I2C(Adafruit_BME280_Advanced):
282282
.. code-block:: python
283283
284284
import board
285-
from adafruit_bme280 import advanced
285+
import adafruit_bme280.advanced as adafruit_bme280
286286
287287
Once this is done you can define your `board.I2C` object and define your sensor object
288288
289289
.. code-block:: python
290290
291291
i2c = board.I2C() # uses board.SCL and board.SDA
292-
bme280 = advanced.Adafruit_BME280_I2C(i2c)
292+
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
293293
294294
You need to setup the pressure at sea level
295295
@@ -349,15 +349,15 @@ class Adafruit_BME280_SPI(Adafruit_BME280_Advanced):
349349
350350
import board
351351
from digitalio import DigitalInOut
352-
from adafruit_bme280 import advanced
352+
import adafruit_bme280.advanced as adafruit_bme280
353353
354354
Once this is done you can define your `board.SPI` object and define your sensor object
355355
356356
.. code-block:: python
357357
358358
cs = digitalio.DigitalInOut(board.D10)
359359
spi = board.SPI()
360-
bme280 = advanced.Adafruit_BME280_SPI(spi, cs)
360+
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
361361
362362
You need to setup the pressure at sea level
363363

adafruit_bme280/basic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@ class Adafruit_BME280_I2C(Adafruit_BME280):
335335
.. code-block:: python
336336
337337
import board
338-
from adafruit_bme280 import basic
338+
from adafruit_bme280 import basic as adafruit_bme280
339339
340340
Once this is done you can define your `board.I2C` object and define your sensor object
341341
342342
.. code-block:: python
343343
344344
i2c = board.I2C() # uses board.SCL and board.SDA
345-
bme280 = basic.Adafruit_BME280_I2C(i2c)
345+
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
346346
347347
You need to setup the pressure at sea level
348348
@@ -402,15 +402,15 @@ class Adafruit_BME280_SPI(Adafruit_BME280):
402402
403403
import board
404404
from digitalio import DigitalInOut
405-
from adafruit_bme280 import basic
405+
from adafruit_bme280 import basic as adafruit_bme280
406406
407407
Once this is done you can define your `board.SPI` object and define your sensor object
408408
409409
.. code-block:: python
410410
411411
cs = digitalio.DigitalInOut(board.D10)
412412
spi = board.SPI()
413-
bme280 = basic.Adafruit_BME280_SPI(spi, cs)
413+
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, cs)
414414
415415
You need to setup the pressure at sea level
416416

0 commit comments

Comments
 (0)