Measuring Current Using an Allegro ACS758 Current Sensor with an LCD1602 (I2C) for Arduino
In this tutorial, we will learn how to measure current using the Allegro ACS758 current sensor and display the readings on an LCD1602 using I2C communication. This setup is useful for various applications, such as monitoring power consumption in circuits or managing battery usage in devices. By the end of this project, you will have a functioning system that displays real-time current readings.


The ACS758 current sensor can measure currents up to 200A, making it ideal for high-power applications. The LCD1602 display will show the current in amperes along with the corresponding voltage sensed by the current sensor. To clarify any steps, be sure to check the video (in video at 00:00) for a visual demonstration.
Hardware Explained
The main components of this project include the Allegro ACS758 current sensor and the LCD1602 display with I2C. The ACS758 operates by measuring the magnetic field generated by the current flowing through a conductor. It provides an output voltage proportional to the current flowing, which can be easily read by the Arduino.
The LCD1602 is a 16x2 character display that uses I2C communication, allowing for easy connection and control with only two data pins. This reduces the number of wires needed, simplifying the wiring process. The I2C interface enables multiple devices to communicate over the same bus, making it a versatile choice for projects.
Datasheet Details
| Manufacturer | Allegro Microsystems |
|---|---|
| Part number | ACS758 |
| Logic/IO voltage | 3.3V / 5V |
| Supply voltage | 5V |
| Output current (per channel) | 200 A max |
| Peak current (per channel) | 200 A |
| PWM frequency guidance | N/A |
| Input logic thresholds | 0.3V (low), 2.7V (high) |
| Voltage drop / RDS(on) / saturation | 0.5V max |
| Thermal limits | up to 150°C |
| Package | TO-220 |
| Notes / variants | Bidirectional and unidirectional options |
- Ensure proper heat sinking for high current applications.
- Decouple the power supply to avoid noise affecting readings.
- Use twisted pair wires for the current path to minimize interference.
- Verify the output voltage corresponding to zero current for calibration.
- Check polarity when using unidirectional sensors.
Wiring Instructions

To wire the Allegro ACS758 current sensor and the LCD1602 display, start by connecting the power and ground. Connect the VCC pin of the ACS758 to the 5V pin on the Arduino, and connect the GND pin to the Arduino’s ground. The signal output pin (Vout) from the ACS758 should be connected to the analog input pin A0 on the Arduino.
Next, for the LCD1602 display, connect the VCC pin to the 5V pin on the Arduino and the GND pin to ground. The SDA (data line) from the LCD should connect to the Arduino's A4 pin, and the SCL (clock line) should connect to the A5 pin. This setup allows for I2C communication between the Arduino and the LCD1602.
Code Examples & Walkthrough
The Arduino sketch begins by defining the input pin for the current sensor. The variable VIN is defined as A0, which is where the sensor's output will be read. The voltage supply and model of the ACS758 are also defined. The sensitivity for the selected model is calculated using the sensitivity array.
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.0; // supply voltage 5V or 3.3V
const int model = 2; // enter the model (see below)
In the setup() function, the LCD is initialized and a welcome message is displayed. The backlight is turned on for better visibility. This is where you can customize the initial display message to suit your project.
void setup() {
Serial.begin(9600); // initialize serial monitor
lcd.begin(); // initialize the LCD
lcd.backlight();
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("ACS758 Current Sensor");
delay(2000); // delay for 2 seconds
lcd.clear();
}
In the loop() function, the voltage from the sensor is read and processed to calculate the current. If the voltage exceeds a defined cutoff limit, the current is displayed on both the serial monitor and the LCD. If no current is detected, a message is shown indicating "No Current". This allows for real-time monitoring of current flow.
void loop() {
float voltage_raw = (5.0 / 1023.0) * analogRead(VIN); // Read voltage from sensor
float current = voltage / FACTOR;
if (abs(voltage) > cutOff) {
Serial.print("V: "); Serial.print(voltage, 3); // print voltage
lcd.print(current); // display current on LCD
} else {
Serial.println("No Current"); // output when no current is detected
}
delay(500); // wait before next reading
}
Make sure to watch the full code walkthrough in the video (in video at 01:30) for a detailed explanation of each segment.
Demonstration / What to Expect
When powered on, the system will display the current flowing through the sensor on the LCD in real-time. You can test the setup by applying a known current and observing the readings. If the sensor detects current, the voltage and current values will update on the display. If there is no current, the message "No Current" will appear. Be cautious of reversed polarity connections, which can lead to incorrect readings or damage to the components.
/*
*
* Arduino Sketch for Allegro ACS758 Current Sensor with LCD1602 & I2C module
* This sensor can measure current at a range of up to 200A.
* It operates with 3.3V or 5V.
* This sketch requires you to watch the following two videos before using this code:
* 1- ACS758 Sensor https://www.youtube.com/watch?v=SiHfjzcqnU4
* 2- LCD1602 with I2C https://www.youtube.com/watch?v=q9YC_GVHy5A
*
*
* Written by Ahmad Shamshiri on Tuesday, June 19, 2018, at 20:40 in Ajax, Ontario, Canada
* for Robojax.com
* View the video instruction for this code at https://youtu.be/tug9wjCwDQA
* This code has been downloaded from Robojax.com
*/
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.0;// supply voltage 5V or 3.3V. If using PCB, set to 5V only.
const int model = 2; // enter the model (see below)
float cutOffLimit = 1.00;// reading cut-off current. 1.00 is 1 Amper
/*
"ACS758LCB-050B",// for model use 0
"ACS758LCB-050U",// for model use 1
"ACS758LCB-100B",// for model use 2
"ACS758LCB-100U",// for model use 3
"ACS758KCB-150B",// for model use 4
"ACS758KCB-150U",// for model use 5
"ACS758ECB-200B",// for model use 6
"ACS758ECB-200U"// for model use 7
The sensitivity array is holding the sensitivity of the ACS758
current sensors. Do not change.
*/
float sensitivity[] ={
40.0,// for ACS758LCB-050B
60.0,// for ACS758LCB-050U
20.0,// for ACS758LCB-100B
40.0,// for ACS758LCB-100U
13.3,// for ACS758KCB-150B
16.7,// for ACS758KCB-150U
10.0,// for ACS758ECB-200B
20.0,// for ACS758ECB-200U
};
/*
* Quiescent output voltage is a factor of VCC that appears at the output
* when the current is zero.
* For bidirectional sensors it is 0.5 x VCC
* For unidirectional sensors it is 0.12 x VCC
* For model ACS758LCB-050B, the B at the end represents Bidirectional (polarity doesn't matter)
* For model ACS758LCB-100U, the U at the end represents Unidirectional (polarity must match)
* Do not change.
*/
float quiescent_Output_voltage [] ={
0.5,// for ACS758LCB-050B
0.12,// for ACS758LCB-050U
0.5,// for ACS758LCB-100B
0.12,// for ACS758LCB-100U
0.5,// for ACS758KCB-150B
0.12,// for ACS758KCB-150U
0.5,// for ACS758ECB-200B
0.12,// for ACS758ECB-200U
};
const float FACTOR = sensitivity[model]/1000;// set sensitivity for selected model
const float QOV = quiescent_Output_voltage [model] * VCC;// set quiescent Output voltage for selected model
float voltage;// internal variable for voltage
float cutOff = FACTOR/cutOffLimit;// convert current cut off to mV
// ======== start of LCD1602 with i2C settings
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// ======= END of LCD1602 with i2C settings
void setup() {
//Robojax.com ACS758 Current Sensor
Serial.begin(9600);// initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("ACS758 Current Sensor");
Serial.println("with LCD1602 & I2C");
// initialize the LCD,
lcd.begin();
// Turn on the backlight and print a message.
lcd.backlight();
lcd.clear();
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("ACS758 Current Sensor");
delay(2000);
lcd.clear();
}
void loop() {
//Robojax code ACS758 with LCD1602 and I2C
float voltage_raw = (5.0 / 1023.0)* analogRead(VIN);// Read the voltage from sensor
voltage = voltage_raw - QOV + 0.007 ;// 0.007 is a value to make voltage zero when there is no current
float current = voltage / FACTOR;
if(abs(voltage) > cutOff ){
Serial.print("V: ");
Serial.print(voltage,3);// print voltage with 3 decimal places
Serial.print("V, I: ");
Serial.print(current,2); // print the current with 2 decimal places
Serial.println("A");
//start of loop Robojax code ACS758 with LCD1602 and I2C
lcd.clear();
lcd.setCursor (0,0); // set to line 1, char 0
lcd.print("Current: ");
lcd.setCursor (9,0); // go to start of 2nd line
lcd.print(current);
lcd.setCursor (15,0); // go to start of 2nd line
lcd.print("A");
lcd.setCursor (0,1);
lcd.print("Sense V: ");
lcd.setCursor (9,1); // go to start of 2nd line
lcd.print(voltage);
lcd.setCursor (15,1); // go to start of 2nd line
lcd.print("V");
lcd.backlight();
//end of loopcode Robojax code ACS758 with LCD1602 and I2C
}else{
Serial.println("No Current");
lcd.clear();
lcd.setCursor (0,0);
lcd.print("No Current");
}
delay(500);
}
|||您可能需要的东西
-
亚马逊亚马逊上的ACS758电流传感器amzn.to
-
易趣从eBay购买Allegro ACS758电流传感器ebay.us
-
全球速卖通从AliExpress购买Allegro ACS758电流传感器s.click.aliexpress.com
资源与参考
尚无可用资源。
文件📁
Fritzing 文件
-
LCD LCD1602-I2C module with 4 wires
LCD1602-I2C.fzpz0.01 MB