@@ -142,7 +142,7 @@ def __init__(self, *, refresh_rate=10):
142
142
self ._write (_BME680_BME680_GAS_WAIT_0 , [0x65 ])
143
143
144
144
self .sea_level_pressure = 1013.25
145
- """Pressure in hectoPascals at sea level. Used to calibrate `` altitude` `."""
145
+ """Pressure in hectoPascals at sea level. Used to calibrate :attr:` altitude`."""
146
146
147
147
# Default oversampling and filter register values.
148
148
self ._pressure_oversample = 0b011
@@ -210,7 +210,7 @@ def filter_size(self, size):
210
210
211
211
@property
212
212
def temperature (self ):
213
- """The compensated temperature in degrees celsius ."""
213
+ """The compensated temperature in degrees Celsius ."""
214
214
self ._perform_reading ()
215
215
calc_temp = ((self ._t_fine * 5 ) + 128 ) / 256
216
216
return calc_temp / 100
@@ -288,8 +288,8 @@ def humidity(self):
288
288
289
289
@property
290
290
def altitude (self ):
291
- """The altitude based on current `` pressure` ` vs the sea level pressure
292
- (`` sea_level_pressure` `) - which you must enter ahead of time)"""
291
+ """The altitude based on current :attr:` pressure` vs the sea level pressure
292
+ (:attr:` sea_level_pressure`) - which you must enter ahead of time)"""
293
293
pressure = self .pressure # in Si units for hPascal
294
294
return 44330 * (1.0 - math .pow (pressure / self .sea_level_pressure , 0.1903 ))
295
295
@@ -383,10 +383,47 @@ def _write(self, register, values):
383
383
class Adafruit_BME680_I2C (Adafruit_BME680 ):
384
384
"""Driver for I2C connected BME680.
385
385
386
- :param int address: I2C device address
387
- :param bool debug: Print debug statements when True.
386
+ :param ~busio.I2C i2c: The I2C bus the BME680 is connected to.
387
+ :param int address: I2C device address. Defaults to :const:`0x77`
388
+ :param bool debug: Print debug statements when `True`. Defaults to `False`
388
389
:param int refresh_rate: Maximum number of readings per second. Faster property reads
389
- will be from the previous reading."""
390
+ will be from the previous reading.
391
+
392
+ **Quickstart: Importing and using the BME680**
393
+
394
+ Here is an example of using the :class:`BMP680_I2C` class.
395
+ First you will need to import the libraries to use the sensor
396
+
397
+ .. code-block:: python
398
+
399
+ import board
400
+ import adafruit_bme680
401
+
402
+ Once this is done you can define your `board.I2C` object and define your sensor object
403
+
404
+ .. code-block:: python
405
+
406
+ i2c = board.I2C() # uses board.SCL and board.SDA
407
+ bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c)
408
+
409
+ You need to setup the pressure at sea level
410
+
411
+ .. code-block:: python
412
+
413
+ bme680.sea_level_pressure = 1013.25
414
+
415
+ Now you have access to the :attr:`temperature`, :attr:`gas`, :attr:`relative_humidity`,
416
+ :attr:`pressure` and :attr:`altitude` attributes
417
+
418
+ .. code-block:: python
419
+
420
+ temperature = bme680.temperature
421
+ gas = bme680.gas
422
+ relative_humidity = bme680.relative_humidity
423
+ pressure = bme680.pressure
424
+ altitude = bme680.altitude
425
+
426
+ """
390
427
391
428
def __init__ (self , i2c , address = 0x77 , debug = False , * , refresh_rate = 10 ):
392
429
"""Initialize the I2C device at the 'address' given"""
@@ -423,12 +460,50 @@ def _write(self, register, values):
423
460
class Adafruit_BME680_SPI (Adafruit_BME680 ):
424
461
"""Driver for SPI connected BME680.
425
462
426
- :param busio.SPI spi: SPI device
427
- :param digitalio.DigitalInOut cs: Chip Select
428
- :param bool debug: Print debug statements when True.
429
- :param int baudrate: Clock rate, default is 100000
463
+ :param ~ busio.SPI spi: SPI device
464
+ :param ~ digitalio.DigitalInOut cs: Chip Select
465
+ :param bool debug: Print debug statements when ` True`. Defaults to `False`
466
+ :param int baudrate: Clock rate, default is :const:` 100000`
430
467
:param int refresh_rate: Maximum number of readings per second. Faster property reads
431
468
will be from the previous reading.
469
+
470
+
471
+ **Quickstart: Importing and using the BME680**
472
+
473
+ Here is an example of using the :class:`BMP680_SPI` class.
474
+ First you will need to import the libraries to use the sensor
475
+
476
+ .. code-block:: python
477
+
478
+ import board
479
+ from digitalio import DigitalInOut, Direction
480
+ import adafruit_bme680
481
+
482
+ Once this is done you can define your `board.SPI` object and define your sensor object
483
+
484
+ .. code-block:: python
485
+
486
+ cs = digitalio.DigitalInOut(board.D10)
487
+ spi = board.SPI()
488
+ bme680 = adafruit_bme680.Adafruit_BME680_SPI(spi, cs)
489
+
490
+ You need to setup the pressure at sea level
491
+
492
+ .. code-block:: python
493
+
494
+ bme680.sea_level_pressure = 1013.25
495
+
496
+ Now you have access to the :attr:`temperature`, :attr:`gas`, :attr:`relative_humidity`,
497
+ :attr:`pressure` and :attr:`altitude` attributes
498
+
499
+ .. code-block:: python
500
+
501
+ temperature = bme680.temperature
502
+ gas = bme680.gas
503
+ relative_humidity = bme680.relative_humidity
504
+ pressure = bme680.pressure
505
+ altitude = bme680.altitude
506
+
432
507
"""
433
508
434
509
def __init__ (self , spi , cs , baudrate = 100000 , debug = False , * , refresh_rate = 10 ):
0 commit comments