mhz19

package module
v0.0.0-...-853cd2f Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mhz19

Read CO2 concentration from MH-Z19 on Raspberry Pi.

Installation

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

Usage

$ mhz19
554

Use as a library

package main

import (
	"fmt"
	"os"

	"github.com/tmsc4zht/mhz19"
)

func main() {
	m := mhz19.New("/dev/serial0")
	v, err := m.ReadCO2()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(-1)
	}
	fmt.Println(v)
}

Differences from the original version

  • You can select serial device file to use.
  • Close serial port after read value.
  • Calc checksum.
  • mhz19 prints only numeric value.
  • mhz19 returns -1 when error happens.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(name string) *Client

func (*Client) ReadCO2

func (m *Client) 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
⌂ 换网址