SHT3x driver (#53)

* SHT3x driver
This commit is contained in:
Anthony Elder
2019-05-12 15:11:15 +01:00
committed by Ron Evans
parent d22cf7a3e1
commit 5930c149d9
5 changed files with 113 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
package main
import (
"fmt"
"machine"
"time"
"github.com/tinygo-org/drivers/sht3x"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
sensor := sht3x.New(machine.I2C0)
for {
temp, humidity, _ := sensor.ReadTemperatureHumidity()
t := fmt.Sprintf("%.2f", float32(temp)/1000)
h := fmt.Sprintf("%.2f", float32(humidity)/100)
println("Temperature:", t, "ºC")
println("Humidity", h, "%")
time.Sleep(2 * time.Second)
}
}