Skip to content

Commit 7d007b9

Browse files
committed
Adding an example (adafruit/circuitpython#493)
1 parent 6c281ed commit 7d007b9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/display_temperature.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import adafruit_thermistor
2+
import board
3+
import time
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+
pin = board.TEMPERATURE
9+
series_resistor = 10000
10+
nominal_resistance = 10000
11+
nominal_temperature = 25
12+
b_coefficient = 3950
13+
high_side_bool = True
14+
15+
thermistor = adafruit_thermistor.Thermistor(pin, series_resistor, nominal_resistance, nominal_temperature, b_coefficient, high_side=high_side_bool)
16+
17+
# print the temperature in C and F to the serial console every second
18+
while True:
19+
celsius = thermistor.temperature
20+
fahrenheit = (celsius * 9 / 5) + 32
21+
print('== Temperature ==\n{} *C\n{} *F\n'.format(celsius, fahrenheit))
22+
time.sleep(1)

0 commit comments

Comments
 (0)