Introduction: Using the LM335 Temperature Sensor

The LM335 is an easy to use, relatively precise temperature sensor. It is great for things like temperature loggers and temperature controllers. This sensor is much easier to use than thermocouples, because it does not require any additional interface circuitry. It is also easier than thermistors or other resistive temperature sensors, since it requires no calibration, and has a linear response.

When connected the sensor acts much like a Zener diode. Regardless what current is flowing through it, it will drop the same amount of voltage. The voltage at the output will be 10 millivolts per kelvin temperature. This means at a comfortable room temperature it will output about 2.93 V. This is close enough to the middle of our measurement range of 0-5V to allow a wide range of measurement with the arduino.

For this instructable you will need:

  • An LM335 sensor, in the TO-92 form factor (as shown)
  • A breadboard
  • An arduino
  • Some jumper wires
  • A 1 kiloohm resistor

Step 1: Connecting the Sensor 1

The pinout shown is the bottom view. The ADJ pin is for calibration, and can safely be left disconnected. We can do any calibration using the arduino sketch. Put the sensor in the breadboard as shown. Flat side toward you.

Step 2: Connecting the Sensor 2

Now connect a resistor to the center lead of the sensor, and run it to the other side of the breadboard. Connect the resistor to the 5V pin of your arduino.

Step 3: Connecting the Sensor 3

Connect a wire from the Analog 0 (A0) pin of your arduino, to the center lead of the sensor.

Step 4: Connecting the Sensor 3

Finally, connect the GND pin of your arduino to the right pin of the sensor.

Step 5: Measure Your Supply Voltage

If you are using an external power supply you probably have 5 V nearly exactly. If, on the other hand, you are powering your arduino from usb, you probably have a little bit less. Since the supply voltage is the reference for the ADC, you will need this to calibrate your measurements. Using a multimeter, find the voltage between the 5V and GND pin of your arduino, and write it down. I got 4.92.

Step 6: The Arduino Sketch

To read the temperature you now need to get the value of A0 using analogRead(0). This will give you a value between 0 and 1024. 1024 will represent the supply voltage. Below is an example sketch to read the LM335. You can download this code here. I split off the class I used here as an arduino library. If you want to use it you can download it here. Once you have that file, unzip it and copy it you your arduino/libraries directory. You can then import it into any sketch you like.

 class LM335<br>{
  float cal;
  int pin;
  LM335(float mCal, int mPin);
  float measureV();
  float measureK();
  float measureC();
  float measureF();
  float measureRankine();
LM335::LM335(float mCal, int mPin)
  cal = mCal;
  pin = mPin;
float LM335::measureV()
  float retVal = (float) analogRead(pin);
  retVal = (retVal*cal)/1024.0;
  return retVal;
float LM335::measureK()
  return measureV()/0.01;//10mV/k
float LM335::measureC()
  return (measureV()/0.01)-273.15;
float LM335::measureF()
  return (((measureV()/0.01)-273.15)*1.8)+32;
float LM335::measureRankine()
  return measureF() + 458.67;
LM335 mTemp(4.92, 0);//supply volts, analog pin
void setup()
void loop()
  Serial.println(" volts");
  Serial.println("Temperatures: ");
  Serial.print("Kelvin: ");
  Serial.print("Fahrenheit: ");
  Serial.print("Celsius: ");
  Serial.print("Rankine: ");

Step 7: Upload and Run the Sketch

Once you hit upload, you can open the serial monitor. The output should look something like this:

Kelvin: 292.13 Fahrenheit: 66.16 Celsius: 18.98 Rankine: 524.83 2.92 volts Temperatures: Kelvin: 292.13 Fahrenheit: 66.16 Celsius: 18.49 Rankine: 524.83 2.92 volts Temperatures: Kelvin: 292.13 Fahrenheit: 66.16 Celsius: 18.98 Rankine: 523.96 2.92 volts Temperatures: Kelvin: 291.64 Fahrenheit: 66.16 Celsius: 18.98 Rankine: 524.83

Now you know how to measure temperatures with an arduino.