mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-10 09:53:42 +00:00
thermistor: add support for thermistors such as the NTC 3950
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user