Hello to all,
I just build a potential divider circuit using a thermistor, i have read several tutorials whereby they are using a 10 K thermistor ana a 10 K resistor in series.
I purchased the Ultimate microcontroller pack, havinf 2 qty of thermistor written 503 on that, with a range of 20k ohm - 1M ohm with power of 50mW and having its beta value 4300.
Through much research i could deduce that it was a 50 K thermistor due to the 503 code.
When i measured the resitance through a meter at room temperature which at that time was approx. 26 to 27, i could get around 35.2 K ohms.
My first puzzle, i should have a reading near 50 K right ??
I combine 2 100K resistors in parallel, to be used in the divider circuit, where the actual reading was 46 K ohm.
I used an external power supply, providing with 4.98 V as input on the UNO board R3.
Using the equation :
R(therm) = R(Series)/((1023/ADC) - 1);
and
V(out) = ( R(therm)/R(series) + R(therm) ) *V(in)
My resistance values were coherent, almost the same reading through measurement and calculation as well as from the program code on the arduino giving therm resistance.
However, when i convert the resistance reading through stainhart-hart equation, my values are innacurate on my UNO, above +2.8 C when compared to digital thermometer used to measure the ambient temperature.
At the time of measurement RT = 27 C with digital thermometer and arduino temperature display showing 31.58 C.
See the code i used:
Please note the stainhart equation used was for the beta value only.
// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 50000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 4300
// the value of the 'other' resistor
#define SERIESRESISTOR 46000
int samples[NUMSAMPLES];
void setup(void) {
Serial.begin(9600);
//analogReference(EXTERNAL);
}
void loop(void) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples* = analogRead(THERMISTORPIN);*
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples*;*
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
delay(1000);
}
[/quote]
I tried to work with the full stainhart equation, using the a,b,c values constant to see if things get better, i tried the code below:
Note that the a,b,c values are constant for a 10K thermistor, i used values for a 50K therm i.e. a = 9.657154 e -4 , b= 2.106840 e -4 ,
c= 8.585481 e -8, but unfortunately my temperature reading was above 300 C instead of near room temperature.
So i stick the same values in the program code.
> #include <LiquidCrystal.h>
> #include <math.h>
>
> LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
> int backLight = 13; // pin 13 will control the backlight
> void setup(void) {
> pinMode(backLight, OUTPUT);
> digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
> lcd.begin(16,2); // rows, columns. use 16,2 for a 16x2 LCD, etc.
> lcd.clear(); // start with a blank screen
> lcd.setCursor(0,0); // set cursor to column 0, row 0
> }
> double Thermister(int RawADC) {
> double Temp;
>
> Temp = log(((10230000/RawADC) - 10000));
> Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp *
> Temp));
> Temp = Temp - 273.15; // Convert Kelvin to Celcius
> return Temp;
> }
> void printTemp(void) {
> double fTemp;
> double temp = Thermister(analogRead(0)); // Read sensor
> lcd.clear();
> lcd.setCursor(0,0);
> lcd.print("Temperature is:");
> lcd.setCursor(0,1);
> lcd.print(temp);
> lcd.print(" C / ");
> fTemp = (temp * 1.8) + 32.0; // Convert to USA
> lcd.print(fTemp);
> lcd.print(" F");
> //if (fTemp > 68 && fTemp < 78) {
> //lcd.setCursor(0,3);
> //lcd.print("Very comfortable");
> //}
> }
> void loop(void) {
> printTemp();
> delay(1000);
Again i had a drift of temperature reading, LCD displaying 32.20 C while digi thermometer showing 30.6 C
Any suggestion please.
Thanks
Taz . . .