0
\$\begingroup\$

I am trying to turn on and off a lamp I have at home using a relay controlled by my Raspberry Pi. Here are the exact parts I will be using:

Raspberry Pi B+ enter image description here

My lamp:

enter image description here enter image description here

My relays:

enter image description here

Potential outlets I would be using (mains):

enter image description here

OR:

enter image description here

With all the equipment being listed, my procedure would be:

Peel off the lamp cable and connect the lamp's power supply to the relay so whenever the Pi closes the circuit, the lamp is powered on.

I am aware that there are risks implied when tampering with the "mains" voltage. With that being said, I would like to ask the following questions:

  1. Will it be dangerous to do this with the hardware listed above? Please know that I would place the relay on a surface that does not conduct electricity (potentially wood), and the though of touching any hardware (not even the PI) while the lamp is connected WOULD NOT EVEN POP IN MY HEAD.

  2. I am aware that the relay may fail since I've read in some forums that this is supposedly a 5V relay (maybe not?). If it were to fail, would it be dangerous? As in, would my whole house be in a blackout or something like that? Any advice for that?

3.If you were to consider this safe, would it make a difference if I cut/tamper with the wire before or after the manual switch my lamp has? (please refer to the switch image above).

  1. How would I be able to identify which wire is positive and which negative if I cut open my lamp's cable?

  2. Would it make a difference to connect the lamp to the black extension cord (please refer to the picture above) rather than directly to the mains outlet?

I am still debating whether to give this a try or not due to security reasons. I am aware of how dangerous tampering with house-level voltage (especially current) is, therefore I need your help to better analyze the situation.

Thank you so much for your help!

QUICK EDIT:

FYI, I currently live in America, therefore I am assuming my mains V supply is 120V...

\$\endgroup\$
  • 1
    \$\begingroup\$ There is a lots of questions in one here; generally single questions are better received on this site. I personally would say that because it is a safety thing you should rather learn the underlying principles to be able to answer the questions yourself than to get an answer to these questions. \$\endgroup\$ – PlasmaHH Dec 22 '15 at 10:44
  • \$\begingroup\$ Well I could guess how you might wire these up but it's best if you show a scheme. \$\endgroup\$ – Andy aka Dec 22 '15 at 11:23
1
\$\begingroup\$

Here is a good way to do this project without getting yourself messed up with playing with live mains wiring.

  1. Acquire one of the many AC remote controlled outlet devices such as that pictured below. There are plenty of choices available for low prices on eBay or Amazon. Can be lower than price of the Raspberry Pi.

enter image description here

  1. Plug the AC unit into your mains outlet and then plug your unmodified lamp into the front of the AC unit.

  2. The wireless remote FOB contains a battery operated transmitter circuit that can be hacked to let the RasPi trigger the lamp on and off. The nature of the hack interface will be a far better learning experience for you than risking life and limb screwing around with your own relay controlled AC wiring.

  3. The simplest hack for the FOB will be to simply bring two small wires out of the FOB that connect to the active contacts of the push button and wire those over to your relay module. Everything is low voltage and safe.

Note that these low cost remote control units may not be of the highest quality but their usage will still be safer than what you have proposed in your posting.

\$\endgroup\$
  • \$\begingroup\$ For extra points, the wireless fob could be modified to take its power from the Pi, eliminating the need for a battery. \$\endgroup\$ – JRE Dec 22 '15 at 11:28
  • \$\begingroup\$ @JRE - That is certainly possible and would make the learning experience even more valuable. Note that some of these FOBs use a small single cell 12V battery and to replace that would require the presence of a 12V supply in the RasPi setup. This may not always be the case in the world where many things are powered by 5V from USB type charger adapters. \$\endgroup\$ – Michael Karas Dec 22 '15 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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