Pages: [1]   Go Down
Author Topic: Temperature Change in Wrong Direction[solved]  (Read 557 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

I'm currently trying to create a thermostat using an Arduino Mega and an LM335A sensor. Whenever I breathe warm air on the sensor, the temperature goes down, not up. Currently I have the "Calibrated Sensor" setup shown in the datasheet, with a 2.2k resistor (too big I know, but 1.5 didn't work either), 10k trimpot, and a .1uF cap from output to ground. Any help is much appreciated!

Code:
 
//Truncated Irrelevant code ////////////
  temp=getTemp();
  lcd.setCursor(0,0);
  lcd.print("Temp:");
  lcd.print(temp);
}

float getTemp() {
  float temp= analogRead(tempPin);
  temp= ((((temp/1023)*5)*100)-273.15)*(9/5)+32;
  return temp;
}
« Last Edit: July 08, 2011, 12:26:40 pm by PerunaPete » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The capacitor is just for decoupling (reading fluctuates like crazy otherwise). Guess I'll try the bare zener soon, I just can't imagine why this is going on!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, when I say "like crazy" I mean to say that I'm not showing any steady values beyond .1 degrees. Unfortunately I don't have a scope so I can't accurately target the noise, but I'll play with some different capacitor sizes later today.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I removed the adjustment pot as suggested, and the weirdness continues.
Right now, I've got the below code to *just* give me degrees kelvin to see if it matches my multimeter.
Code:
float getTemp(){
  float in=0;
  float temp= 0;

  in= analogRead(55);
  temp=(((in/1023)*5)*100);
  return temp;
}

Even though my multimeter is showing ~2.99v (or about 78 F) right between A0 and GND, the code above is outputting 255.13..

What is going on here? At the moment, "AREF" is floating, is that the problem?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Feel like an idiot here, but the problem was that I assumed the analog pins rolled over on the mega (eg, pin A0= pin 55) instead of just accepting "A0". When I was getting close to blow on the breadboard, it was altering the noise in the circuit. Here I was trying smoothing and RC filters, and it was a stupid number... thanks for the help anyway guys!
Logged

Pages: [1]   Go Up
Jump to: