Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
The ACS712 is a popular sensor for measuring current in a circuit. It is a Hall-effect-based linear current sensor that provides an analog voltage output proportional to the current flowing through the sensor. This sensor is widely used in Arduino projects due to its simplicity and effectiveness.
The ACS712 sensor comes in different variants, each capable of measuring different current ranges: 5A, 20A, and 30A. The sensor outputs an analog voltage that is linearly proportional to the AC or DC current passing through it. The output voltage is centered at Vcc/2 (typically 2.5V for a 5V supply) when no current is passing through.
To measure current using the ACS712 with an Arduino, follow these steps:
Components Required:
Wiring:
Here's a simple Arduino sketch to read and display the current measured by the ACS712 sensor:
const int analogInPin = A0; // Analog input pin that the ACS712 OUT is attached to
int sensorValue = 0; // Value read from the sensor
float voltage = 0; // Variable to hold the calculated voltage
float current = 0; // Variable to hold the calculated current
// Sensitivity (mV/A) for different ACS712 models
// 185 for 5A, 100 for 20A, and 66 for 30A
const float sensitivity = 185.0; // Adjust based on your ACS712 model
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(analogInPin); // Read the analog input
voltage = sensorValue * (5.0 / 1023.0); // Convert the reading to voltage
current = (voltage - 2.5) * 1000 / sensitivity; // Calculate current in Amperes
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
delay(1000); // Wait for a second before the next reading
}
analogRead()
function reads the voltage output from the ACS712 sensor.(sensorValue * (5.0 / 1023.0))
.