Measuring 5A to 30A AC and DC Current Using the ACS712 with Robojax Library

Measuring 5A to 30A AC and DC Current Using the ACS712 with Robojax Library

This project guide demonstrates how to measure AC and DC currents ranging from 5A to 30A using the Allegro ACS712 current sensor and a custom Arduino library. The ACS712 is a versatile sensor suitable for various applications. This guide will equip you with the knowledge and code to integrate this sensor into your own projects.

Practical Applications:

  • Monitoring current draw in power supplies.

  • Building a battery management system.

  • Designing a motor controller with current limiting.

  • Creating a smart energy meter for home automation.

  • Developing a system for monitoring industrial equipment.

Hardware/Components

The core component is the Allegro ACS712 current sensor module, available in 5A, 20A, and 30A versions (in video at 00:50). You'll also need an Arduino microcontroller, connecting wires, and a power supply. For testing, a variable DC power supply and an electronic load are helpful (in video at 07:05), as well as an AC load (e.g., a toaster) for AC current measurements (in video at 17:10).

Wiring Guide

The ACS712 module has can be connected in series with the load either AC or DC as shown in the image below.

Wiring for Allegro ACS712 Current Sensor (DC-at negative)
Wiring for Allegro ACS712 Current Sensor (DC-at negative)
Wiring for Allegro ACS712 Current Sensor (DC- at positive)
Wiring for Allegro ACS712 Current Sensor (DC- at positive)
Wiring for Allegro ACS712 Current Sensor (AC)
Wiring for Allegro ACS712 Current Sensor (AC)

The ACS712 module has three pins: VCC (5V), GND, and an analog output pin (VOUT). Connect VCC to the Arduino's 5V pin, GND to GND, and VOUT to an analog pin (A0 in the example, in video at 01:55). The load is connected in series with the sensor, with one wire going through the sensor's input and output terminals (in video at 06:00).

ACS712 Arduino writing
ACS712 Arduino writing

Code Explanation

The provided Arduino code utilizes a custom library, Robojax_AllegroACS_Current_Sensor (in video at 07:38). The key configurable parts are:


const int VIN = A0; // Analog pin for current sensor output
const float VCC = 5.04; // Supply voltage (adjust if needed)
const int MODEL = 0; // ACS712 model (0 for 5A, 1 for 20A, 2 for 30A)

The MODEL constant selects the sensor type. The getCurrent() function reads the current, and getCurrentAverage() calculates the average current over a specified number of readings (in video at 10:10). Remember to install the custom library before using this code.

Live Project/Demonstration

The video demonstrates measuring DC current with the 5A and 30A versions of the ACS712 (in video at 12:26 and 14:39). It also shows how to measure AC current using a toaster as a load (in video at 17:07). Note the significant heating of the 30A module when subjected to its maximum current rating, highlighting the importance of proper thermal management and component selection for high-current applications (in video at 16:28).

Video Chapters

  • [00:00] Introduction

  • [00:50] ACS712 Overview

  • [01:31] Hardware Explained

  • [02:22] Datasheet Viewed

  • [05:57] Wiring Explained

  • [07:36] Code Explained

  • [12:26] ACS712 5A Module Demonstration

  • [14:36] ACS712 30A Module Demonstration

  • [17:07] AC Load Current Measurement

  • [19:37] Conclusion Remarks

Imágenes

Wiring for Allegro ACS712 Current Sensor (AC)
Wiring for Allegro ACS712 Current Sensor (AC)
Wiring for Allegro ACS712 Current Sensor (DC- at positive)
Wiring for Allegro ACS712 Current Sensor (DC- at positive)
Wiring for Allegro ACS712 Current Sensor (DC-at negative)
Wiring for Allegro ACS712 Current Sensor (DC-at negative)
ACS712 Arduino writing
ACS712 Arduino writing
304-Arduino Code for Allegro Current Sensor (ACS712 default)
Idioma: C++
¡Copiado!

Recursos y referencias

Archivos📁

No hay archivos disponibles.