def Temp_humid():
	sensor = scd30.SCD30(PIGPIO_HOST, I2C_SLAVE, I2C_BUS)

	# trigger continous measurement
	sensor.sendCommand(scd30.COMMAND_CONTINUOUS_MEASUREMENT, 970)

	# enable autocalibration
	sensor.sendCommand(scd30.COMMAND_AUTOMATIC_SELF_CALIBRATION, 1)

	sensor.waitForDataReady()
	try:
		# read measurement
		data = sensor.readMeasurement()

		if (data == False):
			exit(1)

		[float_co2, float_T, float_rH] = data

		if float_co2 > 0.0:
			print("gas_ppm{sensor=\"SCD30\",gas=\"CO2\"} %f" % float_co2)

		print("temperature_degC{sensor=\"SCD30\"} %f" % float_T)

		if float_rH > 0.0:
			print("humidity_rel_percent{sensor=\"SCD30\"} %f" % float_rH)
	except OSError:
		sensor.close()
		pass
Exemple #2
0
#!/usr/bin/env python3
# coding=utf-8

import sys
import time
import scd30

PIGPIO_HOST = '::1'
I2C_SLAVE = 0x61
I2C_BUS = 1

sensor = scd30.SCD30(PIGPIO_HOST, I2C_SLAVE, I2C_BUS)

# trigger continous measurement
sensor.sendCommand(scd30.COMMAND_CONTINUOUS_MEASUREMENT, 970)

# enable autocalibration
sensor.sendCommand(scd30.COMMAND_AUTOMATIC_SELF_CALIBRATION, 1)

sensor.waitForDataReady()

try:
    while True:
        # read measurement
        data = sensor.readMeasurement()

        if (data == False):
            exit(1)

        [float_co2, float_T, float_rH] = data
Exemple #3
0
#!/usr/bin/python
import scd30
import socket
import time
from statistics import mean

address = '192.168.2.91'
port = 8001
sensor_path = '/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-port0'

sensor = scd30.SCD30(sensor_path)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
interval = 2
# number of averages for boxcar
N = 4

co2_list = [0] * N
temp_list = [0] * N
hum_list = [0] * N

i = 0
buffer_full = False

if (intv_is := sensor.measurement_interval) != interval:
    print(f'measurement interval was {intv_is}s, setting to {interval}')
    sensor.measurement_interval = interval

while True:
    while not sensor.get_ready():
        time.sleep(0.5)
    co2, temp, hum = sensor.read()
Exemple #4
0
import mqtt
import network
import timer
import time
import machine
import ubinascii
import bme280
import scd30
import max7219

UID = ubinascii.hexlify(machine.unique_id()).decode()
I2C = machine.I2C(sda=machine.Pin(21), scl=machine.Pin(22))
BME = bme280.BME280(i2c=I2C)
SCD = scd30.SCD30(I2C)
LED = max7219.max7219()
LED.set_intensity(max7219.INTENSITY_15)
field = 0


def init_wifi():
    nic = network.WLAN(network.STA_IF)
    nic.active(True)
    nic.connect("CCCAC_OPEN_2.4GHz", None)

    while not nic.isconnected():
        time.sleep_ms(100)
    print("WIFI connection established")


def init_mqtt(mqtt):
    mqtt.connect()
Exemple #5
0
#!/usr/bin/python
import struct

# regs = [0x43DB, 0x8c2e, 0x41d9, 0xe7ff, 0x4243, 0x3a1b]
# regs_bin = struct.pack('>6H', *regs)
# print(struct.unpack('>3f', regs_bin))

import scd30


sensor = scd30.SCD30('/dev/ttyUSB0')

print(sensor.read())