Tino Hempel
Published © CC BY

CO2-Ampel mit Calliope und CCS811-Sensor

Vorgestellt wird eine CO2-Ampel, die mithilfe des Sensors CCS811 am Calliope realisiert wird. Das Projekt funktioniert so auch am Microbit.

BeginnerFull instructions provided1 hour1,001
CO2-Ampel mit Calliope und CCS811-Sensor

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1
CCS811-Board
beliebiges CCS811-Modul ohne großen Schnickschnack
×1
Grove - OLED Display 1.12'' V2
Seeed Studio Grove - OLED Display 1.12'' V2
optional
×1
Seeed Studio Grove I2C Hub
optional, falls OLED-Display
×1

Software apps and online services

MakeCode
Microsoft MakeCode
für Calliope/Microbit

Story

Read more

Code

Programm für MakeCode ohne Erweiterungen

Typescript
https://makecode.calliope.cc/_giRcze520L9v
input.onButtonPressed(Button.A, function () {
    Zahlencodierung.zeigeNSorobancodiertAn(co2)
})
input.onButtonPressed(Button.AB, function () {
    t_ton = !(t_ton)
})
input.onButtonPressed(Button.B, function () {
    Zahlencodierung.zeigeNSorobancodiertAn(tvoc)
})
let tvoc = 0
let co2 = 0
let t_ton = false
SG33.address(true)
t_ton = true
basic.forever(function () {
    co2 = SG33.eCO2()
    tvoc = SG33.TVOC()
    if (co2 < 1000 && tvoc < 400) {
        basic.setLedColor(0x00ff00)
    } else if (co2 < 1400 && tvoc < 400) {
        basic.setLedColor(0xff0000)
    } else {
        basic.setLedColor(0x0000ff)
        if (t_ton) {
            music.playMelody("C5 B A G F E D C ", 200)
        }
    }
    basic.pause(10000)
    basic.clearScreen()
})

Programm für MakeCode Calliope mit Erweiterungen

Typescript
https://makecode.calliope.cc/_8vXVC7Ljy0mf
input.onButtonPressed(Button.A, function () {
    Zahlencodierung.zeigeNSorobancodiertAn(co2)
})
function zeigeWerte () {
    oledssd1306.clearDisplay()
    oledssd1306.setTextXY(0, 0)
    oledssd1306.writeString("Messwerte")
    oledssd1306.setTextXY(1, 0)
    oledssd1306.writeString("--------------------")
    oledssd1306.setTextXY(3, 0)
    oledssd1306.writeString("CO2: ")
    oledssd1306.writeNumber(co2)
    oledssd1306.setTextXY(4, 0)
    oledssd1306.writeString("TVOC: ")
    oledssd1306.writeNumber(tvoc)
}
input.onButtonPressed(Button.AB, function () {
    t_ton = !(t_ton)
})
input.onButtonPressed(Button.B, function () {
    Zahlencodierung.zeigeNSorobancodiertAn(tvoc)
})
let tvoc = 0
let co2 = 0
let t_ton = false
SG33.address(true)
t_ton = true
radio.setGroup(2)
oledssd1306.initDisplay()
oledssd1306.flipScreen()
basic.forever(function () {
    co2 = SG33.eCO2()
    tvoc = SG33.TVOC()
    if (co2 < 1000 && tvoc < 400) {
        basic.setLedColor(0x00ff00)
    } else if (co2 < 1400 && tvoc < 400) {
        basic.setLedColor(0xff0000)
    } else {
        basic.setLedColor(0x0000ff)
        if (t_ton) {
            music.playMelody("C5 B A G F E D C ", 200)
        }
    }
    zeigeWerte()
    radio.sendValue("CO2: ", co2)
    radio.sendValue("TVOC: ", tvoc)
    basic.pause(10000)
    basic.clearScreen()
})

Credits

Tino Hempel

Tino Hempel

12 projects • 6 followers

Comments