Introduction

Documentation Status Discord Build Status

Thermistors are resistors that predictably change resistance with temperature. This driver uses an analog reading and math to determine the temperature. They are commonly used as a low cost way to measure temperature.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-thermistor

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-thermistor

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-thermistor

Usage Example

The hardest part of using the driver is its initialization. Here is an example for the thermistor on the Circuit Playground and Circuit Playground Express. Its a 10k series resistor, 10k nominal resistance, 25 celsius nominal temperature and 3950 B coefficient.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

Table of Contents

Simple test

Ensure your device works with this simple test.

examples/thermistor_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import time
import board
import adafruit_thermistor

# 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)
# pylint: disable=no-member
pin = board.TEMPERATURE
resistor = 10000
resistance = 10000
nominal_temp = 25
b_coefficient = 3950

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:
    celsius = thermistor.temperature
    fahrenheit = (celsius * 9 / 5) + 32
    print('== Temperature ==\n{} *C\n{} *F\n'.format(celsius, fahrenheit))
    time.sleep(1)

adafruit_thermistor

A thermistor is a resistor that varies with temperature. This driver takes the parameters of that resistor and its series resistor to determine the current temperature. To hook one up, connect an analog input pin to the connection between the resistor and the thermistor. Be careful to note if the thermistor is connected on the high side (from analog input up to high logic level/3.3 or 5 volts) or low side (from analog input down to ground). The initializer takes an optional high_side boolean that defaults to True and indicates if that the thermistor is connected on the high side vs. low side.

  • Author(s): Scott Shawcroft

Implementation Notes

Hardware:

Software and Dependencies:

Notes:

  1. Check the datasheet of your thermistor for the values.
class adafruit_thermistor.Thermistor(pin, series_resistor, nominal_resistance, nominal_temperature, b_coefficient, *, high_side=True)[source]

Thermistor driver

temperature

The temperature of the thermistor in celsius

Indices and tables