Simple 230V monitoring using PC817 opto coupler

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


Warning sign

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

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:

Simple 230V line monitor circuit

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:

Oscilloscope output

This article is tagged: Tutorial, DIY, Electronics, Physics, Basics, Measurement

Data protection policy

Dipl.-Ing. Thomas Spielauer, Wien (

This webpage is also available via TOR at http://rh6v563nt2dnxd5h2vhhqkudmyvjaevgiv77c62xflas52d5omtkxuid.onion/

Valid HTML 4.01 Strict Powered by FreeBSD IPv6 support