mhz19

package module
v0.0.0-...-96bde45 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 2 Imported by: 2

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{}
	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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MHZ19

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

func (*MHZ19) Connect

func (m *MHZ19) Connect(devicePath string) error

func (*MHZ19) ReadCO2

func (m *MHZ19) 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