Giter Club home page Giter Club logo

thermistor's Introduction

Thermistor

The Thermistor class provides easy access to a thermistor device and supports onboard three-point calibration using the Steinhart-Hart equation.

Dependencies

Thermistor requires the SafetyPin library, which may be found here.

Usage

Circuit

A thermistor is a passive two-terminal component with a resistance strongly dependent on temperature. It is easy to measure a thermistor's resistance by constructing a voltage divider using a known resistance and measuring the resulting potential:

schematic

Calibration

Although the resistance varies with temperature, getting from the observed resistance to the actual temperature isn't trivial. Most thermistors are highly nonlinear, so naive two-point calibration only works over small intervals. Fortunately, the behavior is well described by the Steinhart-Hart equation. This empirically-derived relation includes three coefficients, and calibration amounts to solving for their values given three observed temperatures and resistances.

The Thermistor library makes this calibration process relatively easy. When a new Thermistor object is created it is uncalibrated and will return incorrect temperature values. Before using it, you should call calibrate(t1, v1, t2, v2, t3, v3) , with three observed temperature (°F) and voltage ([0..1023]) values, well separated and spanning at least the temperature range of interest. Thermistor will internally calculate the corresponding coefficients and use them for subsequent calls to temperature(). If you want to store the calibration data across restarts, just store the inputs and call calibrate() in your setup method.

Synopsis:

Thermistor(AnalogIn& pin, unsigned int Rb);

Constructs a thermistor object.

  • AnalogIn& pin analog input pin attached to GND via a resistor of value Rb ohms and to Vcc via the thermistor.
  • unsigned int Rb value in ohms of the balance resistor
temperature_t temperature();

Returns the current temperature in °F.

float raw();

Returns a raw analog reading from the temperature sensor [0 .. 1023], averaged to reduce noise but unscaled.

void calibrate(  temperature_t T1, const float& V1, 
                 temperature_t T2, const float& V2, 
                 temperature_t T3, const float& V3);

Calibrates the probe given three temperatures in Fahrenheit and three corresponding analog sensor readings in the range [0..1023].

  • temperature_t T1, T2, T3 temperature values for the three sample points
  • float V1, V2, V3 corresponding sensor reading values for the three samples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.