Pages: [1]   Go Down
Author Topic: Using a LM335Z  (Read 876 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Born again electronics guy here. Got my arduino a couple of days ago
and have done a lot of blinking leds lately smiley Moving on to temp sensing.
I got a LM335Z (datasheet) and wondering
if anyone have used this sensor? Here is how I have connected the sensor:



I get a constant analogRead value of about ~1000 which probably
is very wrong.. Do my wiring look ok?

I'm trying to figure out how to convert the readings (when ok) to
a "human" value.. I should get 10mV per Kelvin but how do I map
the "a/d" value to voltage again to find out the temperature?

Edit:
Voltage = analogRead(X)*5.0/1024.0; if using 5V as ref...

Anyone using this sensor and could post an example?

Cheers, LnxRktHkr
« Last Edit: February 11, 2009, 06:03:28 am by lnxrkthkr » Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 78
Retired Electronic Technologist focusing on Wireless network development.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Two examples here. As small part of my MRMP controller code. The first small and fast and the second, commented out, has a range checking schema.
Both return the temp in degrees C x10. In general, floating point is rarely required and should be avoided.


Code:
// TTTTTTTTTTTTTTTTTTTT Temperature 2.2 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
// TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT


int tempOnPin(int pin,int offset,int slope)
{
  return ((((analogRead(pin) * 10) - offset) * 100) / slope);
}
/*
 
 #define BitsPerDegree 215       // Slope  2.15
 // #define Bits0Degrees 5490       // Offset. 10 x the bits at zero degrees in WATER.
 #define Bits0DegreesAir 5650    // Offset. 10 x the bits at zero degrees AIR temp.
 // When self heating is an issue for air temp make this lower.
 
 #define MaxTempError 2000       // Used to set upper and lower before error value passes
 #define MinTempError -500
 #define TempError -32000        // Used by functions to determine if sensor shorted or open
 
 
 // Read the temperature LM335 sensor 2k2 and 5v
 int tempOnPin(int pin,int offset,int slope)
 {    
 
 long temp;
 
 temp = analogRead(pin);   // read the value from the sensor
 
 
 temp = ((((temp * 10) - offset) * 100) / slope);      //  10 x the degrees c on pin returned
 
 if ((temp > MaxTempError) || (temp < MinTempError))   // between Max and Min or error
 {
 return (TempError) ;     // Used by calling routine to determine if sensor is shorted or open
 }
 else
 {
 return (int(temp));
 
 }
 }
 
 */

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello George,

Thanks for your reply!
Do you think the wiring is ok?
Also, what are the "offset" and "slope" arguments for?

Sorry for my ignorance...
Logged

Montreal
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
i just check the datasheet, and there is no relation to VO and VI, so i have a hard time figuring wich pin you connect to what?
You should have 10mV/Kelvin that aroud 2.93Volts at room temp (20deg Celcius)
if you have around 0.6-0.7 volt that is probally that you wire the zener in reverse.
Logged

Patgadget
Montreal

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ops, sorry

PIN3 = V+
PIN2 = V-
PIN1 = ADJ

I get almost 5v on the V+ pin...

// LnxRktHkr
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 78
Retired Electronic Technologist focusing on Wireless network development.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you think the wiring is ok?
Yes. Although I use a more common 2k2 resistor.

Quote
Also, what are the "offset" and "slope" arguments for?

Offset. 10 x the bits at zero degrees in WATER or AIR
Simply imerse your sensor in melting ice water to determine the offset bits in water. Alternatively, use a known-good thermometer, and adjust the offset until the output matches.


Slope. If you plotted the degrees vs bits on a graph, the slope (angle) would be 2.15 Knowing the slope and the bits, you can computer the degrees.

Hope that helps.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That helps, thank you! Now I got something to continue testing with..
Logged

Pages: [1]   Go Up
Jump to: