0
\$\begingroup\$

I bought a cheap Chinese inverter with no serial number, I thought it be a fun little home project to check if the AC voltage it provides is a true sine wave.

I tried using an arduino with a breadboard circuit to do so:

enter image description here

Above you can see my circuit, it takes the AC voltage (230V 60Hz), steps it down using a voltage devider, from there i rectify the signal to assure only voltages between 0 and 3.3V will be applied to the MCU's ADC pin. The plot shows the voltage at the ADC pin relative to the MCU ground.

From there I log the readings over serial to my computer to later plot it and then to compare it to the signal provided by mains power.

So when I set everything up and checked the voltage levels over R2 and R1 using a multimeter, I saw everything was correct, but once I connected my MCU and turned on the power, my arduino blew up and damaged my computer's usb port.

What caused the short to happen, my only guess is that it has something to do with the fact that my USB port's ground is also connected to the MCU's ground and some ground loop effect took place that caused this?

\$\endgroup\$

3 Answers 3

2
\$\begingroup\$

Never mess with trying to measure mains voltage with a grounded device. It likely will lead to damage or injury, as you found. One way to measure such a voltage is to use a small transformer (e.g. filament type) that will isolate it and reduce it to a safe voltage. You likely will carefully have to do a simple calibration with an isolated voltmeter to determine the exact ratio between the input and output voltages of the transformer.

Another way is to use a differential amp with a high resistance (at least 100k at both terminals to ground) to measure the AC. -----Below is the LTspice sim of an example circuit to do that:

Its ground current is limited to <0.5mA.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

You cannot rely on which wire is neutral and which is live. Unless you determined which is which, and there is a neutral, so that it's not two live wires.

Also, if the inverter neutral is referenced to same earth as your computer, when the live will go negative, it effectively shorts negative 325V via diode to earth via your computer.

Now, good thing is it only blew up the MCU and one USB port of the computer, and you are not electrocuted. Please be careful with mains voltages.

In reality, you should have used transformer isolaation, e.g. by converting mains to e.g. isolated 12VAC and then resistor divide and connect one of the wires to computer ground.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks @Justme, just to clarify, when it blew up it was not connected to the inverter but to the mains power from a wall plug. I made sure I used the live and neutral wires from the plug and left the earth disconnected. I also anticipated the worst and kept myself a safe distance from everything that could shock me. But why would it matter (Besides for safety reasons) if you switched neutral and live because the current flows in both directions, meaning from the perspective of the MCU its all the same? \$\endgroup\$ Commented Nov 9, 2024 at 16:29
  • \$\begingroup\$ @RikusCoetzee Okay connecting plug to mains was important info you should not have left out. Same rules apply. Neutral and Earth are at same potential, tied together somewhere in your house maybe, and that's 0V reference. Live will wiggle between +325V and -325V in reference to 0V. Your computer is earthed so it has ground at 0V earth potential. If you plug in your mains socket so that live and neutral are swapped (e.g. europlug or schuko), you might have wired live through diode D3 to computer ground and earth, blowing up diode and fuse/breaker, and computer port. \$\endgroup\$ Commented Nov 9, 2024 at 16:34
  • \$\begingroup\$ That makes allot of sense, so to make such a measurement system viable, it should be completely isolated from the earth, for instance, looking at my system, if I used a laptop only running on battery power it might have worked? P.S. I don't plan on trying this ever again so don't worry about me electrocuting myself ;) \$\endgroup\$ Commented Nov 9, 2024 at 16:45
  • \$\begingroup\$ @RikusCoetzee Yes, if you had used a battery-powered laptop, nothing likely would have exploded. But any exposed metal part on your Arduino and laptop, including metallic arm rest, would have had diode-rectified pulsating -325V waiting to electrocute someone. That's why we use the Earth wire for safety, to rather blow up Arduinos, fuses, and computer ports, instead of having to organize funerals. IMO, it's weird ungrounded laptop power supplies exist at all. \$\endgroup\$ Commented Nov 9, 2024 at 16:52
0
\$\begingroup\$

As other said your problem is lack of isolation.

One of the easiest way is to use voltage divider and isolated amplifier. One of such amplifiers is AMC1350 which will also center your voltage around half of supply voltage. Drawback is that you need isolated power supply for it.

Make sure that resistors in voltage divider can withstand full AC voltage.

\$\endgroup\$
2
  • \$\begingroup\$ You are the only one here implicitly pointing out that a standard resistor can not withstand the main voltage… \$\endgroup\$ Commented Nov 9, 2024 at 23:07
  • \$\begingroup\$ Yes, good point. the 200kΩ resistors in my circuit should be three, 165kΩ, 1/4W resistors in series to withstand the peak voltage from the mains. \$\endgroup\$ Commented Nov 10, 2024 at 1:39

Your Answer

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.