dht

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DHT11 DeviceType = iota
	DHT22

	C TemperatureScale = iota
	F

	ChecksumError ErrorCode = iota
	NoSignalError
	NoDataError
	UpdateError
	UninitializedDataError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device interface {
	DummyDevice
	Configure(policy UpdatePolicy)
}

Device interface provides main functionality of the DHTXX sensors.

func New

func New(pin machine.Pin, deviceType DeviceType) Device

Constructor of the Device implementation. This implementation updates data every 2 seconds during data access.

func NewWithPolicy

func NewWithPolicy(pin machine.Pin, deviceType DeviceType, updatePolicy UpdatePolicy) Device

Constructor of the Device implementation with given UpdatePolicy

type DeviceType

type DeviceType uint8

enum type for device type

type DummyDevice

type DummyDevice interface {
	ReadMeasurements() error
	Measurements() (temperature int16, humidity uint16, err error)
	Temperature() (int16, error)
	TemperatureFloat(scale TemperatureScale) (float32, error)
	Humidity() (uint16, error)
	HumidityFloat() (float32, error)
}

DummyDevice provides a basic interface for DHT devices.

func NewDummyDevice

func NewDummyDevice(pin machine.Pin, deviceType DeviceType) DummyDevice

Constructor function for a DummyDevice implementation. This device provides full control to the user. It does not do any hidden measurements calls and does not check for 2 seconds delay between measurements.

type ErrorCode

type ErrorCode uint8

All functions return ErrorCode instance as error. This class can be used for more efficient error processing

func (ErrorCode) Error

func (e ErrorCode) Error() string

error interface implementation for ErrorCode

type TemperatureScale

type TemperatureScale uint8

Celsius and Fahrenheit temperature scales

type UpdatePolicy

type UpdatePolicy struct {
	UpdateTime          time.Duration
	UpdateAutomatically bool
}

Update policy of the DHT device. UpdateTime cannot be shorter than 2 seconds. According to dht specification sensor will return undefined data if update requested less than 2 seconds before last usage

Jump to

Keyboard shortcuts

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