add: humidity (WIP)

This commit is contained in:
2018-12-04 19:11:50 +01:00
parent ba9f0c59f3
commit 81600154f0
141 changed files with 18562 additions and 4 deletions

30
pkg/humidity/humidity.go Normal file
View File

@ -0,0 +1,30 @@
package humidity
import (
"fmt"
dht "github.com/MichaelS11/go-dht"
)
func Get() error {
err := dht.HostInit()
if err != nil {
return fmt.Errorf("HostInit error: %v", err)
}
dht, err := dht.NewDHT("GPIO19", dht.Celsius, "dht11")
if err != nil {
return fmt.Errorf("NewDHT error: %v", err)
}
humidity, temperature, err := dht.ReadRetry(10)
if err != nil {
return fmt.Errorf("Read error: %v", err)
}
fmt.Printf("humidity: %v\n", humidity)
fmt.Printf("temperature: %v\n", temperature)
return nil
}