Interfacing ACS712 with Arduino

In this blog, we are going to learn about the ACS712 Current sensor and Interfacing ACS712 with Arduino and measure the current flowing in a circuit.
Current flowing through a conductor causes a voltage drop. The relation between current and voltage is given by Ohm’s law. In electronic devices, an increase in the amount of current above its requirement leads to overload and can damage the device.
Measurement of current is necessary for the proper working of devices. Measurement of voltage is a Passive task and it can be done without affecting the system. Whereas measurement of current is an Intrusive task that cannot be detected directly as voltage.

What is the ACS712 Current sensor?

For measuring current in a circuit, a sensor is required. ACS712 Current Sensor is the sensor that can be used to measure and calculate the amount of current applied to the conductor without affecting the performance of the system.
ACS712 Current Sensor is a fully integrated, Hall-effect-based linear sensor IC. This IC has a 2.1kV RMS voltage isolation along with a low resistance current conductor.

What is the ACS712 Current sensor?

How does the ACS712 Current sensor work?

Current Sensor detects the current in a wire or conductor and generates a signal proportional to the detected current either in the form of analog voltage or digital output.

Current Sensing is done in two ways – Direct sensing and Indirect Sensing. In Direct sensing, to detect current, Ohm’s law is used to measure the voltage drop that occurred in a wire when current flows through it.
A current-carrying conductor also gives rise to a magnetic field in its surrounding. In Indirect Sensing, the current is measured by calculating this magnetic field by applying Faraday’s law.
How does the ACS712 Current sensor work
ACS712 Current Sensor uses the Indirect Sensing method to measure the current. To sense current, a low-offset Hall effect sensor circuit is used in this module. This sensor is located at the surface of the IC on a copper conduction path. When current flows through this copper conduction path it generates a magnetic field which is sensed by the Hall effect sensor. A voltage proportional to the sensed magnetic field is generated by the Hall sensor, which is used to measure current.

Hardware required for interfacing ACS712 current sensor with Arduino:

  1. Arduino UNO - 1 (You can use any Arduino board for this project)
  2. ACS712 current sensor - 1
  3. DC motor - 1 (You can use any other load for this project)
  4. Jumper cables - As required
  5. Power supply for the load.

Circuit Diagram of ASC712 Current Sensor with Arduino

Circuit Diagram of ASC712 Current Sensor with Arduino
source-www.electronicshub.org

Code

#define sensorPin A0

void setup()
{
Serial.begin(9600);
}
void loop()
{
unsigned int x = 0;
float AcsValue = 0.0;
float Samples = 0.0;
float AvgAcs = 0.0;
float AcsValueF = 0.0;
for (int x = 0; x < 150; x++) //Get 150 samples
{
AcsValue = analogRead(sensorPin); //Read current sensor values
Samples = Samples + AcsValue; //Add samples together
delay (3); // let ADC settle before next sample 3ms
}
AvgAcs = Samples / 150.0; //Taking Average of Samples
AcsValueF = (2.5 - (AvgAcs * (5.0 / 1024.0)) ) / 0.185;
Serial.println(AcsValueF);//Print the read current on Serial monitor
delay(50);
}

Code Explanation

We have declared the analog pin A0 of Arduino for reading the current sensor’s output using the “#define” preprocessor component and named it “sensorPin”.

In the void setup() function, we are starting serial data communication with the baud rate of 9600. “Serial.begin(9600);” is the syntax used for initializing the serial communication.

In the void loop() function, we are calculating the final current using the ACS712 sensor’s analog output value. Finally, the current value will be displayed on the serial monitor.

Applications

  • Inverters
  • SMPS
  • Battery Chargers
  • Automotive Applications like Inverters
  • Used in industrial, commercial, and communication applications
  • overcurrent fault protection circuit

Frequently Asked Questions

1. How to use ACS712 current sensor Arduino?

The ACS712 sensor is used to measure the current flowing in a circuit. You can interface the ACS712 sensor with Arduino by going through the above blog.

 

2. Can ACS712 work with 3.3 V?

Yes, the ACS712 can work on 3.3V.

 

3. Can ACS712 measure DC current?

Yes, the ACS712 current sensor can measure DC current.

 

4. How current sensor works with Arduino?

The current sensor gives a different voltage level as output at different values of current flowing through the circuit. Based on the analog output of the ACS712 current sensor the current measurement is done.

Leave a comment

Please note, comments must be approved before they are published