Saturday, May 12, 2012

Controlling a led using temperature sensor (lm35) and arduino

The lm35 is a simple temperature sensor whose signal can be used to find you the temperature of what ever the lm35 chip is contact with .

Steps to convert the lm35 signal to temperature

  • lm35 outputs 10mv/degree Celsius.
  • When this analog signal is connected to the arduino, it converts the signal to a value between 0-1023.
  • The voltage range of the arduino analog pin is 0-5V.
  • Thus if the arduino board reads 0 at the sensor pin it means there is 0V as input and if it reads 1023 it means the input is 5V.
  • A value in between 0-1023 indicates a value in between 0-5V, which can be calculated by the formula

For eg if the value read is 58 then the input voltage would be

Once we have the input voltage it can be converted to temperature using the information that for every degree celsius lm35 output is 10mV.
Thus for an input voltage V volts temperature would be (to convert volts to mV multiply it by 1000)

Thus for the above example the temprature would be

In this post we will see how lm35 can be used to light up leds when a certain limit of temperature is reached.
We will need

  • Two leds
  • Two resistors (220ohm) (Value chosen randomly)
  • lm35
  • arduino uno

Light up led1 when the temperature is below 30 degrees and led2 when the temperature is above 30 degrees.


The bread board and schema of connections are shown in the figures below.


Analog I/O A0 acts as input
Digital I/O 2 and 4 act outputs.
we read the analog signal at A0, convert it to temperature using the steps shown above. compare the temperature with 30
Set the pins 2 and 4 based on the result of the comparison.

Program :

Load the program into the arduino uno board and depending on the surrounding temperature one of the two leds should glow , we can modify the temperature by holding it between our fingers or placing it near something warm etc.

No comments:

Post a Comment

Follow by Email