ESP Logo
 Elliott Sound Products Project 131 

Light (Or Sound) Activated Switch

© June 2010, Rod Elliott (ESP)

Introduction

This has very little to do with audio, but I suppose that you could use it to switch on your hi-fi (instead if a light) when it gets dark.  The sensor is a light dependent resistor (LDR, aka cadmium sulphide photo-resistor).  Most LDRs have a resistance of well over 1 Megohm in total darkness, and some can get down to only a few hundred ohms in bright light.

It's worth pointing out that a great many of the circuits on the Net that are supposedly light (or dark) activated switches have serious design flaws, and should not be used for controlling anything of any consequence.  I have seen 'comparators' that are wired as amplifiers and have no hysteresis at all (see below for a full explanation), and there are a few kits being sold that just use a couple of transistors - they may work, but switching point stability is often woeful.

There are two main requirements for any general purpose light activated switching system such as this ...

The design shown here has both, so you won't be destroying any relays or connected equipment, and the switching reference voltage is as stable as the regulated supply voltage.  For critical applications, a thermally stabilised zener reference could be used, but that's overkill for most systems.

As a temperature controller ...   You can substitute a thermistor for the LDR, so you can turn on central heating, air conditioning or anything else that can be activated by a contact closure.  The main difference between this project and Project 42 is the deliberate simplicity of this design, and the use of a thermistor instead of diodes.  It has been reduced to the bare minimum, but still functions very well and will do most tasks expected of it with ease.  It can be used instead of the P42 design, and the relay can control mains powered fans if you want to use them.  While it is superficially simple, there are several things that must be done to ensure reliable operation over a long period.  It is not designed for rapid switching - it is designed for applications where the switched circuit is activated at intervals of not less than a few second (perhaps 10 seconds or so).

This circuit would also be an ideal addition to a rack cabinet to switch on the fans if the temperature rises beyond a preset value.  In this instance, you'd probably want to set the temperature to no more than perhaps 35°C or even less.  It is also useful as an incubation temperature controller and can even be used for the same purpose I built mine ... to switch on (LED based) path lighting at dusk and off again at dawn.


Note that this project involves mains wiring and a knowledge of proper techniques when working with the mains.  Errors or omissions may occur in this document, and ESP offers no warranty of any kind.  The project's safety and functionality are solely at the risk and based on the skill of the constructor, and ESP shall not be liable for any damages whatsoever for any reason, even if ESP has been made aware of a fault or risk.  No-one should attempt this project unless suitably qualified.

Description

The project itself is as simple as it's possible to make it.  The opamp can be anything you have to hand - even a dual opamp can be used if you wish ... just ignore the other half.  As shown, I used a μA741, but almost anything will work.  If you use something different, make sure that you check the data sheet to make sure that it is wired correctly.

Although shown with an LDR (light dependent resistor) a thermistor is also a perfectly acceptable sensor.  Indeed, anything that changes its resistance can be used as as sensor - including a pot.  I can't see a particularly useful application using a pot, but I can think of a few frivolous approaches that could be adapted (albeit with little or no point). :-)

The first version is triggered when the light level falls below the threshold (or if temperature falls below threshold if a thermistor is used instead of the LDR).  This is the most likely way that such a controller will be used, because it will be used to switch on outside lighting or perhaps a heater.  When light level or temperature returns to normal, the controlled device switches off again.

Figure 1
Figure 1 - Low Light/Temperature Activated Controller

In its basic form, this is a very simple circuit.  The only scope for complexity is based on how much hysteresis you need.  I strongly recommend that any such circuit has at least some hysteresis.  There are quite a few schematics on the Net that appear quite similar to this, but hysteresis has been omitted - this is a very bad idea, especially if you are driving a relay.  It's shown with two LEDs - one to indicate power is on, and the other to show that the relay is activated.  This is especially useful while setting up and testing, as it's much easier than hooking up stuff to the relay contacts.  The LED series resistors can be adjusted to get the brightness you need, but I suggest that you don't go lower than 1k.  If high brightness LEDs are used, you'll probably find that 10k is about right.

The relay needs to be suitable for the application, and a 10A relay will be suitable for most things you need to do.  As shown, the circuit is capable of driving fairly sensitive relays, having coils of not less than around 200 ohms (60mA at 12V).  If you need to power anything that draws significant current, it's usually easier to use the small relay to drive the coil of a larger contactor which will usually have a mains voltage AC coil.

Hysteresis is controlled by R4, and is essential to prevent relay chatter when the light or temperature is right at the reference level.  The amount needed depends on your application, so adjust R4 )or select a likely candidate from the table below) until there is no relay chatter even if the input voltage is right at the trigger level.  The value shown (1 Meg) is the bare minimum - most applications will use a lower value.  For probably 99% of all uses, R4 will be between 100k and 1Meg.

For those applications where you need to switch something on when the light level exceeds the threshold, use the following version.  As you can see, it is virtually identical.  The same thing can be achieved by using the normally closed relay contacts in the Figure 1 version, but this has a small disadvantage of higher power consumption because the relay is on most of the time.  Most relays draw around 0.5 - 0.75W for typical 10A types.  This may or may not be a disadvantage, depending on your needs.

Figure 2
Figure 2 - High Light/Temperature Activated Controller

It is also possible to use a switch to reverse the way the circuit works if this is something you might need to do regularly - I can't imagine why, but people often need very strange things.

The power supply is intended to be a 12V DC supply, and ideally it will be one of the newer switchmode types so has the advantages of being regulated, and also very low standby power dissipation.  This assists with simplifying the design, because there is no need for additional regulation of the reference voltage.  These supplies have another benefit too - their mains power usage is very low - I measured mine at less than 400mW from the mains when all wired up and operational, but with the relay de-energised.

If you use an unregulated DC supply, you will have to add a regulator (7812 or similar) or the threshold (trigger point) will change with the mains voltage.  Under these conditions, the DC input voltage to the regulator will have to be at least 15V at the lowest typical mains voltage that you get where you live.  A regulated switchmode supply is much easier, and they are now quite cheap too.

Hysteresis
For those who either don't know the term at all, or who are puzzled by its meaning, hysteresis is one of those concepts that can be difficult to grasp.  It occurs naturally, but the most common (and obvious) applications are man-made.  The standard light or power switch as used throughout the world has a snap action that ensures that the contacts open and close quickly.  This is a perfect example of hysteresis - and it ensures that there is no position of the switch where the contacts are just opening or closing, unless the switch is worn.  Try it ... as you move the switch ever so slowly, suddenly there's a snap action and the contacts either open or close.

That's hysteresis.  When applied to an electronic circuit, it does much the same thing.  The voltage rises towards the trigger voltage, and actually gets slightly above the point where the output should change state.  Once it does trigger, the effect is instant, and the voltage now has to be reduced to some value below the trigger voltage before the output will change state again.

Look at Figure 1 or 2 ... the feedback resistor (R4) connects to the positive input of the opamp.  This means that the feedback is positive, not negative, so the opamp does not operate in linear mode.  This circuit configuration is known as a Schmitt trigger.

 R4 Value HysteresisTotal
 1 Meg ± 25 mV 50 mV
 820 k ± 30 mV 60 mV
 680 k ± 36 mV 72 mV
 560 k ± 44 mV 88 mV
 470 k ± 53 mV 106 mV
 390 k ± 63 mV 126 mV
 330 k ± 75 mV 150 mV
 270 k ± 91 mV 182 mV
 220 k ± 111 mV 222 mV
 180 k ± 135 mV 270 mV
 150 k ± 161 mV 322 mV
 120 k ± 200 mV 400 mV
 100 k ± 238 mV 476 mV
Hysteresis Voltage Vs. R4 Value

The above is based on a couple of assumptions.  With light loading, most opamps can usually get to within about 1V of the supplies, so the table is based on a total opamp output swing of 10V.  The amount of hysteresis is reduced if the opamp's output swing is less than the 10V assumed here - it varies with opamps, so a definitive figure isn't possible.  The above is intended as a guide only.  The amount of hysteresis you actually need is determined by the likelihood of small fluctuations at or around the threshold voltage.  No switching system should ever be used without hysteresis, because there will be a point where the relay chatters.  This is a condition where the contacts are making and breaking rapidly - usually at 50 or 60Hz due to mains noise pickup.  Set the value of R4 so that you do not experience any relay chatter under normal operating conditions.  The relay should operate with a single click, both opening and closing.

Noise pickup is usually electrical noise (including spikes and other noises) picked up by the cable, and includes power supply noise, etc.  Noise can also include minor variations from the sensor itself as it passes through the critical region.  In general, lower hysteresis means more accurate switching but greater susceptibility to noise of all kinds.  It is possible to make the hysteresis asymmetrical by using two resistors instead of R4, and connecting each via a diode (with the two diodes facing in opposite directions).  Feel free to experiment, but this will not be covered here.  The reference is nominally 6V (voltage divider R2 and R3), but it is pulled either slightly higher or lower by R4.  The above table gives you an idea of just how much the reference voltage will change.

VR1 is adjusted so the input voltage is about 6V at the desired trigger level of light or temperature (or whatever).  With the values shown, it's expected that the sensor will have a resistance of about 60k at the transition point.  This is adjustable over a wide range though, and the system is easily scaled to suit different sensors.  C2 is used to filter noise from the input signal.

For example, a 10k NTC (negative temperature coefficient) thermistor can be used as a sensor, but you'll need to reduce the values of both R1 and VR1 to suit.  I would suggest that R1 be reduced to 2.2k and VR1 changed to 22k.  This is suited to a wide temperature range, although some experimentation is often needed in practice.


Sound Activation

A somewhat less common requirement is a sound activated switch.  For anyone who wishes to experiment with this, the circuit is shown below.  Using a single opamp removes the ability to include hysteresis, so sound at a level just below that needed for activation is likely to cause some relay chatter, depending on the predominant sound frequency.  Note that the output switch is a Darlington.  With a single transistor you won't be able to get enough current from the rectifier to switch a relay.

Figure 3
Figure 3 - Sound Activated Switch

It's actually more likely that this circuit would be used without the relay.  One (fairly) common application for a sound activated switch is to trigger a camera when an 'event' occurs.  An example might be a balloon bursting, and the camera will capture the action - provided it has low enough shutter-lag of course.  Many modern digital cameras insist on having a think about what they should do when the 'shutter' button is pressed, so the event may have passed by the time the camera gets its act together.  With the values shown and a 50mV input signal, activation time is about 1.2ms.

It's unlikely that too many people will be interested in this version, but it's easy enough to build and someone, somewhere, will look at this and say "that's just what I need!".  Or not.  Because it's a natural extension to the light activated version it was worth including.  The timeout period can be extended by increasing the value of C5.  If it's increased too far, that will increase the activation time - you will need to experiment to get the results you need.


Output Wiring

The relay contacts can be used for a wide variety of applications, ranging from turning on security lights at dusk to incubating bird's eggs.  Extreme care is needed if the contacts are connected to the mains, and I must provide this ...

WARNING
This circuit requires experience with mains wiring.  Do not attempt construction unless experienced and capable.  Death or serious injury may result from incorrect wiring.  It may be illegal in some jurisdictions to perform mains wiring unless suitably qualified.

You have the choice of both normally open and normally closed contacts, and either set can be used depending on your needs.  The most common tasks will use the common and normally open contacts to switch the mains on when the desired trigger point is reached.  This is shown in Figure 4.

Figure 4
Figure 4 - Mains Wiring Example

The above is intended as a guide only.  If you are suitably experienced you'll have no problems with the mains wiring, and if you don't understand the connections you should not be even considering building this project.  Any joins or other connections on mains wiring must be made using approved insulated connectors.  Please do not be tempted to use this (or any other home-built equipment) without the mains safety earth.


Construction

Apart from the mains wiring, there is nothing critical about the circuit, other than ensuring that all components are installed correctly, no reverse polarity, etc.  The circuit is easily built on Veroboard or similar.  Be very careful with the relay contacts if they will be switching mains voltages.  Veroboard does not have the necessary level of insulation for mains voltages, so you must either remove complete sections of track or mount the relay off the board.  I suggest the latter, as it's a lot safer.

When I built my unit (which is used to switch on path lighting at dusk and off at dawn), I built the switchmode supply into the case.  This saved having an extra lead for the DC, but did require secure mounting for the little supply board.  All internal wiring must be made to the standards that apply where you live, including the use of wiring with insulation designed for the mains voltage.

Note that the sensor lead should be shielded, with the shield connected either to the +12V supply (Figure 1) or ground (Figure 2).  This is very important, because an unshielded lead will pick up all sorts of noises, so you may need to have much more hysteresis than is desirable.

The sound activated version is also non-critical, but if the mic is remote from the circuit you must use a shielded cable or hum will trigger the circuit.


Testing

Connect the controller to your switchmode DC power supply.  When powering up for the first time, use a 100 ohm 'safety' resistor in series with the supply to limit the current if you have made a mistake in the wiring.  When the circuit activates, it will probably misbehave because of the safety resistor.  Once you are satisfied that everything is connected properly, remove the safety resistor and adjust the pot (VR1) until the relay activates and deactivates at the desired threshold.

If the relay chatters as it activates or deactivates (it will sound like a buzzer), you will need to reduce the value of R4 to get more hysteresis.  Make sure that your workshop lights aren't causing the problem first - fluorescent lights and fast LDRs can cause chattering where it will be perfectly alright if activated by sunlight (or the lack thereof).


 


HomeMain Index ProjectsProjects Index
Copyright Notice.This article, including but not limited to all text and diagrams, is the intellectual property of Rod Elliott, and is Copyright © 2010.  Reproduction or re-publication by any means whatsoever, whether electronic, mechanical or electro-mechanical, is strictly prohibited under International Copyright laws.  The author (Rod Elliott) grants the reader the right to use this information for personal use only, and further allows that one (1) copy may be made for reference while constructing the project.  Commercial use is prohibited without express written authorisation from Rod Elliott.
Page Created and Copyright © Rod Elliott 13 June 2010./ Oct 2018 - Added sound activated version.