thermistor: add support for thermistors such as the NTC 3950

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2019-04-22 08:21:33 +02:00
parent c0cadf8d82
commit 59db5fef76
4 changed files with 114 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// This example uses the settings for the thermistor that is built in to the
// Adafruit Circuit Playground Express.
package main
import (
"machine"
"time"
"github.com/tinygo-org/drivers/thermistor"
)
const ADC_PIN = machine.TEMPSENSOR
func main() {
machine.InitADC()
sensor := thermistor.New(ADC_PIN)
sensor.Configure()
for {
temp, _ := sensor.ReadTemperature()
println("Temperature:", temp/1000, "ºC")
time.Sleep(2 * time.Second)
}
}