mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-06 07:53:41 +00:00
shtc3: Sensirion SHTC3 Relative Humidity / Temperature i2c sensor
This commit is contained in:
committed by
Ron Evans
parent
121e8147f7
commit
025a66655f
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers/shtc3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
machine.I2C0.Configure(machine.I2CConfig{})
|
||||
sensor := shtc3.New(machine.I2C0)
|
||||
|
||||
for {
|
||||
|
||||
sensor.WakeUp()
|
||||
|
||||
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, "%")
|
||||
|
||||
sensor.Sleep()
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user