I'm planning to add some home automation to my home, using a 5V relay and most likely an ESP8266.

This will be used, for instance, to control the lights or the heaters, certainly through Home Assistant. I have experimented a lot with 5V DIYs, but this will be the first time that I will touch to 220V (domestic voltage in France.)

I read a lot of tutorials before even thinking of reproducing this, as I have very little knowledge of electronics. For instance, I'm considering a circuit like this one. (source [fr]).

However, most DIY tutorials do not dare to address all the possible security issues. Some are just mentioning "be cautious for fire hazard due to high voltage", but nothing more specific.

In such a relatively small project, what is the worst that can happen and what should be done to prevent it?

Any source of noob-friendly documentation would be very welcome.


Reading the comments, I could refine my search keywords and find some resources.

For instance, you could consider this circuitbasics tutorial (and especially the comments). It certainly doesn't seem to require an electrician but it would be very interesting to be proved wrong here. If they actually teach something wrong I think it is essential to notify it.

Electrical experts should really be aware that DIY is a thing and that telling people to seek qualified persons instead of teaching themselves is useless: they will do it anyway.

However, teaching what should be done in the right context might make some aware that they cannot do all the required things. In this case, they will stop by themselves and ask a qualified person.


I live in a concrete building, as there are almost no more homes made of wood in France, especially in big cities like the one I live in (unlike in the USA I think). This might be important to consider regarding the fire hazard.

  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$
    – Voltage Spike
    Nov 24 '20 at 19:02

What should be done to prevent danger and what are the risks?

  • fire, usually caused by a short circuit, have a fuse, check all connections are secure, don't connect the mains to the 5v circuit. Check the relays are rated for the correct current, take into account inductive loads such as motors, transformers, power supplies etc.
  • electrocution, don't have any exposed connections that are live or neutral, if you can touch it and it is metal it shouldn't be live or neutral and should be earthed.
  • earth leakage tripping RCD or GFCI, don't have any path between live and earth or neutral and earth.

Always use the relay to switch the live side of the circuit, and as you are in france where they have some non-polarised connectors, only use plugs with earth sockets in to ensure that the live (switched side) is always connected to the same pin and isn't connected to neutral.

  • \$\begingroup\$ If you are not confident: don't test the circuit around anything flammable, don't touch the circuit at all, not even the low-voltage part, unless it's in a nice non-conductive plastic box. \$\endgroup\$
    – user253751
    Nov 24 '20 at 18:46

In addition to what MParks said, I would add:

If there is a metal box, ground it. So that a loose wire inside the box cannot cause the box to become live.

Also try to keep some minimum distance between the high voltage and low voltage parts of the circuit, usually it's something like 5mm. This is so that some moisture, or a fleck of metal won't energize the "safe" part of the circuit with high voltage.


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.