tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/shtc3/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "machine" 6 "time" 7 8 "tinygo.org/x/drivers/shtc3" 9 ) 10 11 func main() { 12 13 machine.I2C0.Configure(machine.I2CConfig{}) 14 sensor := shtc3.New(machine.I2C0) 15 16 for { 17 18 sensor.WakeUp() 19 20 temp, humidity, _ := sensor.ReadTemperatureHumidity() 21 t := fmt.Sprintf("%.2f", float32(temp)/1000) 22 h := fmt.Sprintf("%.2f", float32(humidity)/100) 23 println("Temperature:", t, "°C") 24 println("Humidity", h, "%") 25 26 sensor.Sleep() 27 28 time.Sleep(2 * time.Second) 29 } 30 }