Arduino - voltage and current measurement ACS712, ADS1015
How to make a circuit for voltage and current measurement using Arduino and ACS712, ADS1015.
The ADS1015 is a 12-bit analog-to-digital converter. Equipped with i2c bus and 4 channels A0-4. What is very
important is also have "Internal Low-Drift Voltage Reference", which significantly simplifies the construction
of precision measuring systems.
ACS712 is the circuit for measuring the current using a hall effect. My version measures current from -30A to 30A.
For testing I used a bulb in the diagram shown as R9.
I used resistors R7 and R8 to make the voltage divider.
Step 3: Software
The following piece of code is responsible for the measurement at the 4 inputs of the ADC.
The value "NUMBR_OF_SAMPLES" specifies the number of samples, in this case it is 20.
After sampling, the average value of the measurements is calculated.
To calculate the voltage at ADS1015 inputs, you need to multiply the average value of the measurement by 3mV( 3.0f/1000.0f ).
Because at the AIN0 input I have a voltage divider, so I have to multiply it by 10.
Resistors are not perfect, that's why I multiply everything by 1.0805f.
To accurately calculate the current I have to measure the ACS712 power supply voltage. In the test, the whole
circuit is powered by USB, which is approximately 5V. In my case the voltage was 4.72V. This difference
is significant when measuring accurately.