-
Notifications
You must be signed in to change notification settings - Fork 0
/
sudoReadCo2.py
31 lines (24 loc) · 1 KB
/
sudoReadCo2.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
import os
import subprocess
import binascii
def debug():
print("Raw data:")
rawData = subprocess.Popen("sudo i2cget -y 2 0x5a 0x03 w;", shell=True, stdout=subprocess.PIPE).stdout.read().decode()
print(rawData)
print("Env data:")
envData = subprocess.Popen("sudo i2cget -y 2 0x5a 0x02 w;", shell=True, stdout=subprocess.PIPE).stdout.read().decode()
print(envData)
def printaValorCO2():
envData = subprocess.Popen("sudo i2cget -y 2 0x5a 0x02 w;", shell=True, stdout=subprocess.PIPE).stdout.read().decode()
envData_cut = envData[4] + envData[5] + envData[2] + envData[3]
print(int(envData_cut, 16))
def retornaValorCO2():
envData = subprocess.Popen("sudo i2cget -y 2 0x5a 0x02 w;", shell=True, stdout=subprocess.PIPE).stdout.read().decode()
envData_cut = envData[4] + envData[5] + envData[2] + envData[3]
return int(envData_cut, 16)
def start():
os.system("./start.sh")
if __name__=="__main__":
#debug()
#retornaValorCO2()
printaValorCO2()