I got a Sensirion SCD30 and wanted to use the sensor on a Raspberry Pi with Archlinuxarm.
The sensor is using I2C so it should be easy. But there is a catch: I2C clock stretching.
I used i2c1_set_clkt_tout from https://github.com/raspihats/raspihats to set the clock speed to 20000. The clock speed is set in the same systemd config that starts the data reading. But running once on system start should be enough.
To read the data from the sensor I use the scd30_i2c library. My code is run via systemd and the main part of the Python script looks like this:
scd30 = SCD30() scd30.set_measurement_interval(2) scd30.start_periodic_measurement() while True: if scd30.get_data_ready(): m = scd30.read_measurement() if m is not None: push_data(m) time.sleep(2) else: time.sleep(0.2) scd30.stop_periodic_measurement()
The push_data is a function that sends the data to my own custom HTTP api. Instead of my own api this could be a csv logger or a push to influxdb/graphite/you-name-it.