Skip to content

Commit 3d4c908

Browse files
authored
Merge pull request #2 from Sigafoos/examples
Adding an example (adafruit/circuitpython#493) #2 adafruit/circuitpython#493 Thanks, tried it out and work great.
2 parents 6c281ed + a86eaeb commit 3d4c908

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/display_temperature.py

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

0 commit comments

Comments
 (0)