EmbeddedRelated.com
Forums

Reading temperature with external thermistor

Started by jaypal01 April 7, 2013
Hi everyone!
Can someone help me on how can I use an MSP430G2231 to read an external thermistor, scavenged from an old computer motherboard?
I tried to use the temperature reading example program without success.

Thank you all in advance.

Beginning Microcontrollers with the MSP430

Look at an ADC example
You need to realise that a thermistor is not like other parts you would
interface to your analog input pin. It is a resistor whose resistance
varies with temperature, therefore it needs to be used in a resistive
divider, or similar circuit that uses resistance to change the operation
of a circuit. You will need to figure out the Beta value and resistance
of your sensor, whether it is NTC or PTC, it's pinouts if not a simple 2
pin etc etc. resistances listed on Element14, for example, range from
0.45R to 5MegR. A common value is 100K for example at 25C. You also need
to be aware that current flow through the thermistor will cause a change
in temperature anyway, so, without a data sheet I'd suggest that
salvaging this from your old computer will cost more than buying a
conventional temp sensor in terms of time and effort especially, but if
you only want it as a learning experience then why not research
thermistor on the internet, and use that as the basis of your learning.

Al
Hi! Thank you all.
I've digged a little after Kyle's answer about using ADC and realized that
I'd need to read the voltage through a voltage divider.
First I've tried to measure the using the multimeter and found that if I
heated the point of the thermistor, the resistance would fall. I thought
this was odd... but ok, I suppose that's the way it is!
Then I've created the circuit in a breadboard using a 3v cell coin and a
resistor (can't precise the value right now, since I'm at my work) and
noted the voltage readout would increase (as expected, since the resistance
would drop).
I needed this to measure the temperature inside a closed box. For start,
I'd need it to read one value, then two or three values in different
places. If possible it would also log the values and later on, control some
fans using PWM and some fins using a stepper motor.
This is a test box for a cooling concept so I needed to somehow create some
stable heat and measure it before the fans start spinning and after with
increasing speeds during a period of time.
That's why logging would be very useful.

If I recall, I can't see any print in the thermistor.
To be honest, I don't care for the real temperature value, just for the
variation and the difference between sensors. Might this be a dumb decision?
Yes it might be a dumb decision! But it's yours to make! Going forward
you wouldn't be able to eactrly replace the experimental thermistor, so
anything you discover now will be of limited use. A temperature sensor
that gives temperature value fairly directly costs <=$1. Using a
thermistor in a divider circuit means using a table or calculations to
get the temperature, and the value read will depend on the restance of
the other part of the divider, and will not be linear. Thus it would be
easier to just go with something simpler to use.

Al
Oh, I see...
And I think you're right - having the right temperature might be also
useful and it's better have it from the start than having to adapt the
project at the end.
Is just that the information I've found for the ADC spoke on using a
voltage divider.
I guessed it would be the proper way to do it but it makes total sense what
you said.
I guess I'm complicating this too much.
Let's divide the "project" for now and simplify:
I need to measure and log temperature inside a tank of water, in front of a
fan (I thought about humidity too using an DHT11 sensor?) and temperature
in the heat-sink (3 measurements).
- Is the MSP430 the right microcontroller for this?
- Is the thermistor the right way to have this values?
- How would you log the values?

Could you please point me out some example (circuit and code) of something
similar?
Sorry to bother with what might be some silly questions, but I'm quite lost
in here... I'm so confused that I can only think in using some mercury
thermometers!!!
This is a comparatively simple task. No need to overcomplicate it at
all. I would NOT use a thermistor for a start, I would find an analog
or digital sensor, depending on which you are most familiar with, and
work with that. Whichever you choose there is plenty of sample code
available from Ti. If you need low power then the MSP430 is the right
microcontroller. Most small microcontrollers would do the task easily.

If you only need to log the values then you need to determine the log
interval and log period to determine the best way to store your logged
data. If you only need to turn a fan on or off, or some other function
then you don't need to be concerned with storage. If you want to gather
data in a log to determine the dynamics of the system before developing
your control algorithm for the fan/heater etc then you could probably
get enough data stored in the spare flash in the micro. If you do need
to log data then you alos need to figure oput how you're going to
extract that data, in what form, and how you're going to visualise or
analyse it.

Two very simple temperature sensors are the TMP102 from Ti and the
TMP05/06, also from Ti. there are literally hundreds of others. these
are digital sensors, meaning that you don't need an A/D to read them.
the TMP102 uses an I2C interface, and there is an app note from Ti for
the TMP100, which is almost identical. Sorry no app note number but it's
easy to find. The TMP05 is a little odd in that it uses a duty cycle
type scheme to measure temperature. If you understand how to use the
timer capture function on the MSP430 then this is very easy, in fact the
easiest, but will require some simple maths to convert to temperature.
Other wise I2C is very easy too.

Read the data sheets to understand the parts and get an idea of a
typical circuit. Buy a Launchpad board if you can with the MSP430G2553
on it. That does everything you need, is cheap, and can easily be
interfaced to most sensors. It has an A/D if you go that way, it also
has a comm peripheral that can handle UART, I2C or SPI in the A channel
and SPI or I2C in the B channel. this is very easy to use, and combined
with, say a CP2102 UART to USB convetrer gets you comms to the PC to
download your data. Again the data sheet gives a circuit example, or you
can cheaply buy an evk board for the CP2102 and similar parts and hook
it to your Launchpad (the same goes for most temp sensors by the way.
Sparkfun is a good, though not particularly cheap source of pre-made EVK
boards.

Cheers

Al
Rui Maldonado wrote:
> I guess I'm complicating this too much.
> Let's divide the "project" for now and simplify:
> I need to measure and log temperature inside a tank of water, in front of a
> fan (I thought about humidity too using an DHT11 sensor?) and temperature
> in the heat-sink (3 measurements).
> - Is the MSP430 the right microcontroller for this?
> - Is the thermistor the right way to have this values?
> - How would you log the values?

This is a one time project? Absolutely, your time will be of most value,
cheeping out on parts is not worth it unless you are really looking for
the challenge. In that case, Al's first suggestion, I2C would be the way
to go. It is practically plug and play. Humidity? Quick look, I could
not find an I2C as cheap as the DHT11. Is it worth the ten bucks of
savings to write code for it if you are just building one of these?

Here is a simple I2C master I use:


Best, Dan.
Dan, Al, thank you!!!
I'll start digging on what you taught me right away!
The project will some how, be permanent. I'll post the code and the
schematics while doing it (although it will take some time).
I already have an MSP Launchpad but I'll have to get at least one
MSP430G255.
But first I'll dig the data cheats of MSP430G255, TMP102, DHT11 and I'll
let the CP2102 for later.
The idea is exactly to study the system dynamics and specially if it is
worth or of any use.
Dan, I've been reading the site and the source files you've sent, but I
think I'll need start forwith the data sheets and trying to figure out the
samples. :-)
Once again, thank you both for your great help and pointing me in the
correct way!
I'll keep in touch for the next questions that will definitely come up!

Com os melhores cumprimentos,
*
Rui Maldonado
Hi everybody!!!
I have been looking to the data sheets of DHT11 and msp430.
I've found this: https://github.com/bafeigum/DHT11-Library-for-MSP430
He says it is compatible with any G2xxx series micro-controller as long as
it has TA0.
If I'm not mistaken, the msp430g2231 (which was bundled with my Launchpad)
has TA0 in P1.1 and P1.2 - this would allow to capture two DHT11, right?
But the same P1.2 is in P1.6 - this is just to be flexible, I wouldn't be
able to connect a third sensor here, right?
Also saw that the DHT11 would only go from 0C to 50C (which is fine to
measure the air temperature and humidity at the end of the fan) but i think
I'd need the TMP102 in the heatsink, since I count to make the heat piece
reach 100C max, do you agree?
For the TMP102 I'd use P1.7 in I2C mode, and if I'm not mistaken, i could
simply connect more than on in series, right? Both MSP430G2231 and
MSP430G2553 only have one SDA, as far as I can see.
I found an excellent example in
http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/167713.aspx but
they only mention one sensor. (At least, P1.1 and P1.2 are free!)
My best regards,