-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_usage_linux_sfm_sf06.py
50 lines (47 loc) · 1.62 KB
/
example_usage_linux_sfm_sf06.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2024 Sensirion AG, Switzerland
#
# THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator: sensirion-driver-generator 0.37.0
# Product: sfm_sf06
# Model-Version: 1.5.0
#
import argparse
import time
from sensirion_i2c_driver import LinuxI2cTransceiver, I2cConnection, CrcCalculator
from sensirion_driver_adapters.i2c_adapter.i2c_channel import I2cChannel
from sensirion_i2c_sfm_sf06.device import SfmSf06Device
parser = argparse.ArgumentParser()
parser.add_argument('--i2c-port', '-p', default='/dev/i2c-1')
args = parser.parse_args()
with LinuxI2cTransceiver(args.i2c_port) as i2c_transceiver:
channel = I2cChannel(I2cConnection(i2c_transceiver),
slave_address=0x2A,
crc=CrcCalculator(8, 0x31, 0xff, 0x0))
sensor = SfmSf06Device(channel)
try:
sensor.stop_continuous_measurement()
time.sleep(0.1)
except BaseException:
...
(product_identifier, serial_number
) = sensor.read_product_identifier()
print(f"product_identifier: {product_identifier}; "
f"serial_number: {serial_number}; "
)
sensor.start_o2_continuous_measurement()
for i in range(100):
try:
time.sleep(0.1)
(a_flow, a_temperature, a_status_word
) = sensor.read_measurement_data()
print(f"a_flow: {a_flow}; "
f"a_temperature: {a_temperature}; "
f"a_status_word: {a_status_word}; "
)
except BaseException:
continue
sensor.stop_continuous_measurement()