# Compare resistance to a setpoint and trigger a relay

I want to compare a PTC thermistor to a set point, and trigger a relay if the temperature goes below a set temperature.

In particular, my temperature to turn on the relay should be 33 degrees F (845 ohms) and turn off at 36 degrees F (860 ohms).

I could easily do this with a microcontroller, but this seems like just too simple of a project to waste one on.

How can I accomplish this with basic electronic components?

• I've updated the question to indicate the type of thermistor and actual temperatures and resistances. Apr 17, 2012 at 16:51
• Do you have a part number for the thermistor ? Apr 17, 2012 at 16:55
• It is an entire probe assembly -- Love Controls TS-5 -- but I haven't managed to find a datasheet. I did some measurements though and found that it acts linearly. Apr 17, 2012 at 16:58
• OK, never mind. I've updated my answer. Apr 17, 2012 at 17:11

While I agree with Rocketmagnet's schematic (though I would decrease R4 to 1k$\Omega$) I can't agree with his calculation of resistor values. Copy of the schematic:

Rocketmagnet calculates for two different voltages on pin 3 of the comparator, which should represent the hysteresis. However, at both toggle points this voltage is the same, namely the voltage set on the inverting input using the potmeter.

edit
The confusion stems from the fact that the hysteresis feedback is added to the signal, rather than the reference voltage, which you would normally do. The consequence is that despite the hysteresis we only have one reference voltage: the voltage at the potmeter's wiper. A more common way to solve this would be to connect the potmeter with R5 to the non-inverting input and the signal to the inverting input. But we'll see that this works too.

Let's suppose the potmeter is set to 2.5V (could have been done with two resistors), and that the comparator's output swings between 0V and +5V ($V_{CC}$). The comparator should have a push-pull output. The comparator's output should go high when the NTC's resistance is 845$\Omega$. Until that moment the output is low, so that

$R5||R2 = 845\Omega$

to let the non-inverting input pass the 2.5V toggle point. Likewise, the comparator's output should go low when the NTC's resistance reaches 860$\Omega$. Until that moment the output is high, so that

$R2 = 860\Omega||R5$

So we have the following set of simultaneous equations:

$\begin{cases} \dfrac{R5 \times R2}{R5 + R2} = 845\Omega \\ \dfrac{860\Omega \times R5}{860\Omega + R5} = R2 \end{cases}$

which gives us

$\begin{cases} R2 = 852\Omega \\ R5 = 96.89k\Omega \end{cases}$

It's pretty easy with a comparator.

As the resistance of the thermistor goes down, it increases the voltage of the comparator's positive input (pin 3). When this input goes higher than the negative input (pin 2) the output will go high.

To set the threshold, you simply adjust the potentiometer.

The output of the comparator probably won't be able to drive a relay (check the current requirement of the relay, and the output drive of the comparator). So I have added a transistor which switches current to the relay.

Relays are inductive loads which will produce a negative voltage spike when they switch off. The diode will absorb this spike.

Hysteresis: Make sure that the comparator you choose has some built in hysteresis. E.G. LTC6702 or MAX9021. Alternatively, add a resistor (R5) to force some hysteresis.

You have now specified the exact on/off temperatures. These give voltages of 2.710v and 2.688v. Which is a hysteresis of 22mv. If my calculations are correct (probably not) then I think you need to use 100k for R5.

## Added 2: How to calculate R5

First, using the formula for parallel resistors, we calculate the effective resistance of RT1 and R2 as about 460 ohms.

Next, we use consider a potential divider formed by R5 on top and (RT1 & R2) at the bottom. For ease of calculation, assume that we have 2.5v at the bottom (generated by RT1 and R2).

Now, the question is, what value of R5 do we need if we want V to change by 0.022v. I.E. +-0.011v.

Using the 0v case, because it's simpler:

2.489v = (R5 / (R5+460)) * 2.5v

R5 = 460 / (2.5/2.489 - 1) = 104085

• You really need to add some hysteresis to this circuit, else it will bounce the relay. Apr 16, 2012 at 14:02
• @Telaclavo, Rocketmagnet - "Hysteresis is designed into most comparators, usually with a value of 5mV to 10mV." (source). The key word is "most". Better be safe than sorry, and by adding hysteresis yourself you can control the level as well. Apr 16, 2012 at 14:13
• Not fundamental ones like LM393, LM339... Apr 16, 2012 at 14:23
• I already upvoted, but it would be great if you could explain where the 200k value for the hysteresis resistor comes from. Calculation! :-) Apr 16, 2012 at 14:37
• Note that the schematic is for a comparator with push-pull output. Comparator outputs are often open collector. Apr 16, 2012 at 14:41

By your description, you're using an NTC thermistor. (This matters for the hysteresis.)

An easy way to do this is with a comparator like an LM393 and some sort of a voltage reference.

This circuit has a normally-low output. When the threshold is reached, the comparator changes state and the output goes high.

The inverting input has the NTC and a pull-up resistor. As the NTC heats up, its resistance drops and the voltage on on the pin will decrease. The non-inverting input has a divider acting as a voltage reference, plus an extra resistor going to the output which provides hysteresis.

• I'm just curious. Why did you say "this matters for the hysteresis"? Because the NTC has a negative (instead of positive) coefficient? Apr 16, 2012 at 15:13
• You need to know if the comparator is going to release when the threshold is reached, or pull down when the threshold is reached. This will impact the reference divider and hysteresis component value selections. Apr 16, 2012 at 18:10
• Actually, looks like I'm going to end up with a PTC thermistor. How do I correct for this? Apr 17, 2012 at 14:54
• If you use a PTC, the reference voltage should be set up so that the output is normally high. This is the opposite case of with an NTC, so you'll need to add a transistor or MOSFET to the output of the comparator to invert the logic. Apr 17, 2012 at 17:47
• What is the capacitor for? Is it to reduce noise? Aug 18, 2017 at 5:08