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.

This article can also see here:

Arduino - voltage and current measurement ACS712, ADS1015

Step 1: Components

Step 2: Schematic

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.

  int16_t adc0, adc1, adc2, adc3;

  float avg0 = 0.0f;
  float avg1 = 0.0f;
  float avg2 = 0.0f;
  float avg3 = 0.0f;
  for(int i=0; i<NUMBR_OF_SAMPLES; i++){
    adc0 = ads.readADC_SingleEnded(0);
    adc1 = ads.readADC_SingleEnded(1);
    adc2 = ads.readADC_SingleEnded(2);
    adc3 = ads.readADC_SingleEnded(3);

    avg0 += adc0;
    avg1 += adc1;
    avg2 += adc2;
    avg3 += adc3;
    delay( 10 );
  avg0 = avg0/(float)(NUMBR_OF_SAMPLES);
  avg1 = avg1/(float)(NUMBR_OF_SAMPLES);
  avg2 = avg2/(float)(NUMBR_OF_SAMPLES);
  avg3 = avg3/(float)(NUMBR_OF_SAMPLES);
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.
  float voltage0 = DIVISOR0 * (avg0 * 3.0f/1000.0f);
  float voltage1 = DIVISOR1 * (avg1 * 3.0f/1000.0f);
  float voltage2 = DIVISOR2 * (avg2 * 3.0f/1000.0f);
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.
  float w = ( voltage2/5.0f ) * 0.066f;
  float i_cur = ((voltage2 / 2.0f) - voltage1) / w;
To calculate power we multiply the voltage and current by itself.
  float power = voltage0 * i_cur;
Download source code: Arduino-voltage-and-current.ino

Step 4: Comparing Results

The difference in measurement between DT-832 DIGITAL MULTIMETER and Arduino is very small.

wwwGoogle pluseTwitter

<p>I know this is just a breadboard, proof-of-concept Instructable, but does the ADS1015 buy you anything? The arduino analog pins have 10-bit precision, so you can read down to around 0.05V and 0.06A. And you can increase the voltage precision by changing the voltage divider.</p>
<p>Thanks for the comment, that's a good question. The advantages of &quot;ADS1015&quot; are: 12-Bit Noise-Free Resolution, Internal Low-Drift Voltage Reference, I2C Bus, Wide Supply Range: 2.0 V to 5.5 V, Increase the number of pins.</p>

About This Instructable




Bio: Software, electronics, do-it-yourself
More by adachsoft:Control Any Devices Using Raspberry PI and PCF8574, Relay Module Raspberry PI Samba Server and Share /var/www/ 1 Pin & 6 Buttons - Analog Keyboard 
Add instructable to: