Sensirion Sht4x Support (#597)

sht4x: implemented driver
This commit is contained in:
Thomas
2023-09-19 08:31:43 +02:00
committed by GitHub
parent a9b36f8bd4
commit 5888bb2ded
3 changed files with 100 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package main
import (
"fmt"
"machine"
"time"
"tinygo.org/x/drivers/sht4x"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
sensor := sht4x.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)
}
}