mhz19

package module
v0.0.0-...-85bb7fd Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 2 Imported by: 1

README

mhz19

Read CO2 concentration from MH-Z19 on Raspberry Pi.

Installation

$ go get github.com/kebhr/mhz19/cmd/mhz19

Usage

$ mhz19
{"co2": "554"}

Use as a library

package main

import (
	"log"
	"github.com/kebhr/mhz19"
)

func main() {
	m := mhz19.MHZ19{}
	if err := m.Connect(); err != nil {
		log.Fatal(err)
	}
	v, err := m.ReadCO2()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("CO2 Concentration: %dppm\n", v)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Co2Dataloader

type Co2Dataloader interface {
	Connect() error
	ReadCO2() (int, error)
}

type MHZ19

type MHZ19 struct {
	// contains filtered or unexported fields
}

func (*MHZ19) Connect

func (m *MHZ19) Connect() error

func (*MHZ19) ReadCO2

func (m *MHZ19) ReadCO2() (int, error)

type MockMHZ19

type MockMHZ19 struct {
	Value int
}

func (*MockMHZ19) Connect

func (m *MockMHZ19) Connect() error

func (*MockMHZ19) ReadCO2

func (m *MockMHZ19) ReadCO2() (int, error)

Directories

Path Synopsis
cmd
mhz19 command

Jump to

Keyboard shortcuts

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