CO2L Unit
UNIT CO2L is a digital air CO2 concentration detection unit with a single-measurement low-power mode, built-in Sensirion’s SCD41 sensor and power buck circuitry, and I2C communication. The unit is suitable for the measurement of air ambient conditions with a typical accuracy of ± (40 ppm + 5 % reading) for CO2 measurements over a measuring range of 400 ppm – 5000 ppm while measuring ambient temperature and humidity.
Support the following products:
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import * 9from unit import CO2LUnit 10 11 12title0 = None 13label0 = None 14label1 = None 15label2 = None 16label3 = None 17i2c0 = None 18co2l_0 = None 19 20 21def setup(): 22 global title0, label0, label1, label2, label3, i2c0, co2l_0 23 24 M5.begin() 25 Widgets.fillScreen(0x222222) 26 title0 = Widgets.Title( 27 "CO2LUnit CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18 28 ) 29 label0 = Widgets.Label("label0", 1, 44, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 30 label1 = Widgets.Label("label1", 1, 95, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 31 label2 = Widgets.Label("label2", 1, 146, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 32 label3 = Widgets.Label("label3", 1, 198, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 33 34 i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000) 35 co2l_0 = CO2LUnit(i2c0) 36 co2l_0.set_start_periodic_measurement() 37 38 39def loop(): 40 global title0, label0, label1, label2, label3, i2c0, co2l_0 41 if co2l_0.is_data_ready(): 42 label0.setText(str("Data is ready.")) 43 label1.setText(str((str("CO2 ppm:") + str((co2l_0.co2))))) 44 label2.setText(str((str("Humidity:") + str((co2l_0.humidity))))) 45 label3.setText(str((str("Temperature:") + str((co2l_0.temperature))))) 46 else: 47 label0.setText(str("Data not ready.")) 48 49 50if __name__ == "__main__": 51 try: 52 setup() 53 while True: 54 loop() 55 except (Exception, KeyboardInterrupt) as e: 56 try: 57 from utility import print_error_msg 58 59 print_error_msg(e) 60 except ImportError: 61 print("please update to latest firmware")
UIFLOW2 Example:
class CO2LUnit
Constructors
Methods
- CO2LUnit.available()
Check if the CO2 unit is available on the I2C bus.
- CO2LUnit.set_start_periodic_measurement()
Set the sensor into working mode, which takes about 5 seconds per measurement.
UIFLOW2:
- CO2LUnit.set_stop_periodic_measurement()
Stop the measurement mode for the sensor.
UIFLOW2:
- CO2LUnit.get_sensor_measurement()
Get temperature, humidity, and CO2 concentration from the sensor.
- CO2LUnit.is_data_ready()
Check if the data (temperature, humidity, CO2) is ready from the sensor.
UIFLOW2:
- CO2LUnit.get_temperature_offset()
Get the temperature offset to be added to the reported measurements.
UIFLOW2:
- CO2LUnit.set_temperature_offset(offset)
Set the maximum value of 374°C temperature offset.
- Parameters:
offset (int) – The temperature offset to set, default is 0.
UIFLOW2:
- CO2LUnit.get_sensor_altitude()
Get the altitude value of the measurement location in meters above sea level.
UIFLOW2:
- CO2LUnit.set_sensor_altitude(height)
Set the altitude value of the measurement location in meters above sea level.
- Parameters:
height (int) – The altitude in meters to set. Must be between 0 and 65535 meters.
UIFLOW2:
- CO2LUnit.set_ambient_pressure(ambient_pressure)
Set the ambient pressure in hPa at any time to adjust CO2 calculations.
- Parameters:
ambient_pressure (int) – The ambient pressure in hPa, constrained to the range [0, 65535].
UIFLOW2:
- CO2LUnit.set_force_calibration(target_co2)
Force the sensor to recalibrate with a given current CO2 level.
- Parameters:
target_co2 (int) – The current CO2 concentration to be used for recalibration.
UIFLOW2:
- CO2LUnit.get_calibration_enabled()
Get whether automatic self-calibration (ASC) is enabled or disabled.
UIFLOW2:
- CO2LUnit.set_calibration_enabled(enabled)
Enable or disable automatic self-calibration (ASC).
- Parameters:
enabled (bool) – Set to True to enable ASC, or False to disable it.
UIFLOW2:
- CO2LUnit.set_start_low_periodic_measurement()
Set the sensor into low power working mode, with about 30 seconds per measurement.
UIFLOW2:
- CO2LUnit.data_isready()
Check if new data is available from the sensor.
- CO2LUnit.save_to_eeprom()
Save temperature offset, altitude offset, and self-calibration enable settings to EEPROM.
UIFLOW2:
- CO2LUnit.get_serial_number()
Get a unique serial number for this sensor.
UIFLOW2:
- CO2LUnit.set_self_test()
Perform a self-test, which can take up to 10 seconds.
UIFLOW2:
- CO2LUnit.set_factory_reset()
Reset all configuration settings stored in the EEPROM and erase the FRC and ASC algorithm history.
UIFLOW2:
- CO2LUnit.reinit()
Reinitialize the sensor by reloading user settings from EEPROM.
UIFLOW2:
- CO2LUnit.set_single_shot_measurement_all()
Set the sensor to perform a single-shot measurement for CO2, humidity, and temperature.
- CO2LUnit.set_single_shot_measurement_ht()
Set the sensor to perform a single-shot measurement for humidity and temperature.
- CO2LUnit.set_sleep_mode()
Put the sensor into sleep mode to reduce current consumption.
- CO2LUnit.set_wake_up()
Wake up the sensor from sleep mode into idle mode.
- CO2LUnit.write_cmd(cmd_wr, value)
Write a command to the sensor.
- CO2LUnit.read_response(num)
Read the sensor’s response.
- Parameters:
num (int) – The number of bytes to read from the sensor.