You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
407 B
19 lines
407 B
7 years ago
|
import time
|
||
|
|
||
|
import gex
|
||
|
|
||
7 years ago
|
# basic NDIR CO2 sensor readout
|
||
|
|
||
7 years ago
|
with gex.Client(gex.TrxRawUSB()) as client:
|
||
|
ser = gex.USART(client, 'ser')
|
||
|
|
||
|
while True:
|
||
7 years ago
|
ser.clear_buffer()
|
||
7 years ago
|
ser.write([0xFF, 0x01, 0x86, 0, 0, 0, 0, 0, 0x79])
|
||
7 years ago
|
data = ser.receive(9, decode=None)
|
||
|
|
||
|
pp = gex.PayloadParser(data, endian="big").skip(2)
|
||
|
print("%d ppm CO₂" % pp.u16())
|
||
|
|
||
7 years ago
|
time.sleep(1)
|