-
Notifications
You must be signed in to change notification settings - Fork 1
/
si7021_test.py
31 lines (28 loc) · 861 Bytes
/
si7021_test.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
from machine import I2C
#from SI7021 import SI7021
from SI7021 import SI7021
import time
i2c = I2C(0)
si7021 = SI7021(i2c)
# si7021.reset()
humidity = si7021.humidity()
# print('Humidity: {0}'.format(humidity))
temperature = si7021.temperature()
print('Temperature: {0}C'.format(temperature))
print('Temperature: {0}F'.format(temperature*9/5+32))
humidity = si7021.humidity()
print('Humidity: {0}'.format(humidity))
dew_point = si7021.dew_point()
print('Dew Point: {0}'.format(dew_point))
serial = si7021.serialnumber
print(serial)
revision = si7021.revision
print(revision)
while True:
temp = si7021.temperature()
tempf = temp*9/5+32
hum = si7021.humidity()
dp = si7021.dew_point()
# print('T: {0:.2f}C {1:.2f}F H: {2:.2f} D: {3:.2f}'.format(temp,tempf,hum,dp))
print('T: {0:.2f}F H:{1:.2f}'.format(tempf,hum))
time.sleep(5)