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
 5import board
 6import adafruit_thermistor
 7
 8# these values work with the Adafruit CircuitPlayground Express.
 9# they may work with other thermistors as well, as they're fairly standard,
10# though the pin will likely need to change (ie board.A1)
11# pylint: disable=no-member
12pin = board.TEMPERATURE
13resistor = 10000
14resistance = 10000
15nominal_temp = 25
16b_coefficient = 3950
17
18thermistor = adafruit_thermistor.Thermistor(
19    pin, resistor, resistance, nominal_temp, b_coefficient
20)
21
22# print the temperature in C and F to the serial console every second
23while True:
24    celsius = thermistor.temperature
25    fahrenheit = (celsius * 9 / 5) + 32
26    print("== Temperature ==\n{} *C\n{} *F\n".format(celsius, fahrenheit))
27    time.sleep(1)