Created
April 26, 2017 15:57
-
-
Save foxel/a163231293d7cf6f24831b363a91dfe5 to your computer and use it in GitHub Desktop.
Python example for SI7021 board from ControlEverything
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
from time import sleep, strftime | |
from OmegaExpansion import onionI2C # requires fixes for https://github.com/OnionIoT/i2c-exp-driver/issues/13 | |
while True: | |
i2c = onionI2C.OnionI2C() | |
i2c.write(0x40, [0xE5]) | |
sleep(0.1) | |
h0, h1 = i2c.read(0x40, 2) | |
i2c.write(0x40, [0xE0]) | |
sleep(0.1) | |
t0, t1 = i2c.read(0x40, 2) | |
hum = ((125.0 * (h0 * 256 + h1)) / 65536.0) - 6.0 | |
temp = ((175.72 * (t0 * 256 + t1)) / 65536.0) - 46.85; | |
print '%s | RH: %0.1f %% | Temp %0.1f C' % ( | |
strftime('%X'), | |
hum, | |
temp | |
) | |
sleep(5) | |
sys.stdout.write("\033[F") | |
sys.stdout.write("\033[K") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment