Look for in our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Current sensor ACS712

General Information and example of use

 

Introduction

In this post we will show you how the current sensor ACS712 works and how to use it to read the current that flows throught it. This sensor can be useful to sense or control current flow in a wide variety of applications including, over-current protection circuits, battery chargers and switching mode power supplies.   
 

 


Requirements


Current Sensor ACS712

The device consists of a precise, low-offset, linear Hall sensor circuit with a copper conduction path located near the surface of the die. Applied current flowing through this copper conduction path generates a magnetic field which is sensed by the integrated Hall IC and converted into a proportional voltage. Device accuracy is optimized through the close proximity of the magnetic signal to the Hall transducer.

Schematic:

Resultado de imagen de ACS712 schematic

The ACS712 outputs an analog signal, Vout that varies linearly with the uni- or bi-directional AC or DC primary sensed current, Ip, within the range specified. Cf is recommended for noise management, with values that depend on the application.  

There are three different types of ACS712 acording to the Ip range. Incresing the Ip you get a better sensitivity: 


Part NumberOptimized Range, Ip (A)Sensitivity, Sens (Typ) (mV/A)
ACS712ELCTR-05B-T+- 5185
ACS712ELCTR-20A-T+- 20100
ACS712ELCTR-30A-T
+-3066

The thickness of the copper conductor allows survival of the device at up to 5× overcurrent conditions. The terminals of the conductive path are electrically isolated from the sensor leads (pins 5 through 8).

General Specifications:


Supply Voltage (Vcc)8 V
Reverse Supply Voltage (Vrcc)-0.1 V
Output Voltage (Viout)8 V
Supply Current (Icc) Typ. / Max. 10 / 13 mA
Frequency Bandwidth (f)80 kHz
Magnetic Coupling12 G/A
Internal Filter Resistance1.7 kOhm
Operating Internal Leadframe Temperature (Ta) Min. / Max.-40 / 80 ºC

ACS712ELCTR-05B-T Specifications:



Optimized Accuracy Range (Ip) Min. / Max. -5 / 5 A
Sensitivity (Sens) 185 mV/A
Noise (Vnoise)21 mV
Total Output Error +-1.5 %

ACS712ELCTR-20A-T Specifications:
Optimized Accuracy Range (Ip) Min. / Max. -20 / 20 A
Sensitivity (Sens) 100 mV/A
Noise (Vnoise)11 mV
Total Output Error +-1.5 %


ACS712ELCTR-30A-T Specifications:

Optimized Accuracy Range (Ip) Min. / Max. -30 / 30 A
Sensitivity (Sens) 66 mV/A
Noise (Vnoise)7 mV
Total Output Error +-1.5 %


Example of use

This example uses a ACS712ELECTR-30A-T, so its possible to input up to +-30 A. The next graph shows the relation between  Ip (A) and Viout (V) with Vcc = 5 V: 


Resultado de imagen de Output Voltage versus Sensed Current ACS712 30

As you can see, with an Input value of Ip = 0 -> Viout = Vcc /2 = 2.5 V.  The same thing happens with the other two sensors. So there is an offset of 2.5 V. As we said, the ACS712 can read negative and positive values but returns values from 0 to Vcc. 

We read the output value Viout from the ACS712 in the Arduino analogic input pin, for example, A0. These are ACD registers of 10 bits, so the value you read in the arduino are from 0 to 1024  (2^10). To get the proporcional value of Viout voltage, you have to multiply by Vcc/1024, that is, Voltage = V_A0 * (5/1024). Dividing the Voltage (V) by the sensitivity (mV/A) provides the Input current.  


Connections


Code

Here you have the example code. This example prints the calculated current Input in A units:


#define ACS712 A0 //Define an analog input where we read Viout from the ACS712 
#define SENS 0.066 //Define sens of ACS712 30A

float voltage, current; //Create variables voltage and current as a float

void setup() {
  pinMode(ACS712, INPUT); //Set pin A0 as Input to read the values from Viout
  Serial.begin(115200); //Set baud rate speed for the serial
}

void loop() {
  calculate_current(analogRead(ACS712)); //Calculate current from de analog value of A0
  Serial.println("Amperage: " + String(current));
}

void calculate_current(int16_t adc_v){
  voltage = adc_v * (5.0/1024) - 2.5;//v = ADC_V * (Vcc/1024) - offset
  current = voltage / SENS; //Dividing the voltage by the sensitivity provides the current
}

 

Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send