An alternative method of measuring the mains voltage waveform for a PV controller

This method of monitoring mains voltage that is safe, accurate and does not require a transformer. It breaks two “rules”.

The first rule to be broken is not to connect directly to the mains. However, we have to “invade” the mains anyway to make a controller, so I thought another instance would be ok as long as it can be done safely – which it can, provided all necessary precautions are taken.

The second rule to be broken is not to conduct any current from the mains to the earth. I did some internet research and found that this is, in fact, both acceptable and commonplace. More justification for this is given below.

Using this circuit, the Arduino is close to earth potential and is safe to touch. It can be connected to a computer, for power and monitoring, or the system can be powered using a mains usb charger adapter.

The system is safe only if the mains earth connection is good – but the same applies to a washing machine and a microwave.

The circuit measures the difference in voltage between the live and neutral. Any voltage between neutral and earth is filtered out.

The circuit provides input protection - the inputs to the opamp and the ADC remain within limits (i.e. the rails) even if 1000V spikes appear on the mains (either live or neutral).

Here are the circuit elements. The first is a 2.5V rail as used elsewhere.

The components inside the dotted line should be mounted on a separate board (see below).


In order to make the circuit safe, the following precautions must be observed.

  • Do not attempt this unless you are confident you know what you are doing.

  • Do not put mains voltage on the same board as the 5V circuitry.

  • Stripboard is not suitable for mains voltage

  • Construct a separate “mains voltage sender” board comprising the four resistors inside the dotted line.

  • Connect the mains inputs directly to the 1MΩ resistors, and insulate the joint with heatshrink sleeving. This renders the rest of the circuit safe to touch, provided the earth is connected.

  • Before connecting to the mains, do a continuity check from the mains earth to the circuit earth.

  • Before connecting to the mains, measure the resistances with a meter to confirm that the circuit is correct.

  • After connecting to the mains for the first time, carry out checks with a mains tester to ensure that no dangerous voltages are present.

The photo below shows the mains voltage sender ready for connection to the breadboard