I have a desk lamp that doesn't have a switch because it was custom made. I discovered that it is bright enough to light the whole room. I figured I'd solve the switch problem by designing a circuit that would allow me to turn it on and off from two locations: my bedside table and my desk (my room is very small).

I'd position the circuit somewhere along the power cable. My power board has a spare built-in USB port so I figured it'd make sense to power a relay from that. The lamp is a 7.5 W, 240 VAC globe. The circuit I came up with is as follows:


simulate this circuit – Schematic created using CircuitLab

Because I'm a still a novice electrical engineer, I have a few technical questions:

  1. Does it matter which AC wire I put the relay on? Could I just pick any wire and put the circuit in the middle of that?
  2. What am I looking for in a relay that could pull this job off? Suggestions welcome.
  3. From my very basic knowledge of electronics, I know you can't just put a solenoid in a circuit without something to take the load - hence the existence of R1. What would be a good value for R1? My guess is that if it's too low, the relay would get hot, and if it's too high, the relay wouldn't work.

If you see issues with this circuit or have better design ideas, be sure to leave a comment.

  • \$\begingroup\$ There are 5V relays. Pick the correct relay and power source, then there is no need for R1. All relays have specifications. Pick one with contact ratings in excess of the voltage and current demanded by the lamp. There are easier COTS approaches you should consider. They might be safer then messing around with 110 to 220 volts on your first go with electronics. \$\endgroup\$
    – st2000
    May 9, 2017 at 12:07

3 Answers 3


What you're trying to do is fine. But consider using an AC-load Solid-State Relay (SSR) instead. They will draw little load current from your 5 V to power and have no moving contacts to arc.

You can find plenty about them on the interweb. But in short, they come in DC-load and AC-load versions and the later is a convenient little package containing a triac to switch the mains and controlled by an opto-isolator. You put a control voltage into the SSR, the internal IRLED lights up, the triac's turned on and your AC conducts. You can get zero-crossing versions, whereby the output is only turned on or off when the AC mains voltage crosses zero, avoiding the spike of current of a load switched on/off as the mains wave is high.

You'd want a device for a 264 V (240 V + 10%) or higher load voltage at 1 A or higher. Fuse the supply for the current rating of your SSR. You can get SSRs in little 8-pin packages up to inch-or-two potted through-hole packages or huge ones with screw terminals, with the cost rocketing as you go. Avoid the DIL ones, the pin gap's not good enough for my liking or your home assembly. Go for a device in a larger package, something like the Panasonic AQG22105J.

Incidentally, I have yet to see one of these larger devices that needs a series resistor on its control voltage input - they just take the control voltage. But that's not much use if it does, so if you pick a different device to the AQG22105J, check that on the datasheet like everything else.

Answering your other questions:

(1) The switch should break the LIVE wire, not NEUTRAL, so that a switched off lamp has no power going to it.

(2) Look at SSRs, as above.

(3) Most likely don't need R if you use an SSR but check its datasheet. Otherwise just your switches and USB-derived 5 V power on the 5 V side.

  • \$\begingroup\$ Qualification needed "Don't need R if you use an SSR" - If it is rated for 5V operation. \$\endgroup\$
    – Trevor_G
    May 9, 2017 at 13:43
  • \$\begingroup\$ Hi @Trevor, I disagree. SSR has a variety of selection criteria and a 5 V-capable input is no more important than the others. SSRs don't need input resistors and 3..24 V is a common input capability range. Example part has a 5 V input. R shouldn't have been in there with coil relay either, answer says ditch it. \$\endgroup\$
    – TonyM
    May 9, 2017 at 13:59
  • \$\begingroup\$ Yes indeed, but some of them are simply an LED on the input side, so he would need a resistor with those. Just mentioning it for completeness since the OP is obviously a novice. \$\endgroup\$
    – Trevor_G
    May 9, 2017 at 14:05
  • 1
    \$\begingroup\$ @Trevor, I sucked in breath to argue...then thought the ease of going with your point and revised the answer :-) \$\endgroup\$
    – TonyM
    May 9, 2017 at 14:43
  • \$\begingroup\$ An SSR is fine for this application (though for some reason the triac's asymmetric MT1/MT2 construction ever seems to annoy me), but the OP should know that they are no panacea. For my 40 A stove situation, an SSR meant almost 100 W dissipation. I used a hybrid relay + dual SCR arrangement that uses 2 W total when active and stays cool. Low dissipation meant lots less volume required and more freedom about its location. Relays do have their place. \$\endgroup\$
    – jonk
    May 9, 2017 at 15:23

The SSR is an unnecessary replacement for this. Your original idea for a relay is sufficient. 5V DC, 10A/120 5A/220 AC relays are a dime a dozen. These relays work right off 5V so do not need a current limiting resistor. They use 100mA or less so perfect for a spare usb supply. Your SPDT switch for a two switch control would work fine, and is how residential switches are wired. The load is only 35 mA at 240V (0.035 * 240 = 7.5W) so a 5 Amp relay is perfect.

The only change to the circuit is that you want a flyback diode across the relay coil pins. This is to protect the circuit from the collapsing inductance field when you turn the coil off.

As to which wire you would cut, it should be the live or polarized wire. This may be different in 240V wiring. You can make it simpler by using a DP relay. Each wire will be cut, and will switch together, so when off, both wires are interrupted.

  • \$\begingroup\$ The DP relay is a smart idea! Good idea, thanks for your help. Can you clarify why there's no resistor needed? I'm just curious. \$\endgroup\$
    – ezra_vdj
    May 9, 2017 at 21:00
  • \$\begingroup\$ @Ezra because the coil has it's own resistance (or inductance) and will pull the current it needs at a given voltage. Unlike an led which is like an short circuit, a relay coil does not need a ballast resistor to set your needed current. \$\endgroup\$
    – Passerby
    May 9, 2017 at 21:05

If the relay coil voltage rating is same as the supply voltage, then there is no need of R. If you want to add an LED then it may be required have a value (ohms) of (supply voltage - coil voltage)/circuit current.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.