From 7d007b91f9c4d384713d5a650a129f6297780998 Mon Sep 17 00:00:00 2001 From: Dan Conley Date: Thu, 4 Jan 2018 17:21:39 -0500 Subject: [PATCH 1/2] Adding an example (adafruit/circuitpython#493) --- examples/display_temperature.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/display_temperature.py diff --git a/examples/display_temperature.py b/examples/display_temperature.py new file mode 100644 index 0000000..ffb168f --- /dev/null +++ b/examples/display_temperature.py @@ -0,0 +1,22 @@ +import adafruit_thermistor +import board +import time + +# these values work with the Adafruit CircuitPlayground Express. +# they may work with other thermistors as well, as they're fairly standard, +# though the pin will likely need to change (ie board.A1) +pin = board.TEMPERATURE +series_resistor = 10000 +nominal_resistance = 10000 +nominal_temperature = 25 +b_coefficient = 3950 +high_side_bool = True + +thermistor = adafruit_thermistor.Thermistor(pin, series_resistor, nominal_resistance, nominal_temperature, b_coefficient, high_side=high_side_bool) + +# print the temperature in C and F to the serial console every second +while True: + celsius = thermistor.temperature + fahrenheit = (celsius * 9 / 5) + 32 + print('== Temperature ==\n{} *C\n{} *F\n'.format(celsius, fahrenheit)) + time.sleep(1) From a86eaeb556420fc2deea3bb1711b4cd621543457 Mon Sep 17 00:00:00 2001 From: Dan Conley Date: Thu, 4 Jan 2018 17:37:49 -0500 Subject: [PATCH 2/2] fixing pylint errors --- examples/display_temperature.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/display_temperature.py b/examples/display_temperature.py index ffb168f..5fc1147 100644 --- a/examples/display_temperature.py +++ b/examples/display_temperature.py @@ -1,18 +1,17 @@ +import time import adafruit_thermistor import board -import time # these values work with the Adafruit CircuitPlayground Express. # they may work with other thermistors as well, as they're fairly standard, # though the pin will likely need to change (ie board.A1) pin = board.TEMPERATURE -series_resistor = 10000 -nominal_resistance = 10000 -nominal_temperature = 25 +resistor = 10000 +resistance = 10000 +nominal_temp = 25 b_coefficient = 3950 -high_side_bool = True -thermistor = adafruit_thermistor.Thermistor(pin, series_resistor, nominal_resistance, nominal_temperature, b_coefficient, high_side=high_side_bool) +thermistor = adafruit_thermistor.Thermistor(pin, resistor, resistance, nominal_temp, b_coefficient) # print the temperature in C and F to the serial console every second while True: