# Ldr relay switch [duplicate]

I'd like to build a simple ldr circuit that turn on a relay when it's dark. I've used a voltage divider composed by a ldr in series with a 10k resistor and 10k potentiometer, which drive a 2n2222 transistor, and the transistor drive a 5v relay. The input supply is 5v. Making some calculations I've find that when the ldr is ~ 1Mohm and the preset resistor fixed to 20Kohm, the voltage should be 4.902V, but the multimeter read between base and emitter is about 600mv. Why this happen?

## marked as duplicate by Olin Lathrop, Voltage Spike, ThreePhaseEel, uint128_t, Wesley LeeFeb 12 '17 at 20:35

• Is the voltage clamped (at 600mV) by the base-emitter junction of the transistor perhaps? – JIm Dearden Jul 4 '16 at 18:30
• We love schematics. There's a button on the editor toolbar. Press it! – Transistor Jul 4 '16 at 18:30

As you describe it, you have a potential divider with an adjustable 10..20K pulling up to 5 V and a Light-Dependant Resistor (LDR) pulling down to 0 V. In parallel with the LDR is the base-emitter of an NPN transistor.

The base-emitter of the NPN will act like the anode-cathode of a diode. This stops your potential divider from dividing potentials properly. When the divider output goes beyond around 0.6..0.7 V, this diode will be forward-biased and will conduct current from its anode to cathode or, in your case, from base to emitter.

You would be better off using a comparator with hysteresis to detect your potential divider voltage and therefore your trip point. You can select one with an input current far less than your potential divider conducts at lowest light and it won't significantly disturb your potential divider's accuracy. The comparator output can drive your transistor's base with a suitable pull-up or series resistor, depending on the actual comparator you select.

(Descriptions of comparators with hysteresis are readily available on the interweb. If you're confused by any of it, post a drawn (or even photo-of-sketch) schematic of what you have and I can help you progress it from there. Schematic editor here is surprisingly dead easy.)

• A schematic would be useful, but +1 since this answer needs to be above the other one. – Olin Lathrop Feb 8 '17 at 16:40

Here is the circuit in which i used ldr and 2n2222a with 555 timer ic to turn on the relay when light is not falling on ldr. You can replace the 47k pot with higher value pot like 470k at the ldr to adjust the ldr's sensitvity.

If Your Vcc is 5v then connect the relay directly(without 100 ohms resistor) to the output of the 555 timer ic i.e, pin 3.

• Please do not post a weblink without a summary of its contents. If the linked document is removed some day, your answer will be worthless. Otherwise consider posting the link as a comment. – Ariser Feb 8 '17 at 12:36
• Sorry, I am new to stack exchange. I will correct myself in future. – Manoj B R Feb 8 '17 at 13:19
• This is a pretty poor circuit. Trying to drive a relay when the final transistor is off doesn't make sense. The relay coil current will either be very limited due to the collector resistor, or you will have to waste a lot of current just to keep the relay off. You haven't said what Vcc is, but even with 12 V, the relay gets at most 2.1 mA at 5 V. That's very little. There is also no hysteresis, so there will be a soft and unpredictable transition region between light and dark. Two transistors would be better, but even just one can be used better than this. – Olin Lathrop Feb 8 '17 at 16:38
• Yes i think this is not the best circuit i will edit it soon – Manoj B R Feb 8 '17 at 16:40