Monday, July 23, 2012

Measuring tempearture using LM35.


Things you Need

  1. LM35 IC
  2. Male & Female Burg-Stick (optional if using breadboard)
  3. Solder wire & Soldering Iron
  4. Connecting Wire

Time Needed

1-2  hour depending on how good & fast you are at soldering. If using breadboard to make temporary circuit it will hardly take an hour.


Difficulty Level

Easy :)


The pin configuration of LM35 is shown below.




Step 1:
Insert the female burg-stick to a small piece of PCB (I do so to make circuit more stable and durable) or insert in a breadboard. Then Solder it. Also insert the Male burg-stick and solder it.
Now insert the LM35 IC in that female stick.




Step 2 (If using AVR-KIT from BRiCS):
Connect pin1 of IC (VCC) to pin2 of stick, pin2 of IC (VOUT) to pin4 of stick, pin3 of IC (GND) to pin1 of stick.





Step 2 (If using BreadBoard):
Connect pin1 of IC (VCC) to VCC of MCU (pin10 in Atmega16,pin7 in Atmega8), pin2 of IC (VOUT) to any ADC pin (port-A in Atmega16, port-C in Atmega8) of MCU, pin3 of IC (GND) to GND of MCU (pin11 in Atmega16,pin8 in Atmega8).

Step 3:
Connect the stick directly to kit . Those using breadboard don’t need to anything.

Hardware part is done. :)





Coding & Concept:
Lm35 IC gives a linear output voltage in Degree Celsius.
There is rise of 10mV of output voltage for one degree rise in temperature. This means,
500 mv == 50°C       100 mv == 10°C     and so on.

Datasheet tells that it may measure tem[erature from -50°C to 150°C!!  :O
 We know that (I suppose :P) in avr MCU the ADC reading is in 10 bit, that means

1024 adc reading = 5 volt = 5000 mv = 500°C  (not measurable).
1 adc reading = 5/1024 = 0.0049 volt = 4.9 mv = 0.49°C
x adc reading = 0.0048828*x volt = (4.8828 * x )°C
.

So we have our formula ready i.e. Temperature =   (4.8828 * adc_reading )°C.
The coding is shown below.


Now lets see the output.


Ok but now how can I produce a high temperature, lets bring the soldering iron (which I left on) near the IC, It should increase the temperature.


See its working. It rised to 41°C from 31°C.

You can make this circuit on PCB also.

We can use two 7segment LEDs also to display the temp, it looks cool :)

To learn how to use 7segment LEDs please have a look on my post "How to interface 7segment LED with Microcontroller"  Link will be updated soon.

To learn "How to control a fan speed according to temperature variation" please  refer to my post "How to use PWM with Atmega-16" Link will be updated soon.

If you have any other idea about what else we can do with the temperaure from LM35 in other projects please let me know, I'll try to include it here.
Suggestions And Queries are most welcome. :)  

Please Share it! :)

Post a Comment

No comments: