Python client for GEX
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.
gex-client-py/demo_ndir_usart.py

17 lines
374 B

import time
import gex
with gex.Client(gex.TrxRawUSB()) as client:
ser = gex.USART(client, 'ser')
while True:
ser.clear_buffer()
ser.write([0xFF, 0x01, 0x86, 0, 0, 0, 0, 0, 0x79])
data = ser.receive(9, decode=None)
pp = gex.PayloadParser(data, endian="big").skip(2)
print("%d ppm CO₂" % pp.u16())
time.sleep(1)