parent
199bdac5f9
commit
7db6c6cc1d
22
test.py
22
test.py
|
@ -3,15 +3,27 @@ import busio
|
|||
import adafruit_bmp280
|
||||
import time
|
||||
|
||||
def get_temperature():
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=0x03)
|
||||
return bmp280.temperature
|
||||
# def get_temperature():
|
||||
# i2c = busio.I2C(board.SCL, board.SDA)
|
||||
# bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=0x03)
|
||||
# return bmp280.temperature
|
||||
|
||||
count = 3
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
while True:
|
||||
print(get_temperature())
|
||||
if count != 77:
|
||||
try:
|
||||
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=hex(count))
|
||||
print(bmp280.temperature)
|
||||
exit()
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
exit()
|
||||
# print(get_temperature()
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
# global GPIO
|
||||
# import RPi.GPIO as GPIO
|
||||
# import time
|
||||
|
|
Loading…
Reference in New Issue