LM335A and arduino

Hi all,

i've tried to use a lm335a themperature sensor with my arduino uno board. But i'm not sure if i'm doing everything correctly. (I'm very new to arduino and electronics).

I connected the sensor to arduino as shown in figure:

And the code that i used is that:

int pin = 0; // analog pin

void setup()
  Serial.begin(9600); // start serial communication
    pinMode(12, OUTPUT);     

void loop()
float valRead = analogRead(pin) * 0.004882814;
float  k = ((100*valRead)-273.15); 

Now i'm not sure about the results (i did not checked the temperature in my room) are here: http://pastebin.com/uMCEFvGQ As you can see the temperature seems to be abbout 16-17 degrees. The fact that i don't understand are why the values change so many times (and sometimes it have very strange values, like 5.66 degrees) Notice that in after the 50th value i put my fingers on the sensors.

My questions are: 1. The sensor is wired correctly? 2. These values can be ok? 3. THere are some errors in my code?

Thanks a Lot! Ivan

It seems you are sometimes seeing a few bad values but most are OK - perhaps there is some electrical noise causing the rogue readings?

You can take several readings in succession and average them to help reduce the noise. Perhaps a small capacitor from the analog pin to ground (say 1nF) could help.

If you have long wires then you might be picking up RFI or switching transients from household appliances - use screened cable for low level signal wires of any length.