# How to avoid Relay buzzing noise? (LDR dependent)

I have the following circuit where I'm switching a relay based on whether it's day or night. I made a voltage divider using a pot and an LDR, which leads to the NPN transistor. So when it's dark the NPN will switch, which then causes the relay to switch.

Problem: I am getting a buzzing noise whenever there is a gradual decrease in light, which is a problem since I'm going to be placing this outside. My guess is there is a threshold where the voltage causes the relay to switch back and forth quickly, causing the buzzing noise. How do I ensure the relay only switches once when light slowly fades? Is there some latching device I could use?

Also, my DC power source is via a full-wave rectifier without a capacitor, so there seems to be very small fluctuations in the DC voltage. Would that be the problem?

simulate this circuit – Schematic created using CircuitLab

my DC power source is via a full-wave rectifier without a capacitor, so there seems to be very small fluctuations in the DC voltage. Would that be the problem?

Yes. Without a capacitor to smooth out the rectified AC, the voltage will go up and down at twice the mains frequency. This is why the relay 'buzzes' - it is turning on and off in time with the rectified AC.

How do I ensure the relay only switches once when light slowly fades?

Most relays have a large hysteresis (pick-up voltage > 3x drop-out voltage) which in your unity gain circuit should be sufficient.

• Reselected this as best answer since the capacitor fixed the problem. Commented Jul 2, 2015 at 20:59

You need what is called a Schmitt trigger. And yes, you definitely need to put a capacitor on your power supply. Try something on the order of 1000 uF to start. Then measure the supply voltage, and it had better be more than 24 volts, although it almost certainly will be.

Then you need to get a comparator IC - an LM311 will do fine. You also need to get a cheap DMM to read voltages and resistances with - eBay will get you a basic unit for less than \$10. Now measure the resistance of your LDR at the sort of light level where you want your lights to come on. Let's call this 1 Megohm, just to have a number to work with.

This circuit

simulate this circuit – Schematic created using CircuitLab

should work pretty well.

• you have the comparitor inputs backwards, your curcuit turns the relay on in the light, sorry to misdirect. Commented Jun 16, 2015 at 1:21
• @Jasen - Dang! I always do that. Edited to fix. Commented Jun 16, 2015 at 1:22
• that looks better. Commented Jun 16, 2015 at 1:25

Maybe not so much a definite answer, but a nice step into the good direction allowing to gain yourself some knowledge.

The problem you face is two-fold:

1. Most of the buzzing will be solved by adding a capacitor to the power supply. Rule of thumb is 2200µF/A drawn by the load, so order magnitude 470µF should be sufficient, 4700µF is somewhat overdone (but not necessarily bad).
2. The other cause is that the transistor as you use it delivers an approximately unity voltage gain. While the surrounding light slowly increases, the voltage on the relay coil is changing slowly with it. You can partially solve this by moving the relay from emitter to collector line. So connect emitter to ground and the relay goes between +20V and collector. The relay may have enough hysteresis of its own to nicely switch on and off. The advantage is that you actually use the transistor as (voltage) amplifier.

The advantage of 2. is that you already have all components required and it is easy to test. The disadvantage is that the thresholds will probably change substantially. You may want to increase R1 to 2k2 or so to protect the transistor base. I agree with the other answer that you really need something like a schmitt trigger although I would personally probably opt for an all transistor solution.

• interesting, will consider it Commented Jun 16, 2015 at 22:30