Library for using common NTC thermistors. Uses Steinhart-Hart A, B, C coefficients.

Thermistor Library

Copyright 2020 Jonathan L. Martin <jon.martini@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Reads a thermistor given the Steinhart-Hart coefficients (A, B, C) and R1

For information on the Steinhart-Hart equation see: https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation

If you have the datasheet for a thermistor but not the A, B, and C coefficients it is recommended you use a tool such as: https://www.thinksrs.com/downloads/programs/therm%20calc/ntccalibrator/ntccalculator.html

Pick three temperatures within the expected range of values you expect in your application, then lookup the nominal resistance expected for the thermistor from its datasheet. For instance for an NTC 3950 at 100K and 1% accuracy thermistor the follow values are provided from its datasheet:

5 C = 254,800 Ohm 25 C = 100,000 Ohm 50 C = 35,900 Ohm

This gives Steinhart-Hart coefficients of: A = 0.6172273387e-3 B = 2.287682172e-4 C = 0.6749479638e-7

We generally use an R1 value close to the resistance at our expected nominal temperature.

So in this case we choose a 100 KOhm resistor as a pull up. Our AnalogIn pin on an mbed NXP LPC1768 has a 0.0V to 3.3V range, so we pull up to 3.3V.

Changes

RevisionDateWhoCommit message
0:f84068436aca 2020-11-21 demartini Initial Commit; default tip