0
\$\begingroup\$

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?

enter image description here

Thanks!

Edit 1: Here's what I'm trying to achieve:

enter image description here

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:

enter image description here

asked Aug 13, 2020 at 14:11
\$\endgroup\$
20
  • \$\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\$ Commented 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\$ Commented Aug 13, 2020 at 14:17
  • 2
    \$\begingroup\$ Use an optocouple, for the love of god! \$\endgroup\$ Commented 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\$ Commented 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\$ Commented Aug 14, 2020 at 2:29

1 Answer 1

4
\$\begingroup\$

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

answered Aug 13, 2020 at 15:40
\$\endgroup\$
3
  • \$\begingroup\$ The above circuit is not safe in the event of a failure or arcing, make sure you use an optocoupler for saftey. \$\endgroup\$ Commented Aug 13, 2020 at 16:55
  • \$\begingroup\$ Can you please provide some input on my optocouple design? Thanks. \$\endgroup\$ Commented Aug 13, 2020 at 19:51
  • \$\begingroup\$ Yes :) See also my question and some answers here: raspberrypi.stackexchange.com/questions/31648/… \$\endgroup\$ Commented Aug 14, 2020 at 5:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.