Using Multiple (3) Allegro AC and DC Current Sensors with the RoboJax Library
In this tutorial, we will learn how to use multiple Allegro ACS770 current sensors in an Arduino project. The ACS770 sensors can measure both AC and DC currents, making them versatile for various applications. We will set up three sensors to monitor current and display the readings on the serial monitor.
This project will guide you through the wiring and coding necessary to implement these sensors effectively. You will understand how to read current values, average them, and display them, as well as how to handle the data in your Arduino sketch (in video at 10:30).
Hardware Explained
The main component of this project is the Allegro ACS770 current sensor. This sensor uses Hall effect technology to measure the current flowing through it. It has a range of models available, measuring currents from 50A up to 200A, and can handle both AC and DC currents depending on the variant used.
The ACS770 features three pins: VCC for power, GND for ground, and VOUT for the output voltage proportional to the current measured. When current flows through the sensor, it generates a voltage output that the Arduino reads to determine the current level.
Datasheet Details
| Manufacturer | Allegro Microsystems |
|---|---|
| Part number | ACS770 |
| Logic/IO voltage | 4.5 - 5.5 V |
| Supply voltage | 5 V (typ.) |
| Output current (per channel) | 50 A, 100 A, 150 A, 200 A |
| Peak current (per channel) | 100 A (typ.) |
| PWM frequency guidance | Not applicable |
| Input logic thresholds | 0.8 V (high), 0.3 V (low) |
| Voltage drop / RDS(on) / saturation | 100 μΩ (typ.) |
| Thermal limits | 0 to 125 °C |
| Package | SOIC-8 |
| Notes / variants | Available in bi-directional and unidirectional configurations |
- Ensure proper heat sinking for higher currents.
- Use short and thick wires to minimize resistance.
- Decouple the power supply with a capacitor near the sensor.
- Verify sensor model and configuration before wiring.
- Be cautious of noise in PWM applications; consider filters.
Wiring Instructions

To wire the ACS770 current sensors, start by connecting the VCC pin of each sensor to the 5V output on the Arduino. Next, connect the GND pin to the ground on the Arduino. For the output pin, connect VOUT of the first sensor to A0 on the Arduino, the second sensor's VOUT to A1, and the third sensor's VOUT to A2.
For the load connection, ensure that the sensors are placed in series with the load. Connect the load's positive terminal to the sensor's input, and the output terminal of the sensor to the positive side of your power source. Ensure that the wire used for the load is suitable for the current rating of the sensor.
Code Examples & Walkthrough
Below is an excerpt from the Arduino sketch that initializes the sensors and reads the current values. The identifiers VIN1, VIN2, and VIN3 correspond to the analog input pins connected to each sensor's output.
const int VIN1 = A0; // define the Arduino pin A0 as voltage input (V in for sensor 1)
const int VIN2 = A1; // define the Arduino pin A1 as voltage input (V in for sensor 2)
const int VIN3 = A2; // define the Arduino pin A2 as voltage input (V in for sensor 3)
const float VCC = 5.04; // supply voltage
This code sets up three sensors, each connected to different analog pins. The variable VCC holds the supply voltage value which is used for calculations later in the code.
In the setup() function, we initialize the serial communication to display the sensor readings.
void setup() {
Serial.begin(9600); // initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("Using 3 ACS770 Current Sensors");
}
The loop() function is where we continuously read and display the current values from each sensor.
void loop() {
Serial.print("Current-1: ");
Serial.print(robojax1.getCurrent(), 3); // print the current with 3 decimal places
Serial.println("A");
// Repeat for sensor 2 and sensor 3
delay(1500);
}
This code retrieves the current from each sensor using the getCurrent() method and prints it to the serial monitor. The readings are updated every 1.5 seconds.
Demonstration / What to Expect
Once everything is wired and the code is uploaded, you should see the current readings from each sensor displayed on the serial monitor. As you adjust the load, the current values should reflect the changes accurately. Make sure to check the sensor specifications to ensure you are within the operational limits.
Common pitfalls include incorrect wiring or exceeding the current rating of the sensors, which can lead to inaccurate readings or damage. Always verify connections before applying power (in video at 15:10).
Video Timestamps
- 00:00 - Introduction
- 10:30 - Code explanation
- 15:10 - Common pitfalls
++
/*
*
* Arduino Sketch for Allegro ACS770 Current Sensor to use 2 or more sensors
* This sensor is offered at 50A, 100A, 150A, and 200A range.
* Both for AC and DC.
*
* It operates with 5V.
* Please watch the video instruction and explanation for this code.
* Watch video instruction for ACS770 50A to 200A Sensors: https://youtu.be/sB6EULTix2k
* Watch video instruction for ACS712 5A to 30A Sensors: https://youtu.be/3C33DpcSwIw
*
* Written by Ahmad Shamshiri on Saturday, April 4, 2020, at 21:19 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. Purchase my course on Udemy.com: http://robojax.com/L/?id=62
****************************
* Get early access to my videos via Patreon and have your name mentioned at the end of every
* video I publish on YouTube here: http://robojax.com/L/?id=63 (watch until the end of this video for a list of my Patrons)
****************************
* 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 VIN1 = A0; // define the Arduino pin A0 as voltage input (V in for sensor 1)
const int VIN2 = A1; // define the Arduino pin A0 as voltage input (V in for sensor 2)
const int VIN2 = A2; // define the Arduino pin A0 as voltage input (V in for sensor 2)
const float VCC = 5.04;// supply voltage
const int MODEL1 = 12; // enter the model for sensor 1
const int MODEL2 = 12; // enter the model for sensor 2
const int MODEL3 = 12; // enter the model for sensor 3
//using ACS770x-050U
#include <Robojax_AllegroACS_Current_Sensor.h>
Robojax_AllegroACS_Current_Sensor robojax1(MODEL1,VIN1);
Robojax_AllegroACS_Current_Sensor robojax2(MODEL2,VIN2);
Robojax_AllegroACS_Current_Sensor robojax3(MODEL3,VIN3);
void setup() {
//Robojax.com Allegro ACS Current Sensor
Serial.begin(9600);// initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("Using 3 ACS770 Current Sensors");
}
void loop() {
//Robojax.com Allegro ACS Current Sensor
// print current for sensor 1
Serial.print("Current-1: ");
Serial.print(robojax1.getCurrent(),3); // print the current with 3 decimal places
Serial.print("A Avg:");
Serial.print(robojax1.getCurrentAverage(300),3);//
Serial.println("A");
// print current for sensor 2
Serial.print("Current-2: ");
Serial.print(robojax2.getCurrent(),3); // print the current with 3 decimal places
Serial.print("A Avg:");
Serial.print(robojax2.getCurrentAverage(300),3);//
Serial.println("A");
// print current for sensor 3
Serial.print("Current-3: ");
Serial.print(robojax3.getCurrent(),3); // print the current with 3 decimal places
Serial.print("A Avg:");
Serial.print(robojax3.getCurrentAverage(300),3);//
Serial.println("A");
//robojax.debug();
delay(1500);
}
资源与参考
-
外部Allegro ACS770 product page (website)allegromicro.com
文件📁
其他文件
-
Robojax Allegro ACS Current Sensor LibraryThis is version 1.0
robojax_Allegro_ACS_Current_library.zip0.02 MB