pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit CO2

Example

Obtain atmospheric CO2 concentration, temperature, humidity and atmospheric pressure data collected by Unit CO2L

from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
co2_0 = unit.get(unit.CO2_SCD40, unit.PORTA)

co2_0.stop_periodic_measurement()
print(co2_0.serial_number())
print(co2_0.get_calibration_enabled())
co2_0.start_periodic_measurement()
wait(1)
while True:
  if co2_0.data_isready():
    co2_0.read_sensor_measurement()
    print((str('data status:') + str((co2_0.data_isready()))))
    print((str('CO2:') + str((co2_0.co2))))
    print((str('Temperature:') + str((co2_0.temperature))))
    wait_ms(25)
  wait_ms(2)

API

co2_0.stop_periodic_measurement()
  • Stop Periodic Measurements

co2_0.factory_reset()
  • Perform Factory Reset
co2_0.force_calibration(400)
  • Force Recalibration of CO2
print(co2_0.get_calibration_enabled())
  • Get Auto-Calibration Enabled Status
print(co2_0.data_isready())
  • Get Data Ready Status
print(co2_0.get_sensor_altitude())
  • Get Sensor Height
co2_0.read_sensor_measurement()
  • Wait for Sensor Measurement Update
print(co2_0.serial_number())
  • Get Sensor Serial Number
print(co2_0.get_temperature_offset())
  • Get Temperature Offset
co2_0.persist_settings()
  • Save All Settings to EEPROM
co2_0.sleep_mode()
  • Set Sensor to Sleep Mode
print(co2_0.co2)
  • Get CO2/Humidity/Temperature Values
co2_0.reinit()
  • Reinitialize Sensor
co2_0.self_test()
  • Perform Self-Test
co2_0.set_ambient_pressure(0)
  • Set Ambient Air Pressure
co2_0.set_calibration_enabled(1)
  • Set Auto-Calibration Enabled
co2_0.set_sensor_altitude(0)
  • Set Sensor Height from Ground (Mark)
co2_0.set_temperature_offset(4)
  • Set Temperature Offset
co2_0.start_low_periodic_measurement()
  • Start Low Frequency Measurements (30 Seconds Interval)
co2_0.start_periodic_measurement()
  • Start Device Measurements
co2_0.wake_up()
  • Wake Up Sensor
On This Page