LM35: How to get Stable Temperature Reading

One of the most common analog temperature sensors used for temperature monitoring and controlling is LM35. According to the manufacturer, LM35 is a precise centigrade temperature sensor, but the reality is a bit different when we directly wire this sensor with Arduino. There are various reasons for fluctuation in output. Here in the article ” LM35: How to get Stable Temperature Reading” we will address almost all the reasons and solving one by one. But before that let’s see how this sensor work.

Basic Working of LM35

According to the datasheet of LM35D, it can measure temperature from 00C to 1000C with 10mv per degree change in temperature. This sensor senses the temperature and produces a corresponding voltage from its output pin i.e. 10mv/0C. At 00C it produces 0mV and at most 1000C it produces 1000mv i.e. 1V output.

Reason of error/deviation in temperature output.

  1. Noise in power supply
  2. Self-heating and electromagnetic interference
  3. Taking Single reading at a time
  4. References voltage

author prototype of how to get stable outputFigure: Author Prototype

How to get stable Temperature Reading.

  1. Adding Filter Capacitor at power rails of LM35:

The fluctuation of temperature output might be the noise available in the power supply so it’s better to use an electrolytic capacitor at the power supply i.e. connected to Vcc and GND of LM35. Let’s say adding 10uF to the power supply will stable output to some extent.

  1. Adding resistance between the output pin and GND pin

According to the datasheet of LM35, it has low sinking capability, as a result, its output becomes more sensitive to electromagnetic interference. 1K or 2K resistor between output and GND can solve this issue to some extent and also solve self-heating error.

  1. Taking average reading rather than a single reading

Fluctuation or drift is one of the major issues of the Arduino sensors. One way to make fluctuation less is by trying to calculate the average reading instead of a single reading.

How to minimize the error

When we use default reference i.e. 5V reference at analog input, it is less sensitive to voltage difference. At this reference, Arduino can map 5V input voltage into 1024 steps i.e. 0-1023. This means resolution at 5V = 5/1023 = 4.88 x 10-3V = 4.88mV. So, if we use the default 5v analog reference minimum temp deviation that Arduino can detect is 0.50C. If we use the default Arduino reference voltage we will end up adding a 0.50C extra error.

This error can be minimized by selecting the proper reference value for Arduino. Let’s say if we use a 1.1V internal reference for Arduino, the minimum temperature deviation that Arduino can measure is drastically improved.

Let’s calculate the minimum temperature deviation that Arduino can measure.

Internal reference voltage = 1.1V

ACD of arduino = 10 bit = 210 = 1024 Step

Resolution = 1.1V/1023 = 0.00107V = 1.07 mV.

If we use 1.1V internal reference voltage then resolution becomes equivalent to 1mV i.e. it can measure temperature 0.10C temperature deviation.

Related articles you may like:

  1. Arduino Based Temperature Controlled Fan
  2. Measuring Temperature using PT100 and Arduino
  3. ESP8266 Temperature Logger using PIC16F887
  4. Arduino Based Data Logger (Temperature)

Circuit Description of  LM35: How to get Stable Temperature Reading

The circuit is shown in figure 1, designed around Arduino nano, I2C LCD, LM35 IC, and a few other electronic components like resistor and capacitor. LCD and Arduino share an I2C pin where LM35 is connected to the A0 pin of Arduino. A 1K or 2K resistor is connected between output and GND. A capacitor of a few microfarads is connected to Vcc and GND of LM35.

lm35 how to get stable temperature reading

Component Required

Arduino uno/nano x 1

I2C 16×2 LCD x 1

Lm35 x 1

1K resistor x 1

10uF capacitor x 1

Software Code:

Software Code of  LM35: How to get Stable Temperature Reading is written in C/C++ programming language and compiled using Arduino IDE. Here we are using mills function of Arduino instead of delay. For stable reading, we are taking a reading of 100 samples and computing its average, and displaying a change in temperature over LCD every 2 seconds.

One Thought to “ LM35: How to get Stable Temperature Reading”

  1. Rob

    Thank you so much for creating this web site. Your code is exactly what I needed.
    I have noticed the final temp is -2deg to the actual deg. Is there a solution?

Leave a Comment