# How to measure line voltage (220V) with an arduino?

I'm a Electrical Engineering student and I want to sense and sample the voltage signal coming from a wall socket (110V - 220V). I came up with the following circuit using a voltage divider with high impedance and a diferential amplifier. I would like to avoid using a transformer because of weight constraints.

Is there a better way to solve this problem? Should I use a capacitor divider instead?

• Are you aware that the wall socket provides AC rather than DC? – Eugene Sh. Sep 22 '17 at 16:36
• Because your circuit is going to get crazy when fed with AC. – Eugene Sh. Sep 22 '17 at 16:41
• What you've designed here is what's known as a death trap (technical term). Amongst other problems if your GND ever connects to mains earth (e.g. PC USB port), you've just potentially shorted the live (or neutral) terminals to earth via your op-amp. – Tom Carpenter Sep 22 '17 at 16:47
• pin 5 is connected directly to the Live or Neutral. – HandyHowie Sep 22 '17 at 16:49
• @GabrielGóesRodrigues If you want to avoid a transformer, then use opto isolation. I could provide a circuit for you to consider, there. Others can provide ones, as well, I'm sure. – jonk Sep 22 '17 at 16:50

Regular transformers don't have to be heavy.

Figure 1. Miniature transformers.

Hammond Manufacturing, for example, make 0.5 VA transformers smaller than a 25 mm / 1" cube. This provides isolation from mains (which your circuit does not).

simulate this circuit – Schematic created using CircuitLab

To read AC with your micro you'll need to bias the transformer to mid-DC supply as shown. R1, R2 and C2 provide this function.

R3 and R4 provide a potential divider to attenuate the transformer signal into the range suitable for your ADC.

• There are audio transformers on Mouser that go down to 9.5 x 9.5mm footprints. – Bryan Boettcher Sep 22 '17 at 20:24
• They're unlikely to have mains isolation rating. OP would need > 1 kV for safety. – Transistor Sep 22 '17 at 20:31
• They were 2kv rated :) – Bryan Boettcher Sep 22 '17 at 20:56
• @BryanBoettcher An audio transformer may well be useable but will need careful thought as well as probable input interfacing to make it suitable for 50/60 Hz connection at 110/240V. The core will saturate already at low signals (at mains frequency) and the turns ratio is often 1:1 which would not offer voltage scaling benefits. – KalleMP Sep 22 '17 at 22:10

I would like to avoid using a transformer because of weight constraints.

Transformers don't have to be big. Consider being clever and using a really really small transformer that both supplies control signals and power as well as receiving digital data back from an ADC: -

You have an AD7793 ADC on the left that is isolated from your MCU interface on the right. The isolation chip provides power from the MCU's supply as well as permitting a combination of digital IO.

You'll still need to reduce the voltage going into the ADC to a suitable level (using a resistor or capacitive dropper) of course but now you've solved the weight issue without creating the problem of connecting potentially a live circuit to your local MCU ground.

• Subtle but likely an expensive solution. – KalleMP Sep 22 '17 at 22:06
• What is the magic they do on usb wall adapters? Those bastards don't use transformers and are just fine. – Gabriel Góes Rodrigues Sep 23 '17 at 1:39
• @GabrielGóesRodrigues Check electronics.stackexchange.com/q/31018/73121 – Marc.2377 Sep 23 '17 at 1:55
• @GabrielGóesRodrigues they do use transformers but, because they rectify the ac they can convert power across a tiny transformer using a high frequency switching circuit. Transformer size is fundamentally governed by operating frequency for a given power throughput. Higher frequency = smaller size and a common switching circuits will operate at 100 kHz - that's 2000 times higher than 50 Hz. – Andy aka Sep 23 '17 at 7:38
• @Marc.2377 Thanks that's really helpful – Gabriel Góes Rodrigues Sep 24 '17 at 17:33

You can get away with either of the two circuits, one not isolated, one with transformer isolation.

Additionally, in the non-isolated version, use R1 and R2 large resistors, with proper voltage rating (not 0603 size), or even several resistors in series. You can also replace R1 and R2 with high voltage capacitors, calculated to have about 1M5 impedance at 50 or 60 Hertz. 220V rms is about 314 V p-p, scaled down by a factor of 150, you will see about 2V p-p between your op amp inputs. For the isolated one, any cheap telecom transformer from DigiKey would do - they typically have isolation voltage of at least 1500V

How about using an unregulated AC wall wart? That way you will be isolated from the mains and 12v AC or so is friendlier and safer to measure. Cheap as well..