#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.