Go Down

### Topic: LM335 (Read 4335 times)previous topic - next topic

#### zeus2kx

##### Feb 28, 2012, 08:45 amLast Edit: Feb 28, 2012, 08:59 am by zeus2kx Reason: 1
Hello,
I am using LM335 Temperature sensor. Here is my code:
Code: [Select]
`float celsius = 0, kelvin=0;void setup(){  Serial.begin(9600); }void loop(){  kelvin = analogRead(0) * 0.004882812 * 100;  celsius = kelvin - 273.15;  Serial.print("Celsius: ");  Serial.println(celsius);                    Serial.print("Kelvin: ");  Serial.println(kelvin);  Serial.println();  delay(1000); }`

Output:
Code: [Select]
`Celsius: 41.30Kelvin: 314.45Celsius: 41.30Kelvin: 314.45Celsius: 41.30Kelvin: 314.45Celsius: 41.30Kelvin: 314.45`

41.30 degrees C is unusual. I am testing inside my room where the temperature is 19 degrees C.

Thanks.

Z

#### Runaway Pancake

#1
##### Feb 28, 2012, 02:13 pm

Insert a Serial.print statement to knock out the analogRead(0) result.
"You gotta fight - for your right - to party!"
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!

#### zeus2kx

#2
##### Feb 28, 2012, 04:46 pm

Insert a Serial.print statement to knock out the analogRead(0) result.

I added, here is the output.
Code: [Select]
`Celsius: 41.30Kelvin: 314.45Analog Read: 644Celsius: 41.79Kelvin: 314.94Analog Read: 644Celsius: 41.79Kelvin: 314.94Analog Read: 645`

What can I do to solve this issue?

Thanks.

Z

#### wildbill

#3
##### Feb 28, 2012, 04:57 pm
How do you have it wired up?

#### Runaway Pancake

#4
##### Feb 28, 2012, 05:02 pm
Well, your analogRead result means there's about 3.1V (645 * 4.888mV = 3152mV == 310K - 273 = 42C).
Are the wires to the sensor short?  They should be as short as possible.
Try a bypass cap at the sensor, 0.1uF from +V to Gnd, too.

5V / 1023 = 4.888mV (per count)
"You gotta fight - for your right - to party!"
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!

#### zeus2kx

#5
##### Feb 28, 2012, 05:08 pm
This way

http://imageshack.us/photo/my-images/718/lm355.jpg/
OR
http://img718.imageshack.us/img718/1821/lm355.jpg

#### zeus2kx

#6
##### Feb 28, 2012, 05:15 pm

Are the wires to the sensor short?  They should be as short as possible.
Try a bypass cap at the sensor, 0.1uF from +V to Gnd, too.

5V / 1023 = 4.888mV (per count)

Thanks.
No, wire length is almost like a foot.

#### zeus2kx

#7
##### Feb 28, 2012, 05:25 pm
Kindly confirm the circuit so that I fix sensor on board itself.

Thanks.

#### zeus2kx

#8
##### Feb 28, 2012, 06:01 pm
I tried connecting 0.1uF between +V and Gnd but no significant changes.  :0

#### Runaway Pancake

#9
##### Feb 28, 2012, 07:02 pm
You may be coupling noise into the analogRead with those 1 foot wires.
Better try as short as possible.  Your application likely requires remote placement, but try and find out if this helps first.
Your circuit looks like what I've seen recommended.
"You gotta fight - for your right - to party!"
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!

#### zeus2kx

#10
##### Feb 28, 2012, 07:09 pm
I soldered on the board but yet no change in readings.

#### Runaway Pancake

#11
##### Feb 28, 2012, 07:17 pm
Have you put a voltmeter to the LM335 output (right there on the board)?
If it's "3V" then maybe it's defective.
"You gotta fight - for your right - to party!"
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!

#### zeus2kx

#12
##### Feb 28, 2012, 07:55 pm
Nope, I am home, don't have one now but can check tomorrow.

#### zeus2kx

#13
##### Feb 29, 2012, 04:49 pm
I found the problem that there wasn't any problem just that Arduino was only connected through USB, not with AC adopter.

Z

#### Runaway Pancake

#14
##### Feb 29, 2012, 07:23 pm
But,... I...
Well, OK then.
"You gotta fight - for your right - to party!"
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!

Go Up

Please enter a valid email to subscribe