Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Measure Current with ACS712 and Arduino

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.

Understanding ACS712

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.

Connecting ACS712 to Arduino

To measure current using the ACS712 with an Arduino, follow these steps:

  1. Components Required:

    • Arduino board (e.g., Arduino Uno)
    • ACS712 current sensor module
    • Connecting wires
    • Load (e.g., a DC motor or a resistor)
  2. Wiring:

    • Connect the VCC pin of the ACS712 to the 5V pin on the Arduino.
    • Connect the GND pin of the ACS712 to the GND pin on the Arduino.
    • Connect the OUT pin of the ACS712 to an analog input pin on the Arduino (e.g., A0).
    • Connect the load in series with the IP+ and IP- pins of the ACS712.

Arduino Code Example

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
}

Explanation

  • Analog Reading: The analogRead() function reads the voltage output from the ACS712 sensor.
  • Voltage Conversion: The analog reading is converted to a voltage using the formula (sensorValue * (5.0 / 1023.0)).
  • Current Calculation: The current is calculated by subtracting the mid-point voltage (2.5V for a 5V system) from the measured voltage and then dividing by the sensor's sensitivity.

Considerations

  • Ensure the ACS712 is rated for the current range you intend to measure.
  • The sensor's accuracy can be affected by temperature and other environmental factors, so consider calibrating it if precise measurements are needed.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.