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.
P19
-- I2C - SCLP20
-- I2C - SDA 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.
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.
|CCS811 Start|
block sets the CCS811 sensor into APP MODE - basically turns it on and ready to transmit data|Read eCO2|
block reads the equivalent CO2 and can be any number between 400ppm and 8182ppm. |Read TVOCs|
block reads the total organic volatile compounds and can be any number between 0ppb to 1187ppb. |Device Error|
block is used while troubleshooting otherwise don't use it. It will return a number corresponding to a specific error on the CCS811.|Device Status|
block is used while troubleshooting otherwise don't use it. |HWID|
block is used to test the most basic read on the I2C line. Use if you are having probelms establishing communication. 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()
MIT
airQuality=github:ADataDate/pxt-airQuality