Analog Temperature sensor inaccurate? Or is the Arduino at Fault?

Hello again, I have a project where I wish to take the ambient room temperature, and display it on a 16x2 display. The display works fine, it's the analog temperature sensor that's the issue. When I hook it up (correctly) and ask it to output to a variable, it only displays the number "18". Of course, I'm using an analog in port (A0, in this case.). I found a datasheet for my sensor, which is an SGS-Thomson LM335. Any idea why it'd only be outputting the number "18" and nothing else? It works through 10mV/degree Kelvin. When I hook my multimeter up to the sensor, it will show 2.93V. Of course, that would be 293MV, so 293K. 293K is 19 degrees Celsius. It's not that cold in my house. Any idea on what's wrong? A programming example, maybe? I've even included a massive picture of my circuit.

IMG_2634[1].JPG|3264x2448

(deleted)

(deleted)

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float tempC;                            // create variable to store the temperature in.
int tempPin = 0;                        // Attach vout to analog pin 0.

void setup()                            // Will execute once at the start of the code.
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
  }

void loop()                             // code here will continue to replay until powered off.
{
  tempC = analogRead(tempPin);          // read the analog value from the lm335 sensor.
  tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.
  Serial.println((byte)tempC); 
  Serial.println((byte)tempPin); // send the data to the computer.

    
  delay(3000);                          // wait 3 seconds before redoing the loop.
}

not printing to the display for now for reasons of troubleshooting. Here, i will consistently get the number 28-30, followed by a zero.
this means that tempC = 28-30, and that tempPin = 0?!?

today, I'm getting a measurement from my multimeter of around 2.59-2.6V

(deleted)

Ok, that fixed it partially. Now I’m back to getting the number “18” and nothing else.

(deleted)

Ok, done and done. This gets rid of the 18, however, now I’m wondering exactly what the 28-30 is! It’s nowhere near that temperature in my house. It’s somewhere around 25. And when I put my fingers on the sensor, the temperature actually dropped to 28! Got any clue on what’s going on?

(deleted)

It’d appear as though it’d doing the opposite of what it should be doing! I put it outside, to find that it read out on my serial port as “37”!

Here’s a (very) rough schematic of how I have things hooked up; i excluded the display as it isn’t used to determine temperature.

I'll revisit this tomorrow morning, for I wish to go to bed. Good night. If anyone has any idea on what's wrong, do post a reply on this thread.

Hi.

http://www.uib.es/depart/dfs/GTE/staff/jfont/InstrETT/lm335Z.pdf

Please read it and then connect the sensor up the correct way with a series resistor on page 6/11. You do not connect it across the supply and get volts/DegC out.

Tom.................. :)

TomGeorge: Hi.

http://www.uib.es/depart/dfs/GTE/staff/jfont/InstrETT/lm335Z.pdf

Please read it and then connect the sensor up the correct way with a series resistor on page 6/11. You do not connect it across the supply and get volts/DegC out.

Tom.................. :)

Please Tom, if you could, could you please describe in more detail on how to do it? It's my first time using electronic circuits. What is an R1?

Hi, try this.
Not my work, but cut from another site.
This is the basic setup, you don’t use the adj pin.

Tom… :slight_smile:

Got it working :D I just multiplied by -1 to get rid of the inverted measurements (meaning colder gives a higher number and warm giving a lower number), and then adding the non negative number of the variable plus the actual temperature! Works, and doesn't need resistors :P