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