The LM335 and it’s serieresistor

alibrated mode
Fig 1: LM335 in Calibrated mode

The LM335 belongs to a range of a fairly accurate and simple to use temperature sensors.

The LM335 operates from -40°C to 100°C. It’s output is lineair with 10mV/°Kelvin (¶ 6.6 in the datasheet). It can be used in two ways: Calibrated and uncalibrated mode. The difference is a  10kΩ potentiometer that is used to regulate the output voltage to 2.98 Volt at 25°C (25°Celsius is 298.15°Kelvin) . With more and more devices running off of 3.3 Volt, the question is sometimes raised: will the LM335 run off of 3.3 Volt as well. Going through the datasheet you will not see a min or max value stated for the voltage to be used as all depends on the current through the LM335 and that current is determined by a series resistor (R1 in Fig. 1)

If we want to use the calibrated configuration of the LM335 then this is how to calculate the series resistor for the LM335:
According to the datasheet, the potentiometer needs to set the voltage over the LM335 at 2.98 Volts at  25°C (¶ 6.4 in the datasheet). The LM335 needs between 400uA and 5 mA (¶ 6.2 in the datasheet). Suppose that the max temperature we want to measure is 30 C (=303.15 °K). The output then will be 3.0315 Volt (let’s say 3.03 V).
At 3.03V the current through the 10k potentiometer will be 3.03/10k=303uA. The minimum current that needs to flow through the LM335 is 400uA, so R1 needs to supply 703uA over a voltage of Vcc-3.03V.

So at 5 Volt that would be 1.97/0.703 = 2.8kΩ
At 3.3 Volt it would be 0.27/0.703 = 0.384kOhm =384Ω
(Note 703uA= 0.703mA = 0.000703A. I chose to divide by mA so I get outcome in kΩ).
Now we still have to check if the current will not be too high at the lowest temperature we want to measure:
Let’s say our minimum temperature is 0°C that is 273.15. At 10mV/°K that means an output voltage of 2.73 Volt.
At 5 Volt the resistor current will be (5-2.73)/2.8kΩ = 810uA. We still need to subtract 2.73V/10kOhm=273uA which flows through the potentiometer so we have 810-273=537uA, which is well below the 5mA max.

If we calculate that for 3.3Volt, we find the following:
The resistor current will be (3.3-2.73)/384=1.5mA. Subtract 273uA that flows through the potentiometer and that gives roughly 1.23mA, well within limits.

If you want to measure temperatures higher than 30°C then R1 has to be smaller. When using 3.3 Volt the  theoretical maximum temperature measurable is 330°K which is about 57°C. In practice however that does not work as you need a drop voltage over R1 so the value of R1 cannot be zero, or, in other words: you cannot connect the LM335 directly to Vcc and still expect to get an output lower than Vcc.

Bet let’s see how that would be at 50°C (323.15°K) and 3.3V Vcc :
Well again you need 703uA but this time over 0.07V.
That gives a value  for R1 of 100Ω.
But then at 0 degrees the current is 5.7mA. Still need to subtract 2.73uA which gives 5.4mA which is out of spec.

A program would be as follows:

//A0 is used to read the LM335
void setup()
void loop()
int rawvoltage= analogRead(A0);
float millivolts= (rawvoltage/1024.0) * 5000;
float kelvin= (millivolts/10);
Serial.println(" degrees Kelvin");

float celsius= kelvin - 273.15;
Serial.println(" degrees Celsius");

float fahrenheit= ((celsius * 9)/5 +32);
Serial.println(" degrees Fahrenheit");


Beware though that the ESP8266, in spite of it being a 3V3 device only wants a maximum of 1 Volt on its ADC


9 thoughts on “The LM335 and it’s serieresistor”

  1. In the code is an error.

    You need 5 V divided by 1023, not 1024. 5 V equals 1023. So 1023 * 0.004887855 = 5V

    Then you need to correct for the actual Voltage on IOref, which is not necessary 5 V. So IOref / 5. If not there is an error in temp reading, so measure it with its own powersupply, not the pc’s usb power.

    tempK = analogRead(lm355) * 0.004887855 * 100 * uRef / 5;

    1. Regarding the 1023 vs 1024 I dont think you are correct
      afaik,, but there is some discussion on it and even the website has used both values
      Yet 1024 seems to be the consensus

      With regard to the Vref, yes, but as in the program I do not call analogReference as external, it is using the internal reference (and yes for a 3v3 Arduino that is not 5volt).

      1. If you don’t the error is big.

        When measuring the 5v and made the correction the value is correct.

        For reallife measuring I would use a external Aref with presion voltage.

        When using a pot there is no problem.

      2. Using precision voltage on the external aref can certainly be precise, but not every project needs that degree of precision. If for instance one uses it to measure soil humidity even the 10bits precision of the ADC is already overkill

      3. true for humidty.

        The temperature error on my board was more than 1 degrees and that was to mutch. That why I look further and find the coarse. After making the formula it was correct.

        There are 1024 steps but you start with 0 and the 1024ste has a value of 1023, do the binary conversion for 10 ones.

        2 bit is 4 steps but the values are 0,1,2 and 3, so not 4.

      4. Perhaps we have a misunderstanding. I fully agree with what you are saying, Just wanted to make clear that on many projects no precise reference voltage is needed.
        For any precise temperature measuring I usually use a DS18B20, specifically because it is more precise than using the Analog input. Not only would you need a stable precision reference voltage but also precision resistors. I am not sure what sensor you use but e.g. the TMP35 has a precision of +/- 2 degrees celsius, The LM335 has 1 degree accuracy (but can get better with Calibration), whereas the ds18B20 has +/- 0.5 degree celsius accuracy.
        Anyway, before we make this about the best sensor…… your factor of 1023 is right

      5. I use the lm335 because you can messure negative celsius. Because there is no coorelation with the 5 v and this not not precise, what you need for adc i used the coorection in the formula but even this is not the best way.

        I have not tryed de ds18b20, but wil do in the short future.

        For the lm335 and real analog input I will go for a precise reference voltage on de aref pin.

        For use with potmeters there is no isue.

      6. The ds18b20 can do that and no need to calculate anything. Can put more than one on 1 pin. Can use long cables too

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: