Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can anyone teach me how to use lm35?

Not open for further replies.


Member level 1
Feb 16, 2012
Reaction score
Trophy points
Activity points
log.png the relay wont switch :( is there anything wrong on how i connect the lm 35 in my circuit? i really dont know how to use lm35 so i dont have an idea what seems to be the problem.. any help?

Are you sure that schematic is supposed to use an LM35? It is an unusual configuration for it.

Normally the LM35 is used as a DC source which increases in voltage according to temperature, I'm not saying the schematic would not work but I've never seen the device used in that way before. It appears to be used as a variable resistance or possibly a clamp across the oscillation from the first gate, if it's a clamp, I wouldn't expect the relay to operate until more than about 65 degrees is reached. As it depends on the output impedance of the LM35, you might find it's performance varies between batches or different manufacturers as that is not a guaranteed parameter.


to tell you the truth im just experimenting.. i really dont have an idea how to use lm35 ^_^ sorry.. well that circuit has an LDR sensor i just need to replace it by lm35.. but i dont know how to..

Thank you for confirming my sanity!

An LDR probably would work in that design because it has the property of changing resistance according to light level falling on it. The oscillator in the first part of the circuit produces a signal detected by the second part which in turn drives the relay. The LDR shorts the signal out when illuminated so the detector sees less and turns the relay off. You could think of the LDR as being a volume control operated by light!

An LM35 works completely differently though, it actually produces a voltage on it's output pin which is proportional to it's body temperature. The voltage rises by 10mV (0.01V) for each degree celsius so you can either measure it to tell the temperature or compare it to another voltage to decide if some action should be taken, for example operating the relay. To use it to measure temperature you need to connect it to something that measures it's output voltage and converts it to numbers. This could be an analog meter or a digital display. These days most people opt for a digital display so you would connect the output pin to an analog to digital converter (ADC) which gives you a numerical value proportional to the voltage.

If you want to use it just as a temperature controlled switch, there is no need to actually measure the temperature, all you are interested in is whether it is below or above a set amount. This is normally done with a voltage comparator. A comparator has two inputs which are compared to decide whether the output pin should be high or low voltage, it switches abruptly between the two as one input voltage exceeds the other. You would make one input your comparison voltage and the other the output from the LM35. If the temperature rises, the LM35 voltage would increase and if it went higher than the comparison voltage the comparator would change it's output state. The comparison voltage may come from an adjustable control or potentiometer in which case you have an adjustable thermostat.

The only caveat withthe LM35 is the voltage per degree is quite small so you have to be careful not to lose it in background interference. This means giving it a clean supply voltage and avoiding entry points where unwanted signals might get mixed with it's output. Quite commonly you will see an amplifier close to the LM35 to increase it's output voltage before it's used.


tnx for ur help sir ;) but before u said it i did use an amplifier to amplify the lm35's output voltage bcoz its output is too low to trigger the nand gate.. so i decided to put an amplifier for the lm35.. here it is acast.png do you have any suggestion or comments? if ive done a mistake please inform me sir.. thank you again ;)
Last edited:

Sorry for a late reply, I just had a batch of circuit boards delivered for assembly and I have to give them priority. No work = no money = hungry Brian :lol:

I'm afraid your circuit still would not work. I can see what you did with the op-amp to increase the output of the LM35 and that is good. The real problem is the way the original circuit was supposed to work. Incidentally, it had a serious design mistake that would almost certainly damage at least one component - can you spot it?

It would be useful to understand why the circuit isn't suitable so I'll try to explain, this refers to the original circuit not the version with the extra amplifier:

U1:A is used as a schmitt inverter. The output goes low when the input goes high and the output goes high when the input is low. R1 couples the output back to the input so it would try to keep switching itself from one state to the other all the time. C1 slows down it's response to output changes by taking time to charge and discharge through R1 so it lowers the oscillation frequency to around 2.9KHz. The oscillation was passed through C2 to a voltage doubling rectifier made from C3, D1, D2 and C4. When the voltage from the rectifer was high enough, it reached the point where the AND gate changed state and turned the transistor on to drive the relay (there is a clue there to the mistake in the design).
The LDR was a resistor that changed it's value when light fell on it. The resistance dropped as it got brighter. Where it was wired at the junction of C2 and C3 it acted as a level control as so adjusted how much AC signal voltage from the oscillator reached the rectifier.

The LM35 doesn't work as a controlled resistor so it can't adjust how much signal passes that point. Instead it produces a voltage at it's output pin so to make it operate the relay you have to sense when the voltage has reached or gone beyond a threshold. It is far easier to do this with analog ciruits than with logic gates so I would suggest you forget the original design completely. At it's simplest, all you need is a comparator, a potentiometer, a resistor and a transistor to drive the relay. I would suggest you try this: connect the LM35 output to one input of an LM311 and a potentiometer across the supply with it's wiper pin connected to the other input. From the output pin of the LM311 connect a resistor of 4.7K to the positive supply and also connect the output pin to the base of your 2N2222 as before. At a certain position on the potentiometer you should see the relay operate, the position will depend on the temperature so you can use it to set the 'trip point' at which the relay operates.


no its ok sir.. i fully understand ur situation.. ;) and thnx for a knowledgeable reply, but im afraid i cnt change the circuit as my instructor requires a logic gate as part of the circuit.. there's one question i would like to ask sir.. if i build the circuit ive done what will happen? it will not trigger the relay? or what? thnx in advance sir brian.. ;)

I doubt it will work but if the relay turns on it will either destroy the transistor or the AND gate. When the output of the AND gate goes to logic high state, it's output will be held down by the current flowing into the transistor base pin and one or the other (possibly both!) will be damaged. You shoud add a resistor between the output of the gate and the transistor to limit the current. I would suggest 2.2K would make it safe.


thnk you sir brian i'll do wat u suggest.. but why do i need to put a resistor between the output of the and gate and transistor? im building the circuit now.. and i hope it wont explode in my face.. haha xD honestly sir thank you very much.. i hope i can repay you for your kind tutorial ;) thank you again sir!
Last edited:

Think in terms of a small puff of smoke - no need to build a bomb shelter :grin:

The resistor is needed because a bipolar transistor like the 2N2222 has a P-N junction between it's base and emitter pins. The emitter is grounded so when you put current into the base it forward biases the P-N junction. That is normal operation but a silicon P-N juncton holds a constant voltage across itself when current passes through it, the voltage is typically about 0.65V. If you try to apply more voltage, it draws more current to try to hold it at 0.65V.

Consider what happens in the output stage of the AND gate, internally it has a switch to ground to make it's output low (logic 0) and a switch to the supply rain to make the output high (logic 1). Obviously these are wired inside the gate so one or the other operates but not both at the same time or it would short out the supply lines! Look at what happens if the AND output goes high, it closes the switch linkng the output pin to the supply pin and tries to lift the output pin to the supply voltage. That would put full supply on the base of the transistor and make a large current flow. This will overload the output stage of the AND gate and also the B-E junction of the transistor so one or both would be damaged.

The transistor only needs a small base current so the simple solution is to add a resistor between them. This limits the current that flows into the base and allows the logic output of the AND gate to change without being overloaded.


yeah.. thanks for the enlightenment sir.. i see your point now.. i hope that it work well.. thanks to your tutorial sir.. i cant thank you enough for wat uve done to me ;)

- - - Updated - - -

sir? im doing a testing on my lm335 by connecting a 9v to its input and -9v to the gnd but when i connect my vm to the output pin and gnd it always read 4. sumthing volt and when i put a hot water above it it doesnt change its output.. what seems to be the problem? i cant go on building the circuit if i cant operate the lm335 :) do you have an idea sir how to test an lm335 properly? am i doing it the wrong way? haha.. i hate this lm335 ^_^

- - - Updated - - -

Not open for further replies.

Part and Inventory Search

Welcome to