I am building a tester which will measure power consumption of multiple devices (up to 6) at a time. These devices operate at 220VAC and range from 3W to 10W. I initially decided to measure current using ACS712 but had to abandon it because the current I need to measure ranges from 13mA to 45mA which is way below what ACS712 can measure and distinguish between.
Hence I decided to connect a small shunt resistor (1W) between the supply (220VAC) and my LED light. I then pass this potential difference across the shunt through a bridge rectifier and through a suitable potential divider so as to keep the output voltage below 5V level of the Arduino. This rectified DC is being fed into the Analog Port of the Arduino Mega.
All is well here and I get exact values of voltage from the Arduino and then I calculate the Power. The problem starts when I start charging my laptop to which the Arduino is connected. The moment I connect the charger to the AC mains, it starts behaving very strangely.
Without the laptop being charged, in a particular case, my NO LOAD voltage after the bridge fed into the analog port is approx. 0.3V and ON LOAD it is approx. 1.8V which matches the voltage as measured by a multimeter and also as per calculations. However, as soon as I connect the laptop charger to mains, the output goes to 5V irrespective of whether the load is connected or not.
I brought the setup home and tried there. Now at NO LOAD the Arduino's output is 2.5V. Hence any load whose output at the Arduino should be less than 2.5 cannot be measured.
Then I thought of connecting the Arduino to external power instead of powering it with the USB. And bizarrely, the values shown the the Arduino are ALWAYS 5V irrespective of whether the load is present or not.
Now my questions are:
Is it normal to have the base reference voltage level shifted with a laptop on charging as compared to not charging? Has anyone else experienced it?
Why does Powering up the Arduino externally bring the Arduino's analog pin to 5V? Are the USB power and external power in conflict? Just theoretically, will it help if I use a USB cable with just the DATA wires and without any +5V and GND wires?
Actually there is no isolation. Here is the circuit. I too understand that isolation could have an effect, but then it should affect when the laptop is not on charging as well, isn't it?
Everything here is very well protected and the AC across the shunt into the bridge is not more than 6V in any case.
There is nothing to stop any current from flowing from the 220V source in your diagram through the bridge, through the Arduino, through the USB cable, through the laptop, and through the charger to another 220V outlet.
You probably have already damaged the Arduino and possibly damaged your laptop/charger.
Don't use that circuit.
That statement just confirms that the shunt hasn't burnt out yet.
Your circuit is dangerous, you potentially have 220V on the Arduino GND pin.
Do not ignore the advice of contributors who have far more electrical experience than you do.
I agree with everyone about the dangers of this circuit. Actually earlier I was measuring the AC voltage with ZMPT101B AC Voltage sensor which provides analog output for the arduino. That worked but there was a lot of variance (instability) in the outputs of ZMPT101B for a stable AC input. Again, the input AC is maximum 6V and the variation in the output of ZMPT101B is around 30% even though I was measuring at least 10 cycles of the AC (200ms) during each test and then calculating the RMS. Later I found that this instability too was only when the laptop was charging. When not charging, the variance was less than 5%.
That's when I decided to convert the AC to DC. Anyway, can you please now suggest how to overcome the interference/variance in readings using ZMPT101B when laptop is under charge?
Also, if you could suggest a simplest way to isolate my DC voltages before connecting to the Analog Pin if the AC voltage is measuring after rectification?
I'm don't know about the wiring where you live, but the danger is if the hot & neutral get swapped. That can happen and then your voltage divider gives you 220V - 6V = 212V relative to ground! Dangerous to you and anything you connect via USB, etc. That's why it's illegal to sell something built like that! (1)
There should be no electrical connection between the AC power and the low voltage circuitry. Usually, isolation is electro-magnetic, through a transformer. A hall-effect sensor is also magnetic. A relay provides isolation (on-off only), or you can have optical isolation (usually not linear),
(1) There is an exception if everything is enclosed in an insulated box with no external connections (unless they are isolated). But, it's not easy to safely develop or troubleshoot/experiment with something like that without opening it up, or connecting USB, etc,
Humbly, that's incorrect. There is no voltage divider on the AC circuit, it is just a shunt resistor which has a potential drop across it because of the current flowing through it, irrespective of what is 'hot' and 'neutral'. Since the current is approx. 50mA and the resistor is 100 Ohms (1W), there is maximum 5V across it. This 5VAC is fed to the bridge rectifier which makes approx. 6VDC which is now fed to a load of 2x20K resistors which work as a potential divider and hence 3V is fed to the Arduino.
I agree there is a need to isolate either the AC before bridge may be with an isolation transformer or DC after bridge may be with a linear optocoupler.
A sampling resistor on the AC line is NOT THE WAY to measure AC current!
A sampling resistor on the AC line is NOT THE WAY to measure AC current!
A sampling resistor on the AC line is NOT THE WAY to measure AC current!
A sampling resistor on the AC line is NOT THE WAY to measure AC current!
You are detecting the current, conditioning the signal and then trying to find a way of getting isolation.
What you need to do is provide the isolation first (easier whilst it is still an ac signal), and then process the signal as required, but this can now be done safely.
Your code is also not written for AC,
AC changes all the time and needs to be sampled for at least one sine wave.
As others said, you're playing with your life, and worse, the life of others.
Use a (5Amp) current transformer, not a rectifier bridge, and code to sample AC.
Leo..
ZMCT103C is a small size, high accuracy module with some features and specifications mentioned below:
Current Ratio: 5A:5mA
Rated Primary Current at 50/60 Hz: 5 A
Winding D.C. Resistance at 20 °C: 155 Ω
Maximum Primary Current at 50/60 Hz: 20 A
Transformer Turns Ratio: Np:Ns = 1000:1
Isolation Voltage: 4500V
Onboard sampling resistor, to drop the voltage to lower levels
Operating Temperature: -40 to 85 °C
Pin Length of the secondary coil (encapsulation) > 3mm
Epoxy Encapsulation
Thanks a lot for your suggestion. I tried ZMCT103C but as mentioned in the original post, my current range to be measured is 13-45mA which is too low for these current sensors with 1000:1 ratio. They are made to measure 0-5A or 0-10A at the input, which would be converted to 0-5mA or 0-10mA with the CT. Now in my case when the output is 13-45mA, CT's output is 13uA to 45uA which is as good as 0 for these devices, hence there is no change in output. ZMCT103C has LM358 for amplification of small currents (or voltages actually) to a readable level with Arduino, so I tried adjusting the gain resistor values but at such high gains, the noise becomes unbearable. Same was the issue when I used ACS712 Hall sensor.
I agree I should have isolated the input which I had planned to do at a later stage. Now I have ordered an isolation transformer for such small currents and will add it to the input before feeding to the bridge rectifier.
Please let me know if you have a better alternative.
5Amp CT have a 200 ohm burden resistor, which can be increased in value.
Several loops of wire through the hole is another way to increase output.
Leo..
True. 5VAC is 14V P-P which doesn't mean anything here. It is approx. 7V DC minus the forward voltage of each diode in the bridge, but again that's not important. What's important is that I'm unable to measure current using current sensors or current transformers because the current to be measured is too small (less than 50mA max). If I use a CT with a large value of CT, there is excessive noise, if I amplify the burden resistor's voltage drop with an Op-Amp, again there is noise as soon as I get a voltage with amplitude good enough to be read by Arduino.
As mentioned in the last post, I have ordered an isolation transformer and will add it to the circuit for isolating the AC from the DC.
If you have any other solution that you can think of, please do share.
You're right, multiple loops does help but again, the variation on values for the same load checked multiple times is what is bothering. Let me explain the purpose of this.
I am building an LED PCB tester which tests LED PCBs before they're assembled into housings. These PCBs are from 3W to 20W maximum and the tester has a 3-axis motion where it goes to each PCB on the table, measures the power and if outside the acceptable range, it marks the PCB with a marker. Hence the tolerance of measurement is maximum 10% but 1000:1 CTs, I get more than 30% variance.
Yes that's what a CT is. But the isolation transformer that I've ordered is with 1:1 ratio instead of 1000:1 which is there in most available CTs. Hence I'll be able to (hopefully) use a small shunt or burden resistor to measure with the Arduino.