Pages: [1]   Go Down
Author Topic: Arduino NTC thermistor test  (Read 5065 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
#include <LCD4Bit_mod.h>
#include <stdio.h>
#include <math.h>
LCD4Bit_mod lcd = LCD4Bit_mod(2);
int value=0;
int analoginput=5;
int R1=1000;
int Vin=5;
float tmp=0.0;
float Vout=0.0;
float f=0.0;
char text[16];
char temp[16];

void setup() {
  pinMode(analoginput, INPUT);
  lcd.init();
}

void loop()
{
  Vout=1023-analogRead(5); // Invert the number because of setup
  Vout=(Vout/1024.0)*5;
  f=1000*exp(-3500/298.15); // 298.15K = 25C, 3500 seems to be the B value for a standard 1kOhm NTC
  tmp=(R1*Vin)/Vout-R1;
  value=(3500/log(tmp/f))-273.15;
  sprintf(text,"%d      ",value);
  lcd.cursorTo(1,0);
  lcd.printIn(text);
  delay(1000);
}
A little messy but it was just a test...
Using a 1kOhm resistor and NTC in a voltage divider on analogport 5. Seems to be working quite nicely.
The inverting of Vout was done because I was too lazy to flip my voltage divider around.

The equations were taken from wiki and the numbers (B value) were just googled, so no warranty on them being correct.
« Last Edit: June 06, 2009, 04:19:38 pm by Jokse » Logged

London, England
Offline Offline
Edison Member
*
Karma: 4
Posts: 1026
Go! Go! Arduinoooo !!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What's an NTC ?
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Temperature data logger
Logged

London, England
Offline Offline
Edison Member
*
Karma: 4
Posts: 1026
Go! Go! Arduinoooo !!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Surely that's TDL ?   :o
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

NTC is Negative Temperature Coefficient –  a device where the resistance decreases with rising temperature.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wasn't allowed to post links in my first post, but here are the links I used for it and the topic  for this should have said Arduino NTC Thermistor test.

http://en.wikipedia.org/wiki/Voltage_divider
http://en.wikipedia.org/wiki/Thermistor
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Mike Mc

I googled NTC and thats the answer it gave me... next time I'll use Bing lol
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm working on something like this and I'm trying to calculate the B value. With a 1k resistor and an NTC probe that has a different B than your sample here, I'm getting a reading on my analog input of 1014 at 0 degrees C and 649 at 100 (i put the probe in ice and boiling water)  - that's the raw value, not inverted.

How do I take that 1014 and 649 reading and convert that the resistence so I can plug it into  b = Ln(R t1/ Rt2) / (1/T1 – 1/T2) ?

Thanks a lot, i'll post back to this thread if i figure it out
Logged

DFW, Texas
Offline Offline
Newbie
*
Karma: 0
Posts: 15
we are all borg
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a look at: http://thermistor.sf.net

It will teach you about the equations, coefficients, and has some code to calculate the coefficients.  I did this with my 2 salvaged thermistors and it works very well so long as I use the full Steinhart-Hart equation.

You can also have a look at the library I added to the playground:
http://www.arduino.cc/playground/ComponentLib/Thermistor4

I have a lot of documentation in the source that will probably answer most questions.
Logged

Pages: [1]   Go Up
Jump to: