Sensirion / python-shdlc-sensorbridge

SHDLC Python driver for the SEK-SensorBridge
https://sensirion.github.io/python-shdlc-sensorbridge/
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

more concrete example in getting started guide #1

Closed saket424 closed 2 years ago

saket424 commented 3 years ago

I am new to the sensorbridge sek ecosystem

I have an scd41 hooked up to port 1 and an scd30 to port 2

Can you give me a pointer to some starter code on how i can enumerate these two sensors, their serial numbers and retrieve the sensor values

So far, I have progressed this much

(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge $ cat t.py
import time
from sensirion_shdlc_driver import ShdlcSerialPort, ShdlcConnection
from sensirion_shdlc_sensorbridge import SensorBridgePort, SensorBridgeShdlcDevice

# Connect to the device with default settings:
#  - baudrate:      460800
#  - slave address: 0
with ShdlcSerialPort(port='/dev/ttyUSB1', baudrate=460800) as port:
    device = SensorBridgeShdlcDevice(ShdlcConnection(port), slave_address=0)

    # Print some device information
    print("Version: {}".format(device.get_version()))
    print("Product Name: {}".format(device.get_product_name()))
    print("Serial Number: {}".format(device.get_serial_number()))

(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge $ python3 t.py
Version: Firmware 5.8, Hardware 3.0, Protocol 1.0
Product Name: EKS2
Serial Number: 39002700035048474D393520
(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge $ 
saket424 commented 3 years ago

I think scd4x is at i2c 0x62 and scd30 is at i2c 0x61

Any help is much appreciated

saket424 commented 3 years ago

ok so i found an scd41 example at https://sensirion.github.io/python-i2c-scd/quickstart.html

when i start the scd41.py the first time it runs ok but the second time i get an error and i have to unplug and replug the device

(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge $ python scd41.py
SensorBridge SN: 39002700035048474D393520
SensorBridge Version: Firmware 5.8, Hardware 3.0, Protocol 1.0
SensorBridge Product Name: EKS2
493 ppm, 21.7 °C, 32.8 %RH
493 ppm CO2, 21.67 °C (24966 ticks), 32.8 %RH (21527 ticks)
499 ppm, 21.6 °C, 33.4 %RH
499 ppm CO2, 21.56 °C (24926 ticks), 33.4 %RH (21873 ticks)
q
500 ppm, 21.5 °C, 33.7 %RH
500 ppm CO2, 21.46 °C (24890 ticks), 33.7 %RH (22115 ticks)
^CTraceback (most recent call last):
  File "scd41.py", line 34, in <module>
    time.sleep(5)
KeyboardInterrupt
(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge $ python scd41.py
SensorBridge SN: 39002700035048474D393520
SensorBridge Version: Firmware 5.8, Hardware 3.0, Protocol 1.0
SensorBridge Product Name: EKS2
SHDLC device with address 0 returned error 41.
Traceback (most recent call last):
  File "scd41.py", line 30, in <module>
    scd41.start_periodic_measurement()
  File "/home/pi/sensirion-stuff/python-shdlc-sensorbridge/venv3/lib/python3.7/site-packages/sensirion_i2c_scd/scd4x/device.py", line 56, in start_periodic_measurement
    result = self.execute(Scd4xI2cCmdStartPeriodicMeasurement())
  File "/home/pi/sensirion-stuff/python-shdlc-sensorbridge/venv3/lib/python3.7/site-packages/sensirion_i2c_driver/device.py", line 61, in execute
    return self._connection.execute(self._slave_address, command)
  File "/home/pi/sensirion-stuff/python-shdlc-sensorbridge/venv3/lib/python3.7/site-packages/sensirion_i2c_driver/connection.py", line 116, in execute
    return self._interpret_response(command, response)
  File "/home/pi/sensirion-stuff/python-shdlc-sensorbridge/venv3/lib/python3.7/site-packages/sensirion_i2c_driver/connection.py", line 205, in _interpret_response
    raise response
sensirion_i2c_driver.errors.I2cNackError: I2C transceive failed: NACK (byte not acknowledged).
(venv3) pi@pi0gadget:~/sensirion-stuff/python-shdlc-sensorbridge 
saket424 commented 3 years ago

Can you point me to similar starter code for the scd30 for my SEK-SCD30 device on port 2

https://www.mouser.com/ProductDetail/Sensirion/SEK-SCD30-Sensors?qs=rrS6PyfT74eb1S97LuEpuw%3D%3D

I only see a package for scd4x and not for scd30

venv3/lib/python3.7/site-packages/sensirion_i2c_scd/scd4x

what is the solution for the scd30?

MBjoern commented 3 years ago

Hi

We do not provide a finished python i2c via sensor bridge package for SCD30 yet. You'd need to create that yourself or use the ControlCenter evaluation kit software to compare the two sensors.

Please find the SCD30 technical documentation here

MBjoern commented 3 years ago

I hope you've found your way to a working sample.

As there was no activity on this issue, i'll close it. Feel free to reopen or open another issue, if you need any further assistance.

Keep prototyping, We'll love to see your projects in the field.