Please, excuse me if this question is ill-suited here. I am new and in need of guidance.

I am studying Internet-of-things and I'm keen on starting a first project.

The tutorial I'm planning to follow controls a lamp from a raspberry pi by cutting the power cord in half and reconnecting both halved of the power cord with a relay module.

For a newbie like myself, I'm nervous about plugging the cable into the mains for testing.

Can anyone advice how to carry out this experiment safely? Will a Surge Protector help avoid fire etc?

  • 3
    If you are nervous about this, I only have one piece of advice: Do another project. Making mistakes with simple 3V3/5V DC circuits is no big deal, the worst you can do is fry your Pi. Making a mistake with 110V/220V AC can lead to much bigger problems, such as electrocution, fires and other damage to your house. I'd recommend you do a lot of reading up on the topic before attempting a project using outlet power.
    – Phil B.
    Jan 18, 2016 at 16:46
  • Yea definalty. Maybe try and find a local hackathon or somebody that may be able to teach you something, with practise. You also need to understand electricity allot better to know when you may create a fire hazard and how to avoid it.
    – Piotr Kula
    Jan 18, 2016 at 17:04
  • I'm closing this as a duplicate. If you feel your question is not addressed over there, point that out and call for a reopen. The advice given by PhilB and ppumkin should be considered nonetheless!
    – Ghanima
    Jan 18, 2016 at 19:43
  • You could achieve the same goal with far less risk (if slightly higher cost). You could use a remote controlled outlet such as these amazon.com/Useful-UH-RP159-Controlled-Electrical-Wireless/dp/… and not have to deal with mains current (note these are for the american market and run at 110V but you should be able to find something similar in your country). Jan 18, 2016 at 20:04
  • Then instead of switching the relay you could either hack the remote to be switched by your Pi, or add a transmitter (usually these operate at 433MHz for which transmitters are cheap) to your Pi and send the proper code to the socket from your Pi. Jan 18, 2016 at 20:04


Browse other questions tagged or ask your own question.