Tags

,

One of the sensors on the Healthy pH Shield is a thermistor.  The thermistor is used to read the temperature of the bath.  As noted in other posts (like this one), the pH is relative to the temperature.

The Goal

The goal of this post is to walk through the implementation of the thermistor for taking temperature readings and describe the diagnostic tests that will be used to make sure temperature readings are available.

Thanks to Those That Went Before

Adafruit provides great tutorials.  I used their thermistor tutorials for this effort.

Thanks to Gerald Rectenwald for his excellent class notes on thermistors.  They were easy to read and useful.

As always – a huge thank you to Chris Gammell.  His Contextual Electronics and additional guidance has made it possible for me to even attempt this effort.

Ryan (Sparky’s Widgets) has provided us with an open hardware pH and E.C. sensors as well as incredibly useful guidance.

A Voltage Divider Circuit

A drawing and explanation of the circuit was done in this post.  

Thermistor Schematic to Real

Finding the temperature means figuring out what the resistance value is of the thermistor….yet another example of a voltage divider circuit.  

ThermistorVoltageDividerCircuit

Solve for Rtherm

I found a wonderful document written as class notes by Gerald Rectenwald: “Temperature Measurement With a Thermistor and an Arduino.”  The document does a great job in explaining what I’ll state in summary.

Measuring Temperature

There are two steps to getting to a temperature reading:

  • Solve for Rtherm
  • Use an equation from a really smart person (people?) to convert Rtherm  to a temperature.

Solve for Rtherm

I can see the first step since finding Rtherm  is an application of Ohm’s law and keeping in mind what Gerald Rectenwald states: “Electrical resistance is always measured indirectly, usually by inferring the resistance from a measured voltage drop”.  In this case the measured Voltage drop, Vo, is the voltage we get from the ADC.  Now I need an equation or two so that I can solve for Rtherm .  
since the resistors are in series, the current (I) is the same throughout the circuit…this leads to:
Vs= I(R+Rtherm)

Vo = IR
The two unknowns then are I and Rtherm. I can be substituted with Vo/R. This gives an equation with just Rtherm not known:
Vs = (Vo/R)(R+Rtherm)
Rtherm = R(Vs/Vo – 1)

Substituting in what is known and can be measured:
Rherm = 10,0000(5/M – 1)
where M = the voltage measurement read from the ADC.

Calculate the Temperature

In Gerald Rectendwald’s class notes, he says “the thermistor temperature can be computed with the Steinhart-Hart equation:

Steinhart-Hart Equation

…GULP…if you say so…Now I just plug in…hey wait – first I would need to find C1, C2, and C3….luckily, there is a simpler way as noted in Adafruit’s thermistor tutorial, there is a B parameter equation.  

AdafruitBParamThermistor

I assume this way of calculating the temperature is “good enough” because – hey both Adafruit and Wikipedia talk about it :-).  Whether this works well will ultimately be determined by the temperature values I read when compared to other ways of reading the temperature.  Adafruit notes B = 3950.  For the 10K thermistor I am using, the data sheet notes B = 3977.  Adafruit uses Ro for Rtherm.  To is room temperature.  Adafruit uses 25˚C = 298.15K… At this point I’m going to be lazy and assume this value for To will “just work.”  Again, measurements will prove out whether my laziness is justified.

Testing the Circuit

I soldered together two wires to a 10K Thermistor so that I could easily hook the two wires up to pins 3 and 4 on the 8 pin terminal block.

pinsOn8TBForThermistor

 

 
I did this before I discovered Gerald Rectendwald’s “How To” on “Fabricating a (Reasonably) Waterproof Thermistor Probe“. 

The schematic for the thermistor is located in the kicad Temperture.sch file (located in this GitHub repository for Dev-Rev2).  

Thermistor Schematic

the schematic is pretty much a duplicate of the voltage divider circuit I showed a picture of earlier.  Before figuring out the temperature, I calculate Rtherm.  I used a DMM to get Vo and then calculated Rtherm (Rtherm = R(Vs/Vo – 1) ).

Hooking my DMM to TP11 relative to AGND, the voltage reading I get for Vs and Vo:

Vs = 5.07V Vo = 2.01V…hmmm…Vo should be much closer to 2.5V since it is 10K at room temperature.

Plugging these values into:

Rtherm = R(Vs/Vo – 1) = 10,000(5.07/2.01 – 1) = 15224

Hmmm…given 2.01V, I am not surprised the calculation for Rtherm is quite a bit larger than expected.

What’s Going on With R15?

The first thing I do is check the value of R. Is it 10K? On the schematic, R is R15. I look at the reading for R15…and weird – it reads 5.4K. Yet the label on R15 is 103 – which is the 3 digit code for 10K. Maybe my probes are not getting a good enough connections on the ends of the resistor. I could have damaged the resistor during soldering, but if I did, wouldn’t the resistor just not work and I would get no reading? Could quality control be bad enough to allow a 10K impostor? Could this resistor have been damaged during shipment? Could I have zapped it?….While my curiosity remains piqued as to why I am getting a 5.4K, I’m going to remove and replace.

After I removed, it looked like I had removed the copper from the pad. The image is a bit blurry, but what concerns me is the white pad – this should be copper:

R15

 

I measured the resistance of the resistor I removed…hmmmm…it read 10K. I’m thinking I’ve damaged the pad too much. I’m going to stop testing using this circuit…even if it did work…

Simpson DOH


D’OH… while testing the pH circuit (covered in this post), I realized the MCP3901 can read voltages between +/-.79V.  I wouldn’t be able to read Vo! 

 

 

Testing the Thermistor

Using a DMM

I tested the thermistor with a bread board.  I measured the actual resistance of the 10K resistor I am using.

Breadboard Thermistor with DMM

 

 

 It measured 9.9K.  Vo measured 2.64.  With these values, Rtherm = 9,900(5.07/2.64-1) = 9,112.5.  When I put the thermistor between my thumb and first finger (added heat), the voltage decreased to 2.44 -> 10671Ω.  This indicates to me that the thermistor is working.

Using an Arduino

Taking a reading on the Arduino using Adafruit’s sketch (see this post for why analogReference(EXTERNAL) is used):

// the value of the ‘other’ resistor
#define SERIESRESISTOR 10000
// What pin to connect the sensor to
#define THERMISTORPIN A5
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
}
void loop(void) {
float reading;
reading = analogRead(THERMISTORPIN);
Serial.print(“Analog reading “);
Serial.println(reading);
// convert the value to resistance
reading = (1023 / reading) – 1;
reading = SERIESRESISTOR / reading;
Serial.print(“Thermistor resistance “);
Serial.println(reading);
delay(1000);
}

I got the following readings:

ArdThermistorReadings

Rtherm ~= 11313.

hmmm….not 10K….

So…

Additional Cleanup

A few more changes in Dev-Rev3.

Get Rid of Multiple Test points

  • Remove TP11: The Thermistor can be measured from the 3rd pin of the 8 Terminal Block Connector.

What’s Next

At this point, I am not getting a good enough reading for Rtherm .  I have ordered more thermistors.  When these come in, I’ll:

  • test on breadboard
  • test on arduino
  • set a plan for the thermistor given the MCP3901 cannot handle its voltage.  This most likely means using the Arduino.  I am concerned with this choice because of the inherent noise using the Arduino can introduce.
I’ll be back!
 

 

Advertisements