Analog Temperature Sensor

Hey guys,

I have a small question for you. I a

Thermistor 10K - “10K thermistor with a negative temperature coefficient.”
sparkfun.com/commerce/produc … cts_id=250

From SparkFun a while ago and I want to get this bad boy working! How would I get this working?

Do I basically put a 100ohm resistor in series with it, then connect that to an analog pin on my PIC (18F4550)? Then use the PIC’s ADC function to get the analog value and then convert that to a temperature value with a funky formula and resistance tables located in the datasheet:
sparkfun.com/datasheets/Comp … 226403.pdf

Would that mean I would need a lookup table? Or could I just use an exponential regression to get a one variable formula?

Sorry for being stupid :frowning: I haven’t used analog sensors before so I wouldn’t know how they work. And I am too scared to try without some information. Don’t want to blow up my PIC :frowning: I tried googling, but never found any articles using this type of sensor. They were all funky sensors with 3 pins or digital.

Cheers,
-robodude666

basic idea is to make a voltage divider with it, which you described. The response is non-linear and you can attempt to derive an equation to turn a measured voltage into a temperature, or use a table in say 5 degree increments and interpolate your measured voltage to a temperature, or the easiest thing is make a table in 1 degree F increments from -40F to +185F, find the point where your voltage is between two values in the table and say close enough. :slight_smile:
Actually you can put a second resistor in parallel with the thermistor (within the divider network) and that has a linearizing effect although mostly at the low temperature end.
Using a spreadsheet where you put the series and parallel resistor in cells so you can tweak them is a relatively painless way to see the effects, especially since you can make a graph and display visually what happens when you bump each value up and down a few percent. Many thermistor manufacturers actually have a table showing R vs. T so that can be imported into the spreadsheet to speed things up even more. :wink:

Here is an example for a Betatherm 10K3MCD1 thermistor which is fairly typical of a 10K ntc thermistor.
betatherm.com/rt_charts/10K3MCD1.html

EddieB, you know where I can get that sensor? It is very tiny which is exactly what I need. The 10k one from SF is rather fat.

So basically I put a resistor and connect it to an analog pin? I put the other end of the sensor to 5v? (since analog is an input)

er, not sure about distribution for betatherm as we buy mostly custom assemblies from them. Digikey though sells lots of thermistors, the GE MA100GG series is pretty tiny and comes with wire leads.

if you want the voltage to go up as the temperature rises then yes, the thermistor to +5V (or whatever your reference voltage is, typically 5V), the junction between the thermistor and resistor also goes to the a/d input, and then the other resistor end goes to ground. it would not hurt to place a small capacitor, say 0.01uF to 0.1uF, across the resistor to filter out noise.
So using +5V as a reference, Vin = 5 * R / (R + Rtherm)
If R = 10K and your thermistor is 10K @ 25C then you get 2.5V input.
Using the same values for Vref and R, @ 20C Rtherm = 12.491K and you get 2.22V in, and @30C you get 2.76V in.
Here’s the data sheet for a MA100GG103B thermometrics.com/assets/images/ma.pdf

:mrgreen:

All of the ones I found on digikey and jameco are pretty fat. I need one of those thin, flexible sensors…

This sensor only has 2 pins. Doesn’t one go to 5v and other goes to AD in? Where does ground come from? So the cap should be in parallel to the 100ohm resistor?

This is odd… I put the sensor onto a breadboard. Put the 100ohm resistor in series to the sensor. Placed 4.28v power to the resistor and GND to other end of sensor… Then when I put the multimeter on (parallel to sensor) I get a constant 4.17v No matter how much heat I apply to sensor (squeezing it warm fingers, or hovering a HOT iron over it)

That MA100GG103B sensor seems to go from 0-50c… I will need like -40 - 125C (100C max really, but 125 to be safe)

Maybe I should get a sensor with a better datasheet? The one with my sensor totally sucks…

re-read my previous post and I tell you how to wire it up. :open_mouth:

with a 10K-ohm thermistor you are not going to see much of a voltage change with only 100 ohm series resistor. You really need 1000 ohms (1K) or more to make it significant and a 10K resistor would be even better. this is why I suggested a spread sheet approach so you can just try resistor values and see what kind of voltage change you get with changes in temperature. You can even take it ot the next step and put the a/d conversion factors in and display the results in the numbers your a/d would actually return.

I don’t believe betatherm sells through distribution. I could be wrong so you can research it if you like. I know they make fairly precision parts and sell them priced appropriately.

Searching digikey I find an EPCOS B57862S103F40 and it’s data sheet is here epcos.com/inf/50/db/ntc_06/M … __S862.pdf and it has a chart to the temperatures you indicate but mechanically it doesn’t have the wire leads already attached so it would require some fine wire soldering skills and then adding heatshrink to protect the connections, and then another layer of heat shrink to hold the legs together so you can’t pull the thermistor apart. I don’t know how fat is fat, this part has a 2.8mm diameter so a little more than 0.1" doesn’t seem that big but I don’t know what you are trying to measure so… I do know that the smaller they are the price goes up really fast. Maybe that matters, maybe it doesn’t.

So wait…

one end of the sensor goes to ADin, other goes to 5v? And a resistor is placed between GND and sensor? (Forming a T shape)

EDIT:

I upped it to a 4.7kO resistor and it seems to work fine… Says room temperature is 2.974v The chart for my sensor is so damn confusing X_x

Time to open excel!

Yep. It’s a voltage divider with the thermistor being one of the two resistors. http://upload.wikimedia.org/wikipedia/en/5/5f/Resistor_Divider.png
the thermistor is R1 in this pic, and the cap goes across R2, and Vout goes to the a/d input, and vin is +5V. :smiley:

Hmm, thats basically what I have now. Since I am doing this on breadboard with a multimeter and no PIC my Vout is GND.

R1 is a series of resistor and sensor?

EDIT:

I took another look at the datasheet in more detail and i am confused as to how their datasheet works.

What is R25/85?

Since its just a resistor which changes resistance based on temperature, can’t I use the datasheet of another 10k temp. sensor?

um, I can’t think of how to explain the circuit any more clearly than R1 is the thermistor and R2 is your 4.7K resistor. I mean if you are saying the vout is GND and your R1 is the thermistor and resistor in series… either you are messing with me or you just need to stare at the circuit a little longer to realize they are the same circuit. :open_mouth:

The R25/85… I’m not sure about the 85 part of that but frequently thermistor tables are shown as the resistance at 25C / the resistance at each temperature, basically the number they give is a ratio. This lets them make several thermistors with different resistances at 25C from the same material and only have one chart showing how the ratio changes over temperature. For a particular temperature you just multiply the ratio by your RT@25C value, 10K in your case, to get the resistance at that temperature.

edit: oh yeah, many 10K thermistors are similar but each material will be a little different so the tables are different for each… but how accurate are you looking to be becomes the question, and also if you are going to do any calibration.

Nope, the way you described the picture was confusing. You didnt mention R2 being the resistor. You just mentioned the cap going across R2… I previously asked what do you mean by “across” and you didnt reply to that so it was confusing… Anyways, thats pretty much what I have now. Vout should go to ADin, but since I am using a multimeter ADin is GND and I measure the voltage parallel to the sensor…

I don’t think its as simple to get the temperature…

Take a look at page 4:
sparkfun.com/datasheets/Comp … 226403.pdf

There are 8 variables based on the R25/85… and none of those tables have the resistance… at least nothing in the 10,000s

oh it’s there, it’s just bloody complicated instead of being straightforward and simple.

go to page 11 in that data sheet you linked. on that page, first table, first and last columns are temperature and resistance respectively for the 10K thermistor.

if you feel like doing the math on page 4 go ahead, but in 5 degree C increments the deviation of a calculated value from one linearly interpolated from two adjacent temperature points in the table on page 11 will be very small, a couple tenths of a degree at most. not only that but it’ll be a helluva lot faster to calculate on a microcontroller. :wink:

Ahhh, alright! I see :slight_smile: Thanks. So Toper is my temperature and R25 (6.103) is my resistance? Woops, missed the kO part :blush: So at 10kO its 25C :slight_smile: Perfect! 5C increments aren’t that very helpful really… Hmm, I think I will paste the chart into excel and do me a regression!

Thanks for your help :slight_smile: Just wondering, I know theres a formula for this but I forgot it… How do I convert the ADC output value to voltage?

EDIT: Just making sure this idea is correct:

Since I can find out the Voltage from ADC value and I know the current doesn’t change (it doesnt, right?) I can find out R from Ohm’s law:
R = V/I
Then I can plug r/1000 into a regression formula to get the temperature, correct? Or is there a more direct/easier way?

you can do it this way but one of the things to consider is you are, or at least I am guessing you are, running this on a microcontroller. microcontrollers are not real big on either floating point math or lots of multiplication, division, or power / log type functions. If you import that table into excel and plot the resistance against temperature and then plot a 2nd order trend line you will see there is little difference between the line drawn to connect two values at 5C increments and the trend line connecting those same two points. you can capitalize on that fact and use linear interpolation to find a specific temperature between the two bounding temperatures (which are at 5C increments) in a table.

I don’t know if you have 8-bit, 10-bit, or 12-bit resolution but for each case it is your (Vref) * (A2D_reading) / (2 raised to the n-th power) where VREF is usually 5V and n is the number of bits your converter has.

Well the voltage divider general equation is VOUT = VIN * R2 / (R1+R2) and you have VIN = 5V and R2 = 4.7K. Solving for R1, R1 = (R2/Vout) * (Vin - V out).

So, you get Vout from your A2D equation, you get R1 from your voltage divider equation, and you get Temp from either your regression formula or table based interpolation. QED, no?

Another approach to this problem that avoids the non-linearity and such:
Just use a temperature sensor chip.

I’ve recently been using a Microchip TC1047A. It’s in an SOT23 package (looks like a small SMT transistor). It has 3 leads: power, ground, and output. The output is a voltage that is proportional to degrees C. At minus 40 degrees C, the output is 100 mV. The output goes up 10 mV for every degree, so at zero degrees, the output is 0.5V. I think it costs about 50 cents.

There are all sorts of other sensor chips, some of which are in packages like TO-92, which is easier to handle (but bigger).

Pete

Guess I will use the:
"Well the voltage divider general equation is VOUT = VIN * R2 / (R1+R2) and you have VIN = 5V and R2 = 4.7K. Solving for R1, R1 = (R2/Vout) * (Vin - V out). "

method.

I know there are lots of other sensors out there but I need one that is tiny as possible and flat as possible. Those sorts of packages won’t work for me since they are fairly large.

Well for narrow and flat you could always go with the Analog Devices AD590JF which is about 2.3 mm wide and 1.2 mm thick. It’s output is 1 uA per degree Kelvin and it operates from -55 C to 150 C. The output IS linear. They are not inexpensive though.

Yea, $15 a pop… Saw them on digikey before… I will stick to my current ones for now.

Are you aware of how small an SOT23 is?
It’s 1.0mm thick, 1.30mm wide, 2.92mm long. If you drop it on the floor, you may have trouble finding it…

The TC1047A works from -40 to +125 degrees C. It uses only 35 uA of power. Using a 10K thermistor with a 4.7K resistor, you’ll be using about 10 times as much power (although it’s still small).

No conversion tables required, no resistors required.
It costs 47 cents in singly-unit quantities. How can you go wrong?

Pete

Its just not the type of package I am looking for… I need something with two pins, both next to each other… I will be sticking these inside of a computer and I need them to be a certain way in order for them to fit properly.

I will be ordering another sample from microchip soon so I will get a few for testing purposes.