



The ACS712 is a widely used hall effect-based current sensor that provides a simple, effective way to measure both AC and DC currents. The ACS712-5A version is designed to measure currents up to 5A with an analog output that is proportional to the current flowing through the sensed conductor.
Typically, the ACS712 module has the following pins:
This simple code reads the output of the ACS712, calculates the current flowing through the conductor, and displays the value on the Serial Monitor.
const int sensorPin = A0; // Pin connected to the OUT pin of ACS712
float sensorValue = 0; // Variable to store sensor value
float voltage = 0; // Variable to store voltage reading
float current = 0; // Variable to store current in Amps
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
sensorValue = analogRead(sensorPin); // Read the analog value from ACS712
voltage = (sensorValue * 5.0) / 1023.0; // Convert the analog value to voltage
current = (voltage - 2.5) / 0.185; // Convert voltage to current (using the sensitivity)
Serial.print("Current: ");
Serial.print(current, 3); // Print current in amperes with 3 decimal places
Serial.println(" A");
delay(500); // Delay for half a second
}
analogRead() function reads the voltage on pin A0 (connected to the ACS712's OUT pin).Brand:- Generic
Origin:- China