ADataDate / pxt-airQuality

Makecode Package for the CCS811 Air Quality Sensor
MIT License
5 stars 6 forks source link

airQuality

SparkFun Air Quality Breakout - CCS811

This package adds functionality to the weather:bit board sold by SparkFun.

To use this package, go to https://makecode.microbit.org, click Add Package and search for: https://github.com/ADataDate/pxt-airQuality in the search bar.

~

This package is still under development and subject to changes.

~

Usage

Micro:bit Pins Used

CCS811 Start Function

The first block in the AirQuality package is the |CCS811 Start| block. At the start of any program which will use the air quality sensor place the |CCS811 Start| block in a "Forever" block above the rest of your code.

Air Quality Data

The CCS811 air quality sensors communicates via I2C. The data returned as a number can be stored in a variable, displayed on the 5x5 LED Matrix or sent serially to OpenLog.

Example Project:

The following project will read the eCO2 and TVOCs data and then display it on the 5x5 LED matrix.

let eCO2 = 0
let TVOCs = 0
basic.forever(() => {
    TVOCs = airQuality.readTvoc()
    eCO2 = airQuality.readCo2()
    basic.showString("TVOC")
    basic.showNumber(TVOCs)
    basic.pause(1000)
    basic.showString("eCO2")
    basic.showNumber(eCO2)
    basic.pause(1000)
})
airQuality.appStart()

License

MIT

Supported targets

airQuality=github:ADataDate/pxt-airQuality