File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Introduction
10
10
:target: https://discord.gg/nBQh6qu
11
11
:alt: Discord
12
12
13
- TODO
13
+ I2C and SPI driver for the Bosch BME280 Temperature, Humidity, and Barometric Pressure sensor
14
14
15
15
Dependencies
16
16
=============
@@ -26,7 +26,33 @@ This is easily achieved by downloading
26
26
Usage Example
27
27
=============
28
28
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 (" \n Temperature: %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
+
30
56
31
57
Contributing
32
58
============
Original file line number Diff line number Diff line change @@ -179,7 +179,6 @@ def _read_coefficients(self):
179
179
self .dig_H4 = float ((coeff [2 ] << 4 ) | (coeff [3 ] & 0xF ))
180
180
self .dig_H5 = float (((coeff [3 ] & 0xF0 ) << 4 ) | coeff [4 ])
181
181
self .dig_H6 = float (coeff [5 ])
182
-
183
182
#print("%d %d %d" % (self.dig_T1, self.dig_T2, self.dig_T3))
184
183
#print("%d %d %d" % (self.dig_P1, self.dig_P2, self.dig_P3))
185
184
#print("%d %d %d" % (self.dig_P4, self.dig_P5, self.dig_P6))
You can’t perform that action at this time.
0 commit comments