Simple test

Ensure your device works with this simple test.

examples/thermistor_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7
 8import adafruit_thermistor
 9
10# these values work with the Adafruit CircuitPlayground Express.
11# they may work with other thermistors as well, as they're fairly standard,
12# though the pin will likely need to change (ie board.A1)
13pin = board.TEMPERATURE
14resistor = 10000
15resistance = 10000
16nominal_temp = 25
17b_coefficient = 3950
18
19thermistor = adafruit_thermistor.Thermistor(pin, resistor, resistance, nominal_temp, b_coefficient)
20
21# print the temperature in C and F to the serial console every second
22while True:
23    celsius = thermistor.temperature
24    fahrenheit = (celsius * 9 / 5) + 32
25    print(f"== Temperature ==\n{celsius} *C\n{fahrenheit} *F\n")
26    time.sleep(1)