Version 11

    element14's The Ben Heck Show

    Join Karen as she shares her enthusiasm for teaching STEM subjects, gives you what you need to know to get started on electronics projects, and more.

    Back to The Ben Heck Show homepage

    The Learning Circuit
    Featured Bonus Content
    See All Episodes


    DaftMike builds a thermometer using an Arduino and a thermistor.  He’ll write some Arduino code, build a circuit, and then convert the values into a temperature reading.  He’ll use an NTC thermistor as a sensor. This is a special type of resistor whose resistance changes with temperature. In order to read it with an Arduino he’s going to build a circuit on a breadboard.  This will require some wire and a 100K resistor.

    Make Your Own!

    Parts & Products:

    Product Name

    UK Part No

    US Part No

    Part Link

    Arduino Micro228519463W3544Buy NowBuy Now
    Thermistor211293510M5320Buy NowBuy Now



    For this project, DaftMike will use an Arduino MicroArduino Micro because it plugs directly into the breadboard but you can use any Arduino you like. He uses wire to connect 5 volts to the top power rail and ground to the bottom power rail. There are usually multiple ground pins (marked ‘GND’).  You can connect to any of these.  He connects the thermistorthermistor to 5V and in the same column he connects the resistor to ground.  It doesn’t matter which way around these components go, they work either way.  Finally, you connect midpoint to analog pin p0.   You can now write some code:


        Episode 15: Make Your Own Thermometer
    // Parameters for the voltage divider equation
    const int Vin = 1023;
    const long R2 = 100000;                         // measure this resistor and update this value for better accuracy
    // Parameters for the Steinhart?Hart equation
    const float T0 = 298.15;
    const int B = 3974;
    const long R0 = 100000;
    const int thermistorPin = A0;
    const int numReadings = 10;                     // number of readings to average
    int readings[numReadings];                      // array to store thermistor readings
    void setup() {
      Serial.begin(9600);                           // setup serial monitor
    void loop() {
      float Vout;
      for (int i = 0; i < numReadings; i++) {
        readings[i] = analogRead(thermistorPin);    // read from the thermistorPin into the array
        Vout += readings[i];                        // sum the readings so far
        delay(10);                                  // allow the ADC to settle between loops
      Vout /= numReadings;        // divide the running total by the number of readings to get an average
    // Voltage Divider equation to calculate R1
      float R1;
      R1 = (R2 * (Vin - Vout)) / Vout;
    // ? parameter equation:
      float T;
      T = (1.0 / ((1.0 / T0) + (log((R1 / R0)) / B))) - 273.15;     // T is in Celcius
    // Celcius to Farenheit conversion
      float Tf;
      Tf = (T * 9.0) / 5.0 + 32;
    // Print the temperature in Celcius and Farenheit to the serial monitor
      Serial.print(T); Serial.print("C | ");   Serial.print(Tf); Serial.println("F");


    He names the thermistor pin and sets up an array to store a bunch of readings so that you can take an average to sort out the data.  He uses a line to set up the serial monitor.  In the main code he declares the output as a float and then uses a for loop to calculate the average.  A thermistor reading is stored in the array, added to a running total, and then delayed for a while to give the ADC a chance to settle before it runs through the loop again.  ADC stands for analog to digital convertor.  It converts voltage on the analog pin into a discrete signal.  Outside that loop, the code divides the running total by the number of readings to get an average.  You can then print it to the terminal.


    DaftMike gives a diagram of the circuit. It’s a voltage divider where R1 is the thermistor and R2 is 100K. The equation for voltage dividers is Vout = Vin *R2/(R1+R2).  Vout is what we measured in the code, Vin is 5 volts, R2 is 100K, and R1 is what we are solving for.