Pages: [1]   Go Down
Author Topic: LM335A and arduino  (Read 1020 times)
0 Members and 1 Guest are viewing this topic.
Viterbo
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
int pin = 0; // analog pin

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

void loop()
{
digitalWrite(12,HIGH);
float valRead = analogRead(pin) * 0.004882814;
float  k = ((100*valRead)-273.15);
Serial.println(k);
delay(1000);
}
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
Logged

I believe in Fairies smiley

0
Offline Offline
Shannon Member
****
Karma: 160
Posts: 10418
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: