-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbmp280.py
executable file
·37 lines (29 loc) · 1016 Bytes
/
bmp280.py
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
#!/usr/bin/python3
import board
import busio
import digitalio
import adafruit_bmp280
import time
#i2c = busio.I2C(board.D27, board.D17)
i2c = busio.I2C(board.SCL, board.SDA)
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=0x76)
print("Temperature: %0.1f C" % bmp280.temperature)
print("Pressure: %0.1f hPa" % bmp280.pressure)
print("Altitude = %0.2f meters" % bmp280.altitude)
"""
bmp280.mode = adafruit_bmp280.MODE_NORMAL
time.sleep(1)
print("Temperature: %0.1f C" % bmp280.temperature)
print("Pressure: %0.1f hPa" % bmp280.pressure)
print("Altitude = %0.2f meters" % bmp280.altitude)
bmp280.mode = adafruit_bmp280.MODE_FORCE
time.sleep(1)
print("Temperature: %0.1f C" % bmp280.temperature)
print("Pressure: %0.1f hPa" % bmp280.pressure)
print("Altitude = %0.2f meters" % bmp280.altitude)
bmp280.mode = adafruit_bmp280.MODE_SLEEP
time.sleep(1)
print("Temperature: %0.1f C" % bmp280.temperature)
print("Pressure: %0.1f hPa" % bmp280.pressure)
print("Altitude = %0.2f meters" % bmp280.altitude)
"""