mhz19b

package module
v0.0.0-...-c3791ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2021 License: MIT Imports: 3 Imported by: 1

README

go-mh-z19b

二酸化炭素濃度計「MH-Z19B」のGo言語ライブラリ

センサーについて

MH-Z19B(データシート) は安価な二酸化炭素濃度計として有名です。

インストール

$ go get -u github.com/macaron/go-mh-z19b

サンプルコード

func main() {
    mhz19b := mhz19b.New("/dev/serial0")
    ppm, err := mhz19b.Read()
    
    if err != nil {
    	log.Fetal(err)
    }
    fmt.Printf("CO2 = %dppm\n", ppm)

    // If you want to reset the sensor ZERO point
    // mhz19b.CalibrateDefault()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(device string) (ppm int, err error)

Types

type MHZ19B

type MHZ19B struct {
	SerialConfig *serial.Config
}

func New

func New(device string) *MHZ19B

func (*MHZ19B) CalibrateDefault

func (mhz19b *MHZ19B) CalibrateDefault() error

func (*MHZ19B) Read

func (mhz19b *MHZ19B) Read() (int, error)

Directories

Path Synopsis
cmd
mhz19b command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL