Sorry I haven't been around I've been super busy. So this is a very small project but I figured it might help someone out. I won't dive into the
theory or anything as it's not that hard. This is an entry level tutorial, if you want more then learn it and share it.
I purchased a NTC thermistor for about 1-2$ USD not long ago. It didn't come with documentation but the specifications were listed as -
Quote:
Stainless steel sheath and waterproof
Measurement range: -40 to 120 °C
Type: NTC
Resistance: 10k
B-constant : 3435K -/+ 1%
The most important thing here is knowing the maximum resistance(10K ohm) for purposes of having the arduino make a measurement. The arduino's ADC
measures counts based on voltages which are easily converted to voltages. But it does not measure resistances so the simplest way to turn a varying
resistance into a measurable voltage is what is called a voltage divider circuit(https://en.wikipedia.org/wiki/Voltage_divider).
(image courtesy of wikipedia page)
A resistive DC voltage divider can be expressed as this equation: (image courtesy of wikipedia page)
Because the thermistor has a 10k Ohm resistance I selected R1 to be ~10k Ohm as well. Which is sensible looking at the equation.
It's important to actually measure the resistance of your R1 resistor to get a more accurate value. As resistors vary from their package description.
1% resistors are ideal and cheap. It's also important to measure the voltage of the 5V power from the arduino or whatever external power source you
use. The ADC counts depend on that.
To physically create the circuit connect a 5V line from the arduino to the voltage divider and lead that back to the ground. Put an analog pin(I chose
A0) where the resistor and thermistor meet in series. I have attached an image which is of horrendous quality(I artificially sharpened it) of the
bread board I used.
Now the thermistor does not operate in a linear manner by any means. The B or beta parameter is given which can be used in a simplified way to
retrieve temperature measurements (https://en.wikipedia.org/wiki/Thermistor). Thankfully the arduino can handle logarithm's and powers because the equation turns out to be this one
-
where
(images courtesy of wikipedia page)
For all intensive purposes the Rinfinite can be regarded as a constant and implemented as such in the code. For a more accurate rendering of a
thermistor the use of the Stienhart-Hart equation is advised.
The arduino code is attached below. If there's any errors with it just let me know I tidied it up without compiling before uploading.
Attachment: thermometer2.ino (1kB) This file has been downloaded 1245 times
--------------
How well does it work?
Well, I don't have anything to test it against at the moment. However,
Icey tap water reads about 1.5-2.0*C. (A little high maybe)
Tap water shortly after being boiled is around 95*C. (A little low maybe)
Room temperature with air conditioning is about 26*C. (A little high maybe)
Body temperature read 37.1-37.3*C (A little high but close if not accurate)
The readings are probably not absolute. For a 2 USD thermistor and a 5 USD microcontroller (if you purchase a clone), the head-way into temperature
measurements, automation, (basic) calorimetry, or data logging is very accessible and easily implementable.
Hope this "tutorial" helps people understand the basic premise of how to use a NTC Thermistor and encourages some tinkering. I mostly made it so if I
get sick I can take my temperature, and because it was a very cheap fun way to spend an hour.
[Edited on 30-8-2015 by smaerd]aga - 30-8-2015 at 11:34
For non-critical stuff, the good old y = mx + c works pretty well despite sensor non-linear behaviour.
Pretty sure i implemented that in the Smelty code somewhere.
Glad to see you back smaerd.m1tanker78 - 30-8-2015 at 12:41
These thermistors are great to have on hand and provide a robust way (once calibrated) to monitor instrument temperature and put the unused analog
pins to good use.
Nice tutorialsmaerd - 30-8-2015 at 13:29
@aga - thanks, grad school has been eating a lot of my time!
Oo I had never seen the smelty before awesome job on that! I see, yes thermistors are very non-linear whereas the thermocouple you used is quite
linear so y=mx+b is fine. I actually tried a similar route before reading about thermistors and was getting some very peculiar values.
@m1tanker78 - That's a smart idea I'll definitely be thinking about that for some future projects.aga - 30-8-2015 at 13:31
grad school ?
What's that ?smaerd - 30-8-2015 at 16:43
It's the college after college to contribute to the scientific community and earn a doctoral or masters degree. Bright Spark - 31-8-2015 at 21:52
Nice tutorial and I am impressed with both your programming and your maths skills
When I use thermistors in the commercial world I always model them as a polynomial, usually the manufacturers of the thermistors give the resistance
across the range and it can be within 1% so a polynomial defined with macros means that is can be so easy to change the thermistor to a totally
different one and only have to change a few macros
The Steinhart equation isn't very accurate over a wide range, IIRC its accurate over a range about 50C
Don't take this as me being negative, thats not the case I am just explaining another way this can be done
I can show you what I mean if you are interested, the voltage can be eliminated from the equations if the ADC reference voltage is the same as the
thermistor bridge supply voltage and this means better accuracy
Regards
[Edited on 1-9-2015 by Bright Spark]
[Edited on 1-9-2015 by Bright Spark]aga - 31-8-2015 at 23:23
Wooo ! Sounds good.
Please show.Harristotle - 1-9-2015 at 02:13
There is an even cheaper way to do this. A silicon diode has a negative temperature coefficient of approximately -2mv per degree celsius.
Thus a 1c diode (1n4001 bought in bulk from ebay) makes quite a good thermometer, with callibration. You don't even need to buy a resistor, if you
program the analog pins as pullup. Like this:
So then your thermometer looks like this:
A bit of code to convert the analog reading to degrees, and you are good to go.
I also write mine so that if the arduino sees an X on its serial port, it enters calibration mode and stores the calibration in eeprom. This way you
can calibrate on new diodes, or just plug it in and run
<pre>
<font color="#434f54">// a functioning diode thermometer with stored calibration</font>
<font color="#434f54">// To recalibrate, open the serial console and hold down the letter x a few times, then press return, within 1 second of
starting</font>
<font color="#434f54">// Then expose the diode to two different, known temperatures. The classic way is with ice water and boiling water, but
you</font>
<font color="#434f54">// can use a known thermometer and any two temperatures to callibrate.</font>
<font color="#434f54">//Leon Harris, 2014</font>
<font color="#434f54">// Version: 0.2</font>
<font color="#434f54">// Fully working, but not cleaned up</font>
The Steinhart equation isn't very accurate over a wide range, IIRC its accurate over a range about 50C
Brightspark that's really good to know.
I'd love to see how thermistors are handled in a professional context. It's interesting you use a polynomial model but why not! I think I see what
you mean about ripping out the voltages. Anything you want to share I'd love to read.
@Haristotle
I am really impressed with this. It's one of those backwoods solutions I probably would have never considered yet have them(diodes) sitting on my
shelf. 2mv increment per degree celsius is quite nice for a wider temperature range sacrificing some resolution(depending on the circumstance). It's
also a lot quicker once calibrated which is great for a cheap and dirty on board temperature measurement.
For external sensing a little thermowell could be made without any issue and very cheaply I am sure as well.
Thanks for providing your code. I also didn't know about the EEPROM commands but I never dabbled much with EEPROM.aga - 1-9-2015 at 11:38
Amazing, I thought i'd seen the diode thing before.
Page 139 of the Microchip PIC16F1823 manual shows the schematic of the die-temperature sensor, and it's two or 4 diodes.
Edit:
Got the part code wrong
[Edited on 1-9-2015 by aga]
one last trick
Harristotle - 2-9-2015 at 01:14
one last qute trick that I normally use, but for some reason did not put in that example: you can increase your resolution 5x by using:
AnalogReference(INTERNAL);
this sets your adc to read 0-1.1volt.
So your diode will give you about 630 counts at room temp, instead of only 140 counts. ie 0.9 bits per millivolt instead of 0.2 volts per mv. In other
words, about +/- 0.5 a degree resolution, if you use the internal reference, which is 1.1 volt.
Cheers,
H.smaerd - 13-9-2015 at 04:46
Very nice! I had no idea that the ADC potential range could be changed like that. When I looked into it some more I read in other places that the
arduino ADC isn't exactly a gold standard by simply using analogread() due to supply voltage fluctuations, etc.
Just wanted to share a couple sites I have been spending much time at lately which can aid in using your Arduino for many complex tasks involving
automation. Tutorials useful in learning how to monitor sensors and performing various functions in the lab. This thread seemed to be an appropriate
place to share these links for those who have not already found them.
Just wanted to share a couple sites I have been spending much time at lately which can aid in using your Arduino for many complex tasks involving
automation. Tutorials useful in learning how to monitor sensors and performing various functions in the lab. This thread seemed to be an appropriate
place to share these links for those who have not already found them.
Just wanted to share a couple sites I have been spending much time at lately which can aid in using your Arduino for many complex tasks involving
automation. Tutorials useful in learning how to monitor sensors and performing various functions in the lab. This thread seemed to be an appropriate
place to share these links for those who have not already found them.
Really, this entire thread is pretty much obsolete. You can get a MAX 6675 thermocouple reader from China for about $2, and the corresponding K-type
thermocouple for about $1.50. Then you just download the library, and you can measure virtually any temperature up to the melting point of the
shielding on the thermocouple wires, and more accurately than a thermistor as well.Sulaiman - 22-5-2017 at 03:04