Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DHT ¶
type DHT struct {
// contains filtered or unexported fields
}
DHT struct to interface with the sensor. Call NewDHT to create a new one.
func NewDHT ¶
func NewDHT(pinName string, temperatureUnit TemperatureUnit, sensorType string) (*DHT, error)
NewDHT to create a new DHT struct. sensorType is dht11 for DHT11, anything else for AM2302 / DHT22.
func (*DHT) Read ¶
Read reads the sensor once, returing humidity and temperature, or an error. Note that Read will sleep for at least 2 seconds between last call. Each reads error adds a half second to sleep time to max of 30 seconds.
func (*DHT) ReadBackground ¶
func (dht *DHT) ReadBackground(humidity *float64, temperature *float64, sleepDuration time.Duration, stop chan struct{}, stopped chan struct{})
ReadBackground it meant to be run in the background, run as a Goroutine. sleepDuration is how long it will try to sleep between reads. If there is ongoing read errors there will be no notice except that the values will not be updated. Will continue to read sensor until stop is closed. After it has been stopped, the stopped chan will be closed. Will panic if humidity, temperature, or stop are nil.
type TemperatureUnit ¶
type TemperatureUnit int
TemperatureUnit is the temperature unit wanted, either Celsius or Fahrenheit
const ( // Celsius temperature unit Celsius TemperatureUnit = iota // Fahrenheit temperature unit Fahrenheit )