Temperature control using a NTC Thermistor (10K) and a 5V Cooler.

Introduction: The Thermistor is a resistor type that varies your resistance according to your temperature. Composed, generally, of polymers or ceramic, they have a relatively short operational range (−90 °C ~ 130 °C), but they’re also have a good precision and good price.

Through a First-order approximation, we can draw a linear relationship between the thermal and resistive variation:

ΔR = kΔT

Where:

ΔR = Resistive Variation;

ΔT = Thermal Variation;

k = First Order approximation coefficient (T or R).

In practical terms, the approximation above only works in a small operational range. Therefore, we use a more precise approximation, known as "Steinhart−Hart Equation". This Third order approximation is described by:

1/T = a + b ln(R) + c (ln(R))3

Where:

R = Resistance in Ohms;

ΔT = Temperature in Kelvin;

a, b and c = Steinhart−Hart parameters (normally found on the NTC datasheet).

To the following experience, we are going to use a simplifed version of this equation, using only one parameter (B) to convert the mV signal received by the Galileo’s ADC to degree Celsius (°C).

Components needed:

→ A NTC Thermistor (10K);

NTC

→ 5V Mini Cooler

NTC

→ A TIP120 NPN Transistor (or equivalent);

→ One 1N4007 Diode;

→ One 10k Ohm resistor;

→ One 3.3k Ohm resistor;

→ Protoboard;

→ Jumpers.

1st Step:

On a Protoboard, assemble the circuit below:

Proto3

Where:

→ Red wires and black wires referes to VCC 5V and GND, respectively;

→ The orange wire connects the voltage through the internal resistance of the thermistor to an ADC (A0);

→ The Green Wire connects the signal (PWM or not) that will turn the motor on with the Galileo.

Schematic

Schem3

2nd Step:

Upload the following code to Galileo, using the Arduino IDE or compiling directly from Linux terminal:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
    const int pinTemp = A0; // Temperature sensor pin
    float temperatura;
    int B=3975; // A common B Value between NTC thermistors.
    float resistencia;
       
    void setup() {
        Serial.begin(9600);
              }
    void loop () {
      int val = analogRead(pinTemp); // Acquiring the received values on A0
      resistencia=(float)(1023-val)*10000/val; // Acquiring resistance value
      temperatura=1/(log(resistencia/10000)/B+1/298.15)-273.15; /* Calculating the Celsius temperature through a simplified version of Steinhart-Hart equation */
      Serial.println(temperatura);
      delay(1000); //Delay 1s between readings
      }
     
print3

3rd step:

Now, with the cooler towards the thermistor, we will make a temperature control switching the cooler on/off when the temperature read by the sensor is higher than a preset value (in the exemple, 30 °C). For an easily comprehension of this experience, you can approach the NTC sensor to a heat source (as an incandescent lamp, or ever touching the sensor with your fingers) to can get faster results. The code that makes this “On/Off” control is the following:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
    const int pinTemp = A0; // Temperature sensor pin
    const int pinCooler = 3; //Cooler Pin
    float temperatura;
    int B=3975; // A common B Value between NTC thermistors.
    float resistencia;
       
    void setup() {
        Serial.begin(9600);
        pinMode(pinCooler,OUTPUT);
              }
    void loop () {
      int val = analogRead(pinTemp); // Acquiring the received values on A0
      resistencia=(float)(1023-val)*10000/val; // Acquiring resistance value
      temperatura=1/(log(resistencia/10000)/B+1/298.15)-273.15; /* Calculating the Celsius temperature through a simplified version of Steinhart-Hart equation */
     
if (temperatura > 30.00) //This if describes the On/Off control (or Switched)
      {
     
digitalWrite(pinCooler,HIGH);
      }else
     
{
     
digitalWrite(pinCooler,LOW);
     
}
      Serial.println(temperatura);
      delay(1000); //Delay 1s between readings
      }
     

Note: This type of control isn’t very efficient in industrial regimes. In these cases the control usually have proportional, integrative and derivative parameters. Albeit, for didactic purposes, this simple control serves us well.