Go Down

Topic: Arduino NTC thermistor test (Read 7916 times)previous topic - next topic

Jokse

Jun 05, 2009, 11:54 pmLast Edit: Jun 06, 2009, 11:19 pm by Jokse Reason: 1
Quote
#include <LCD4Bit_mod.h>
#include <stdio.h>
#include <math.h>
LCD4Bit_mod lcd = LCD4Bit_mod(2);
int value=0;
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() {
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.

#1
What's an NTC ?

John_Ryan

#2
Jun 06, 2009, 12:48 pm
Temperature data logger

zooto68

#3
Jun 06, 2009, 04:37 pm
Surely that's TDL ?

mem

#4
Jun 06, 2009, 06:47 pm
NTC is Negative Temperature Coefficient -  a device where the resistance decreases with rising temperature.

Jokse

#5
Jun 06, 2009, 10:20 pm
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

John_Ryan

#6
Jun 06, 2009, 11:06 pm
@Mike Mc

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

bsautner

#7
Oct 14, 2010, 07:08 pm
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

modat7

#8
Oct 17, 2010, 07:51 am
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.

Go Up