add: humidity (WIP)
This commit is contained in:
30
pkg/humidity/humidity.go
Normal file
30
pkg/humidity/humidity.go
Normal 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
|
||||
}
|
@ -85,7 +85,7 @@ func ListTemperatures(configDir string, w io.Writer) error {
|
||||
// print headline
|
||||
fmt.Fprint(tw, "\t")
|
||||
for _, sensor := range sensors {
|
||||
fmt.Fprintf(tw, "%v\t", sensor.HumanName())
|
||||
fmt.Fprintf(tw, "%v\t", sensor.ReadableSensorName())
|
||||
}
|
||||
if len(sensors) > 0 {
|
||||
fmt.Fprint(tw, "\n")
|
||||
|
Reference in New Issue
Block a user