Skip to content

Commit 51ffff9

Browse files
committed
example in RST
1 parent 1deea3c commit 51ffff9

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.rst

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Introduction
1010
:target: https://discord.gg/nBQh6qu
1111
:alt: Discord
1212
13-
TODO
13+
I2C and SPI driver for the Bosch BME280 Temperature, Humidity, and Barometric Pressure sensor
1414

1515
Dependencies
1616
=============
@@ -26,7 +26,33 @@ This is easily achieved by downloading
2626
Usage Example
2727
=============
2828

29-
TODO
29+
.. code-block:: python
30+
import board
31+
import digitalio
32+
import busio
33+
import time
34+
import adafruit_bme280
35+
36+
# Create library object using our Bus I2C port
37+
i2c = busio.I2C(board.SCL, board.SDA)
38+
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
39+
40+
# OR create library object using our Bus SPI port
41+
#spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
42+
#bme_cs = digitalio.DigitalInOut(board.D10)
43+
#bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
44+
45+
# change this to match the location's pressure (hPa) at sea level
46+
bme280.seaLevelhPa = 1013.25
47+
48+
while True:
49+
print("\nTemperature: %0.1f C" % bme280.temperature)
50+
print("Humidity: %0.1f %%" % bme280.humidity)
51+
print("Pressure: %0.1f hPa" % bme280.pressure)
52+
print("Altitude = %0.2f meters" % bme280.altitude)
53+
time.sleep(2)
54+
55+
3056
3157
Contributing
3258
============

adafruit_bme280.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def _read_coefficients(self):
179179
self.dig_H4 = float((coeff[2] << 4) | (coeff[3] & 0xF))
180180
self.dig_H5 = float(((coeff[3] & 0xF0) << 4) | coeff[4])
181181
self.dig_H6 = float(coeff[5])
182-
183182
#print("%d %d %d" % (self.dig_T1, self.dig_T2, self.dig_T3))
184183
#print("%d %d %d" % (self.dig_P1, self.dig_P2, self.dig_P3))
185184
#print("%d %d %d" % (self.dig_P4, self.dig_P5, self.dig_P6))

0 commit comments

Comments
 (0)