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.
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).
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
/*
*
* Arduino Sketch for Allegro ACS712 Current Sensor
* This sensor is offered at 5A, 20A, and 30A ranges for AC and DC
* It operates with 5V
* Please watch the video instruction and explanation for this code
YouTube video: https://youtu.be/3C33DpcSwIw
📚⬇️ Get this code from https://robojax.com/RJT286
written by Ahmad Shamshiri for Robojax.com
00:51 Introduction
01:31 Hardware Explained
02:20 Datasheet Viewed
05:55 Wiring Explained
07:37 5A module demonstration
09:48 30A module demonstration
12:18 AC current measurement
14:46 Conclusion remarks
*
* Written by Ahmad Shamshiri on Saturday, March 14, 2020 at 16:15 in Ajax, Ontario, Canada
* for Robojax.com
* View the video:
* This code has been downloaded from Robojax.com
*
model select
//ACS712
0-"ACS712ELCTR-05B",
1-"ACS712ELCTR-20A",
2-"ACS712ELCTR-30A",
//ACS758
3,// for ACS758LCB-050B
4,// for ACS758LCB-050U
5,// for ACS758LCB-100B
6,// for ACS758LCB-100U
7,// for ACS758KCB-150B
8,// for ACS758KCB-150U
9,// for ACS758ECB-200B
10,// for ACS758ECB-200U
///ACS770
11,// for ACS770x-050B ///
12,// for ACS770x-050U
13,// for ACS770x-100B
14,// for ACS770x-100U
15,// for ACS770x-150B
16,// for ACS770x-150U
17,// for ACS770x-200B
18,// for ACS770x-200U
19 for "ACS732KLATR-20AB",
20 for "ACS732KLATR-40AB",
21 for "ACS732KLATR-65AB",
22 for "ACS732KLATR-65AU",
23 for "ACS732KLATR-75AB",
24 for "ACS733KLATR-20AB",
25 for "ACS733KLATR-40AB",
26 for "ACS733KLATR-40AU",
27 for "ACS733KLATR-65AU",
* This code has been downloaded from https://robojax.com
* Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all material, wiring diagrams, and libraries
all in one place.
or make a donation using PayPal http://robojax.com/L/?id=64
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been downloaded from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int VIN = A0; // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.04;// supply voltage
const int MODEL = 0; // enter the model (see above list)
#include <Robojax_AllegroACS_Current_Sensor.h>
Robojax_AllegroACS_Current_Sensor robojax(MODEL,VIN);
void setup() {
//Robojax.com Allegro ACS Current Sensor
Serial.begin(9600);// initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("ACS770 Current Sensor");
}
void loop() {
//Robojax.com Allegro ACS Current Sensor
Serial.print("Current: ");
Serial.print(robojax.getCurrent(),3); // print the current with 3 decimal places
Serial.print("A Avg:");
Serial.print(robojax.getCurrentAverage(300),3);//
Serial.println("A");
//robojax.debug();
delay(1500);
}
|||您可能需要的东西
-
亚马逊从亚马逊欧洲购买Seek热像仪amzn.to
-
亚马逊从加拿大亚马逊购买Seek热成像相机amzn.to
-
亚马逊从美国亚马逊购买Seek热像仪。amzn.to
资源与参考
-
产品规格书Allegro ACS712 AC/DC 4A, 20A, 30A Current Sensor Datasheetallegromicro.com
文件📁
其他文件
-
Robojax Allegro ACS Current Sensor LibraryThis is version 1.0
robojax_Allegro_ACS_Current_library.zip0.02 MB