LM35 Sensor?

I wanted to know how to convert the readings from a LM35 sensor to Celsius and Fahrenheit.I need them for a thermometer application. I would also like to have the arduino code to serial print the values 

Picture of LM35 Sensor?
sort by: active | newest | oldest
The LM35 gives a fixed voltage change per deg change. The scale factor you apply to turn it into F or C is something you can work out easily.

The thing gives 10mV/deg C - very small input volts for an arduino too. Not allowing for noise, you can only read about 0.5C with it.

So deg F = 9(Deg C) /5 +32


2nd half of question:

*completely untested, ripped from this link

\/*LM35 Thermometer
*LM35 simply connected to:      5+
*         0V
*         Analog Pin 0

int potPin = 0;         //input read pin for LM35 is Analog Pin 0
float temperature = 0;       //variable which will be calculated in process

void setup()
  Serial.println("LM35 Thermometer    ");  //Print "LM35 Thermometer" once at start

void  printTenths( int value){
   // prints a value of  123 as 12.3
Serial.print(value / 10);
Serial.println( value % 10);

void loop ()
  int span = 20;
  int aRead = 0;
  for (int i = 0; i < span; i++) {   //loop to get average of 20 readings
    aRead = aRead + analogRead(potPin);
  aRead = aRead / span;

  temperature = (5.220*aRead*100/1024);      //convert voltage to temperature
  Serial.print ("Analog in reading: ");
  Serial.print (long(aRead));  //print temperature value on serial screen
    Serial.print (" - Calculated Temp: ");


Be careful if you copy/paste to look for wrapped lines.

The Arduno's resolution is pretty crappy though - the sensivity will be horrible.
decent if it's what you have and don't need uber precision...

Would you not be able to trade precision for range? By altering the aRef from 5 down to 2.5 your readings would go from 0-100 to 0-50, with twice the voltage steps detected/degree.

Still agree, not a great sensor. I'd prefer something with an internal adc and i2c
Yes, tweaking the Vref to something lower would be a good plan - though these on-board ADCs are very noisy.

The LM35 is pretty accurate though, certainly compared to the +/- 2 deg "precision" sensors with digital interfaces, like Maxim make.. I ask you , how the heck can 2 deg C be "precision" ????

All you need is a cheap opamp to boost the signal, with a gain of 10 and practically no AC gain, and you're there.
repeatability answers that question. if repeatable, then it can be calibrated. It doesn't output discrete steps.