0
\$\begingroup\$

How to isolate the following circuit from mains or safely send a 5V signal from RPi to turn the relay on? I currently have a 5V signal going into the IN pin of the relay board and RPi ground to the GND pin of the relay board and it works. Is it safe even if I remove the 1.2V battery. I’m not very experienced with 220V AC.

enter image description hereenter image description here

\$\endgroup\$
  • 3
    \$\begingroup\$ You must treat all of that circuit as live as there is no mains isolation. You should not connect your micro-controller directly to that circuit. \$\endgroup\$ – Transistor Nov 29 '18 at 9:00
1
\$\begingroup\$

The relay's coil and the switch already provide proper mains isolation. However you power the relay via a non isolated supply. It is a "capacitive dropper" circuit which is not isolated. Connect it to your RPi and your RPi will then become mains live.

If you want to keep the powering of the relay the same (i.e. non isolated) you will need to either use another relay (there are relay modules for RPi) or an optical isolation module. Then that module will provide the isolation. The circuit that you show does not provide any mains isolation. The reason that the relay is there is to switch a large current, not to provide any isolation.

I’m not very experienced with 220V AC. Then educate yourself on the subject before messing with circuits at mains voltage. Even seasoned professionals treat mains voltage with respect and so should you.

\$\endgroup\$
  • \$\begingroup\$ What’s a good learning source to educate myself with electronics? \$\endgroup\$ – nodejs_ios Nov 29 '18 at 9:48
0
\$\begingroup\$

The circuit is live from mains voltage and the RPi is not isolated from it so don't touch it or anything connected to RPi! Get an opto-isolator between RPi and the relay circuit so there will be isolation between the circuits and RPi is safe to touch.

\$\endgroup\$
  • \$\begingroup\$ Is it safe to plug RPi into the wall? I tested the RPi running of a power bank. \$\endgroup\$ – nodejs_ios Nov 29 '18 at 9:04
  • \$\begingroup\$ No it is not safe, we're not taking about safety of the RPi, we're talking about safety of you, the user. If you connect your RPi directly to the circuit above you have a high chance of receiving a electric shock. It is dangerous, so just don't do this. \$\endgroup\$ – Bimpelrekkie Nov 29 '18 at 9:08
0
\$\begingroup\$

Other answers tell you why your current design is dangerous, this will answer how to do this safely.

You should get relay (board) that is capable of switching mains, but can be triggered with 3.3 V. This relay will then provide enough isolation between mains and your RPi.

PS, this kind of relay boards are popular and can be found on all of mayor distributors websites.

\$\endgroup\$
  • \$\begingroup\$ can i use a CNY65 - optocoupler to isolate the RPi? \$\endgroup\$ – nodejs_ios Nov 29 '18 at 12:01
  • \$\begingroup\$ You cannot use CNY65 directly on mains, but you could use it to replace transistor to control existing relay, depending on its voltage and current rating. In that case your RPi would be isolated, but relay and surounding components would not. \$\endgroup\$ – Rokta Nov 29 '18 at 12:20

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.