Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python example for SI7021 board from ControlEverything
#!/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
You can’t perform that action at this time.