But the libraries are for measuring a constant DC current not recitified AC.
The INA219 and INA226 are intended for constant level DC not rectified AC.
You are much bettor off using a 5A ACS712
There is an example of how to do this on the openenergymonitor.org website.
It's not quite the same as using an INA219; They are using a current transformer, and the Arduino's own ADC, but the principle is the same.
https://docs.openenergymonitor.org/electricity-monitoring/ct-sensors/interface-with-arduino.html
Have a look at their Arduino example.
Look at the function "calcIrms(unsigned int Number_of_Samples)" in EmonLib.cpp for an indication of what you need to do.
Basically you need to:
- take hundreds of current measurements (samples) in quick succession.
- square each value.
- add each squared value to a running total.
- divide the total by the number of samples.
- take the square root.
and that will give you the rms current.
Bi-directional DC only, not (negative going) AC.
Cross-post. It all started here (click).
Leo..
I can't see how you can have something bi-directional if it isn't negative going.
The datasheet says that it can measure shunt voltages of up to ±320 mV.
To me that means it will measure negative going currents.
What is the AC voltage? After full wave rectification, a filter capacitor will have about 1.4 times the AC RMS voltage across it.
EXAMPLE: 12VAC RMS will charge the capacitor to near 17VDC - 2 diode drops (1.4V) =15.6VDC.
Think of measuring current in the + lead of a car battery.
Current can flow both ways during charging/discharging, but the voltage always stays +12volt.
Leo..
Of course.
Good explanation.
I am confused now, does the plan still look promising or ?
Do you understand what you have to do?
Not really , after Wawa input I am not sure if it would work as suggested by JohnLincoln.
I too am beginning to have doubts.
I still think it will measure current in both directions, but it will only measure positive voltages.
I think I had overlooked its voltage measuring capabilities as you hadn't mentioned anything about measuring voltage.
I recommend buying the ACS724. Install a 0.33uF ceramic capacitor in the holes provided.
It has a range of +/-2.5A with a sensitivity of 800mV/A.
For highest accuracy I would use the Arduino 1.1V internal reference but it must be calibrated
You can use the ACS712 library with this board.
ACS712 ACS(A0, 1.1, 1023, 800);
I appreciate it as always jim, I will give this a try and I hope it works ..
I will use 0.33uF cap for Cf, and I can use LT1461 voltage reference instead of the internal reference.
Actually the 1.1V internal reference will be too low for 1A (rms)
For maximum precision, you want the vref to be as close to the maximum voltage you need to measure.
If you use a reference of 1.5V the max rms current you can measure will be (1.5/0.8) * 0.707 = 1.326 A (rms).
So I recommend this vref
The code would be
ACS712 ACS(A0, 1.5, 1023, 800);
I actually was thinking if just using a 5V from the supply and through the LT1461 to the sensor, doesn't the sensor need 4.5 to 5V supply ?
The ACS724, like the ACS712, is a ratiometric device. You introduce another error by powering the sensor and the A/D from a different reference voltage.
This advice gets OP in the same situation as the previous threads, where the ACS was measured with the 1volt reference of an ESP8266.
Leo..
Both the Arduino and the sensor will be powered through the voltage reference IC, I think there won't be a problem.
Are still using an ESP32 or are you now using an UNO
This time I will be going with the Mega- atmega32 ..
Did you mean an ATMega32U4, like a Pro Micro?