 # Simple 230V monitoring using PC817 opto coupler

11 Oct 2022 - tsp
Last update 11 Oct 2022 3 mins

## Warning So first off this is an article that requires an extensive warning:

• The circuit described in this article are operating from line power. Even though this being the safer side of these projects working with line power equipment can result in deadly shock. Be sure to disconnect everything before working with line voltages.
• Only do such stuff when you know what you are doing - working with line voltages is not a beginners project even if it looks simple.
• Make sure you know your local regulations. In most countries one is not permitted of operating custom built line powered equipment on the public power network.
• Make sure you know how building such equipment effects your insurances.

## The schematic

Sometimes one needs to monitor the 230V line that equipment is attached to. For example when ones experiment is running on an USV that offers no useful interface (neither via serial port nor via Ethernet) but one wants to gracefully shut down equipment in case a longer power outage happens (and the USV will most likely run out of capacity earlier or later). To do this one can use a really simple circuit built out of an cheap opto coupler, a diode and some $\frac{1}{4} W$ resistors.

The most simple circuit that one can build consists exactly of that: Keep in mind that the 230V are effective voltage so the peak voltage is around $230V * \sqrt{2} \approx 325V$. This means that the current flowing over a $235 k\Omega$ resistor would be around $1.38 mA$. This doesn’t sound much but converted into power $P = U*I = 325 V * 0.00138 A \approx 0.4485 W$. This is too much for most quarter Watt resistors one has lying in ones drawer usually. This is the reason for the two $470 k\Omega$ resistors in parallel - so they would be perfectly capable of up to $0.5 W$ peak.

Since the forward voltage of the PC817 opto coupler is 1.25V the voltage dropping over the two resistors can be estimated to be around 325V. Note that this is not a hard limit - the line voltage drifts up and down so the voltage might be a few tens of volts higher or lower at any time. The forward current at 325V would be at most $1.4 mA$ which is sufficient to be detected on the secondary side.

The PCB that this prototype has been built has been cut clear below the opto coupler and the two 230V lines are spaced for at least $2.5 mm$ without any copper in between them.

The diode is necessary to prevent the 230VAC being active across the opto couplers terminals - the maximum reverse voltage allowed is $6 V$. Since the diode conducts whenever the opto coupler does not the voltage over the opto coupler is also limited to the forward voltage of the diode - in case of the 1N5364BG used in this circuit (that’s a Zener diode but in this case used as ordinary diode in forward configuration) that would be $1.2 V$ thus way below the $6 V$ allowed by the opto coupler.

As one can see supplying the circuit with $5 V$ and recording the waveform using an oscilloscope one can recover the half-wave of the 230V signal: 