Allegro ACS758 Current Sensor with LCD and Overcurrent Protection for Arduino

Allegro ACS758 Current Sensor with LCD and Overcurrent Protection for Arduino

In this tutorial, we will learn how to use the Allegro ACS758 current sensor with an LCD to display current readings and implement overcurrent protection. This setup allows us to monitor current and disconnect the load automatically if it exceeds a predefined limit. The project combines both hardware and software components to create a functional current monitoring system.

By following this guide, you will be able to wire the components correctly and understand the programming logic behind the code. For a more visual explanation, be sure to check out the associated video (in video at 00:00).

Hardware Explained

The key components in this project include the Allegro ACS758 current sensor, an LCD1602 display with an I2C interface, and an Arduino board. The ACS758 sensor measures current flowing through it and outputs a voltage proportional to the current. The LCD1602 displays the current readings and status messages, while the Arduino processes the data and controls the relay for overcurrent protection.

The ACS758 sensor operates on a principle called Hall effect sensing, which allows it to measure current without direct electrical contact. The output voltage changes based on the amount of current passing through, providing a safe and efficient way to monitor electrical loads.

Datasheet Details

Manufacturer Allegro MicroSystems
Part number ACS758
Logic/IO voltage 3.3V / 5V
Supply voltage 5V
Output current (per channel) 200A max
Peak current (per channel) 200A
PWM frequency guidance N/A
Input logic thresholds 0.5 x VCC (bidirectional)
Voltage drop / RDS(on) / saturation N/A
Thermal limits 150°C
Package PCB mount
Notes / variants Multiple models available for different current ranges

 

  • Ensure proper heat sinking if operating close to maximum ratings.
  • Use decoupling capacitors to stabilize power supply voltage.
  • Verify that the relay used can handle the maximum load current.
  • Be cautious with wiring to avoid short circuits.
  • Common pitfalls include floating inputs; ensure all connections are secure.
  • Monitor for overheating of the sensor during prolonged use.

Components needed

  • ACS758 current sensor
  • 12V  100A relay
  • LCD1602 with I2C (4 wires)
  • 2N2222 or 2N3904 Transistor
  • 1k ohm 1/4W or any power resistor
  • Power Supply for realy
  • Power supply for your load
  • Breadboard
  • Jumper wires

Wiring Instructions

Arduino wiring for ACS758 current sensor with LCD and protection relay
Arduino wiring for ACS758 current sensor with LCD and protection relay

To wire the Allegro ACS758 current sensor and LCD1602 display, start by connecting the ACS758 sensor. Connect the VCC pin of the sensor to the 5V pin on the Arduino. The GND pin should be connected to a ground pin on the Arduino. The S (signal) pin of the sensor should be connected to the analog input pin A0 on the Arduino.

Next, for the LCD1602, connect the VCC pin to the 5V pin on the Arduino and the GND pin to the ground. The SDA pin of the LCD should connect to the A4 pin (SDA) on the Arduino, while the SCL pin should connect to the A5 pin (SCL) on the Arduino. Finally, connect a relay module to digital pin 2 for controlling the load based on the current readings.

Code Examples & Walkthrough

In the Arduino code, we start by defining key identifiers like VIN, which represents the analog input pin connected to the ACS758 sensor. The relayPin is set for the relay control, while maxCurrent defines the threshold for overcurrent protection.

#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const int relayPin = 2; // set a digital pin for relay
const float maxCurrent = 15.00; // set maximum Current

The setup() function initializes the LCD and sets up the relay pin as an output. It also prints a welcome message on the LCD, informing the user about the current sensor being used.

void setup() {
    pinMode(relayPin, OUTPUT); // set relayPin as output
    Serial.begin(9600); // initialize serial monitor
    lcd.begin(); // initialize the LCD
    lcd.backlight(); // Turn on the blacklight
    lcd.print("Robojax");
}

In the loop() function, we continuously read the voltage from the sensor and calculate the current. If the current exceeds the maximum limit, the relay is activated to disconnect the load. This logic ensures that the system protects itself from overcurrent conditions.

void loop() {
  float voltage_raw = (5.0 / 1023.0) * analogRead(VIN); // Read the voltage from sensor
  float current = voltage / FACTOR; // Calculate current
  if (current >= minCurrent) {
    if (current <= maxCurrent) {
      digitalWrite(relayPin, LOW); // turn the relay OFF to allow current
    } else {
      digitalWrite(relayPin, HIGH); // turn the relay ON to disconnect current
    }
  }
}

Demonstration / What to Expect

Once everything is wired and the code is uploaded, the LCD will display the current readings. If the current exceeds the defined maxCurrent, the relay will activate, disconnecting the load. You can test this by gradually increasing the load current and observing the changes on the LCD and in the serial monitor. Make sure to avoid reversed polarity connections, as this can damage the components (in video at 10:15).

Images

LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
ACS758-sensor-0
ACS758-sensor-0
ACS758-sensor-1
ACS758-sensor-1
ACS758-sensor-3
ACS758-sensor-3
ACS758-sensor-4
ACS758-sensor-4
Arduino wiring for ACS758 current sensor with LCD and protection relay
Arduino wiring for ACS758 current sensor with LCD and protection relay
111-Arduino Code for Allegro ACS758 Current Sensor with LCD160
Language: C++
Copied!

Things you might need

Files📁

Datasheet (pdf)