Read CO2 concentration from MH-Z19 on Raspberry Pi.
$ go get github.com/kebhr/mhz19/cmd/mhz19
$ mhz19
{"co2": "554"}
package main
import (
"log"
"github.com/kebhr/mhz19"
)
func main() {
m := mhz19.MHZ19{}
myDevicePath := "/dev/ttyS0"
if err := m.Connect(myDevicePath); err != nil {
log.Fatal(err)
}
v, err := m.ReadCO2()
if err != nil {
log.Fatal(err)
}
log.Printf("CO2 Concentration: %dppm\n", v)
}