Add driver for TMP102 low-power digital temperature sensor (#141)

* tmp102: add driver and example
This commit is contained in:
Yannis Huber
2020-04-03 13:11:46 +02:00
committed by GitHub
parent ebceed6014
commit 6f213e97c3
4 changed files with 106 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"fmt"
"machine"
"time"
"tinygo.org/x/drivers/tmp102"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{
Frequency: machine.TWI_FREQ_400KHZ,
})
thermo := tmp102.New(machine.I2C0)
thermo.Configure(tmp102.Config{})
for {
temp, _ := thermo.ReadTemperature()
print(fmt.Sprintf("%.2f°C\r\n", float32(temp)/1000.0))
time.Sleep(time.Millisecond * 1000)
}
}