Go Down

Topic: Using a LM335Z (Read 1 time) previous topic - next topic


Feb 11, 2009, 10:33 am Last Edit: Feb 11, 2009, 12:03 pm by lnxrkthkr Reason: 1

Born again electronics guy here. Got my arduino a couple of days ago
and have done a lot of blinking leds lately :) 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?

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

Anyone using this sensor and could post an example?

Cheers, LnxRktHkr


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: [Select]

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
return (int(temp));




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


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.


ops, sorry

PIN3 = V+
PIN2 = V-

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

// LnxRktHkr


Do you think the wiring is ok?

Yes. Although I use a more common 2k2 resistor.

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.


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

Go Up