Only Oxocard-Connect with AIR Cartridge
The AIR Cartridge includes 3 air quality sensors from Sensirion: - SHT40 Temperature and Humidity sensor. - SCD40 CO2 sensor - SGP41 VOC and NOx sensor
The AIR library provides the AIR object.
Returns the current CO2 value in ppm.
Returns the NOx index. This is calculated with “Sensirion’s Gas Index” algorithm and corresponds to a representative value between 1 and 500.
Returns the VOC index. This is calculated with “Sensirion’s Gas Index” algorithm and corresponds to a representative value between 1 and 500.
Returns the current temperature in °C.
Returns the current humidity in %RH.
Returns the current absolute humidity in g/m^3. This value indicates the amount of water vapor (humidity) in the air, regardless of temperature.
Returns the current IAQ rating. IAQ stands for Indoor Air Quality and usually takes a value between 0 and 5:
import air setPrecision(3) textFont(FONT_ROBOTO_24) def onDraw(): clear() drawText(10, 10, "CO2: " + AIR.CO2() + " ppm") drawText(10, 40, "NOxIdx: " + AIR.NOxIndex() + " / 500") drawText(10, 70, "VOCIdx: " + AIR.VOCIndex() + " / 500") drawText(10, 100, "IAQ: " + AIR.IAQ()) drawText(10, 130, "temp: " + AIR.temperature() + " °C") drawText(10, 160, "humi: " + AIR.humidity() + " %RH") drawText(10, 190, "humiAbs: " + AIR.humidityAbsolute() + " g/m3") update() delay(100)
Only Oxocard-Connect with TOF Cartridge
The TOF library provides the TOF object.
The Time of Flight (TOF) sensor is a distance sensor. It measures the distance to an object in a matrix (8x8 or 4x4) and returns the 64 or 16 values in millimeters.
The TOF must be initialized first. Initialization takes about 10 seconds the first time.
If you don’t want to use 8x8 with 15Hz but 4x4 with 60Hz sampling, you can use the set4x4() function. And to switch back set8x8().
Use getData() to read the 64 or 16 values and store them in the TOF.data array.
The TOF class contains two variables which are updated when getData() is called.
The TOF.data array contains the measured distances in millimeters.
The TOF.status array contains the status of each measured distance. Here, values 5 and 9 correspond to a valid measurement and all other values correspond to an invalid measurement.
import tof TOF.init() TOF.set4x4() def onDraw(): TOF.getData() for i in 16: print(TOF.data[i] + "mm (" + TOF.status[i] + ")") print("")
The IO library provides the IO object, which simplifies the control of hardware IOs.
Use writePin() to set an IO to either 0 (LOW) or 1 (HIGH).
Use setSampleRate() to determine the number of samples for averaging ADC measurements (IO06 & IO07).
Use readPin() to return the current state (0 or 1) of an IO.
import io def onDraw(): IO.writePin(C_PIN_01, 1) delay(500) IO.writePin(C_PIN_01, 0) delay(500)
import io IO.setSampleRate(1000) def onDraw(): if IO.readPin(C_PIN_01): IO.writePin(C_PIN_04, 1) else: IO.writePin(C_PIN_04, 0) if IO.readPin(C_PIN_06) > 200: IO.writePin(C_PIN_05, 1) else: IO.writePin(C_PIN_05, 0) delay(10)
C_PIN_06 and C_PIN_07 do not return a digital value (1 or 0) with readPin() but an analog value (0 to 4095).