I'm building a home automation system with raspberry pi and would like to trigger it with a regular pulse switch, connected to my home's 127V AC power network. I'm doing this so I don't need to rewire my power outlets.
I came up with a circuit like this. Do you guys think it would work?
Thanks!
Edit 1: Here's what I'm trying to achieve:
The switch is far away from the raspberry and the wiring is already in place, that's why I would like to use 127V.
Edit 2: deleted
Edit 3: new diagram:
-
\$\begingroup\$ Please, can you explain more? What I understand is that you want to interrupt rpi whenever pulse from "pulse switch" would cross trough 0 Volts. Am I correct? \$\endgroup\$Sanmveg saini– Sanmveg saini2020年08月13日 14:17:13 +00:00Commented Aug 13, 2020 at 14:17
-
\$\begingroup\$ You can attach it directly; you will for sure "trigger" it, at least once... (note: DON'T do it... the "at least once" part means it will blow up in a "not so nice" way) \$\endgroup\$frarugi87– frarugi872020年08月13日 14:17:19 +00:00Commented Aug 13, 2020 at 14:17
-
2\$\begingroup\$ Use an optocouple, for the love of god! \$\endgroup\$Janka– Janka2020年08月13日 14:50:53 +00:00Commented Aug 13, 2020 at 14:50
-
1\$\begingroup\$ The 50k resistor might easily flashover with a 6kV transient rated for 500V and get rather warm. \$\endgroup\$Tony Stewart EE since 1975– Tony Stewart EE since 19752020年08月13日 15:01:56 +00:00Commented Aug 13, 2020 at 15:01
-
1\$\begingroup\$ @Janka, thanks, updated with your suggestions. The problem of moving the GPIO to the collector is that this makes it 1 when the optocoupler is disabled. Also, I'm using different grounds for the left and right side, so I didn't join them. \$\endgroup\$Alexandre Giuseppe– Alexandre Giuseppe2020年08月14日 02:29:23 +00:00Commented Aug 14, 2020 at 2:29
1 Answer 1
Sometimes the people just use a 1M resistor in series with the power; personally I'd also add a small zener to reduce risks
schematic
simulate this circuit – Schematic created using CircuitLab
However, personally I don't like this. Remember that in this case the ground is tied to the neutral wire, and so the rPI is no more insulated. This is usually a thing I want to avoid with microcontrollers, and much more with a complex system like a rPI which gets attached to a lot of other stuff.
For this reason I highly suggest you to avoid this, and use a proper optocoupler. For instance I have used in the past cheap optocouplers (PC817) to sense the presence of the 230V signal. I suggest you to search for circuits with optocouplers (in my case, I used the optocoupler, a diode to block reverse wave, and 100k resistor(s) to limit the current (in your case you may reduce the value of the resistors). This way high voltage and low voltages are properly separated.
My (slightly different) circuit is in this other question, but there are plenty of them. Note: you will have a 50Hz wave there, so you shall filter it either in SW or in HW
-
\$\begingroup\$ The above circuit is not safe in the event of a failure or arcing, make sure you use an optocoupler for saftey. \$\endgroup\$2020年08月13日 16:55:41 +00:00Commented Aug 13, 2020 at 16:55
-
\$\begingroup\$ Can you please provide some input on my optocouple design? Thanks. \$\endgroup\$Alexandre Giuseppe– Alexandre Giuseppe2020年08月13日 19:51:54 +00:00Commented Aug 13, 2020 at 19:51
-
\$\begingroup\$ Yes :) See also my question and some answers here: raspberrypi.stackexchange.com/questions/31648/… \$\endgroup\$tomnexus– tomnexus2020年08月14日 05:54:09 +00:00Commented Aug 14, 2020 at 5:54