-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_BME280.py
More file actions
43 lines (31 loc) · 1.09 KB
/
Copy pathTest_BME280.py
File metadata and controls
43 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from i2c_core import I2CDEV, I2CBUS
from bme280 import *
from time import sleep
from pca9548 import *
#from board import HW_DEFS
#hw = HW_DEFS()
#i2c0 = I2CBUS(hw.PORT, scl=hw.SCL, sda=hw.SDA, freq=100_000)
i2c0 = I2CBUS(0)
print(i2c0)
i2cmux = PCA9548(i2c=i2c0)
i2cmux.enable(1)
bme280 = BME280(i2c=i2c0, altitude=54.0)
bme280.start_measurement()
#bme280 = I2CDEV(bus=i2c0, dev_id=0x76, probe_on_bus=True, reg_bits=8)
#print(bme280)
#print(bme280.values)
while True:
bme280.ReadAllMeasures()
print("Temperatur: {:.01f} C".format(bme280.temperature))
print("Luftdruck: {:.01f} C".format(bme280.pressure))
print("Feuchte: {:.01f} %".format(bme280.humidity))
print("Taupunkt: {:.01f} C".format(bme280.dew_point))
sleep(5)
#print("Luftdichte: {:.04f} kg/cbm".format(bme280.density))
#for y in bme280.measures.values():
# print("{}: {:.02f}".format(y[3], y[0]), y[1])
#print("Hoehe: {:.01f} m".format(bme280.altitude))
#print("QNH: {:.02f} hPa".format(bme280.qnh))
#buf = bytearray(26)
#bme280.receive_reg(regaddr=0x88, rx_data=memoryview(buf), rx_len=26)
#print(buf)