Temperature Sensor Problem

Hi,

i got this
http://www.ebay.de/itm/ws/eBayISAPI.dll?ViewItem&item=261026313725&clk_rvr_id=351800712880
thermistor sensor

Im trying this tutorial
http://www.arduino.cc/playground/ComponentLib/Thermistor2

The problem is i get decreasing Temp readings while increasing the temperature. Looking at both schematics, is it possible that the R and the Thermistor r switched in positions?
How can i fix that with the formula?

I would try just reversing the leads of the thermistor, if you haven't already. Also, hook up your thermistor and use a voltmeter across pin 2 and ground of the device you purchased. You should see a voltage increase. If you do, either the code is wrong, or you have the leads reversed somewhere.

I don't know which of the scripts you are using from the link you cited. Below is what I use with a similar Op-Amp. The voltage conversion will not be the same but if you use it, at least you will see pretty quick whether your signal is going the right way

// LM358 K type Thermocouple amplifier
// Measuring full range 0 to 1250 C

int SCKX = 5;
int CS = 6;
int SO = 7;
float X = 5.0/1023; // analog reading in volts based on 5 volt max
int i=0;
int u=0;
int value = 0;
int err = 0;
float temp = 0;
int samples=1;
int units=0;
int command = 0;       // This is the command char, in ascii form, sent from the serial port 


void setup(){
 Serial.begin(9600);
  pinMode(CS, OUTPUT);
  pinMode(SO, INPUT);
  pinMode(SCKX, OUTPUT);
  
  pinMode(2, OUTPUT);      // Test Com Reset issue  
  pinMode(9, OUTPUT);      // Test Com Reset issue  

}
double Temp_Out(double Vin){ // calculates deg C from voltage for K thermocouple)
 double Sum;
 double a0=0;
 double a1=2.5132785E-2;
 double a2=6.0883423E-8;
 double a3=5.5358209E-13;
 double a4=9.3720918E-18;
 Sum=  a1 * Vin + a2* pow(Vin,2)+ a3* pow(Vin,3)+ a4* pow(Vin,4);
 return Sum * 10000; // 
}
void Average10() { // average 10 readings
  float Ave;
  int AveCt ;
  AveCt =0;
  Ave = 0;
   
  do {
      Ave = Ave +  analogRead(0) ; 
      AveCt = AveCt + 1;
      delay(10);
  } while  (AveCt < 10 ) ; 
  
   temp = (Ave/AveCt)/204 ; // Convert to 5 volt reading to degrees F
   temp = Temp_Out(temp);
}

void loop() {
    value = 0;
   Serial.flush();
     if (Serial.available()>0) {      // Look for char in serial que and process if found
      command = Serial.read();
      if (command == 84) {          // If command = "T" turn it on
          digitalWrite(2,HIGH);
      }
      if (command == 67) {          // If command = "C" turn it off
          digitalWrite(2,LOW);
      }
      if (command==68){                 //if command ="D" sound tone
        tone(9,220);
      }
      if (command==69){                 //if command ="E" end tone
        noTone(9);
      }
        command = 0;                 // reset command   
 }
    
    Average10(); // take averaged sample
    delay(50);
    Serial.flush();
    Serial.print("@- "); 
    Serial.print(temp);       // output to computer USB port
    Serial.println(" -Tmp ");
  
}

Also with ur code i get decreasing values on increasing temperature.

On reversing the leads it works the right way but it leads to destruction, because i cant just switch gnd with vcc on that 393 and be working against the diodes direction.

As u can see its:

Vcc->10K->Thermi^->GND

in every example i find its:

Vcc->Thermi^->10k>GND

so i have to solve it by code.

T2hw1dXj4aXXXXXXXX_!!295849700.jpg

got just yesterday my arduino.

i will solve this, but can someone plz explain to me whats the difference between:

double Thermister(int RawADC) {
double Temp;
Temp = log((((1024 * 10000) / RawADC) - 10000));
return Temp;

and

double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000 / RawADC) - 10000));
return Temp;

first returns 0
and 2nd returns 9

in the math way they should return the same value, or what am i not seeing?

1024 and 10000 both fit in 16 bits (the size of 'int' in Arduino C++), so they have type int. Unfortunately, when you multiply them, the multiplication overflows because the result does not fit in 16 bits. If you write 1024L * 10000L instead, you should get the correct result.

To which base are the logarithms calculated Naperian (base e or base 10? I apologize for a 'slightly' off topic question but I haven't been able to find that information elsewhere.

Doc

Both are available, see http://www.cplusplus.com/reference/clibrary/cmath/.