Exemple #1
0
func TestNew(t *testing.T) {
	temp, err := tempered.New()

	if err != nil {
		t.Fatalf("New failed: %v", err)
	}

	if len(temp.Devices) == 0 {
		t.Error("Devices is empty")
	}
}
Exemple #2
0
func main() {
	t, err := tempered.New()
	if err != nil {
		log.Fatal(err)
	}
	defer t.Close()

	sensing, err := t.Devices[0].Sense()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%.2f°C %.1f%%RH\n", sensing.TempC, sensing.RelHum)
}