ESP32 Projects

Measure AC current by interfacing ACS712 sensor with ESP32

Learn how to measure AC and DC currents with the help of ACS712 sensor by connecting it with ESP32 Microcontroller


In this Project let learn how to interface an ACS712 current sensor module with ESP32 microcontroller board to measure the AC current of the load and display the current in Amperes and power consumption in Wattage of it on 16X2 LCD display module.

So, by using this project you can build a power monitor or AC power consumption monitoring system. You can also implement IOT to get the data over the internet or cloud. This ACS712 sensor comes in 3 version, which you can choose according to your need. 5A, 20A and 30A versions of ACS712 are available in the market.

Related Project: Measure AC current using ACS712 sensor with Arduino

Required components:

Product NameQuantityamazon logoamazon logo india
ESP32 Microcontroller1
ACS712 current sensor module1
LCD 16X2 module with or without I2C adapter1
5V power supply (Micro USB or External).1
Few Connecting Wires
You can buy the required components from the given best buy links. We choose the components according to value for money.

ACS712 current sensor module:

ACS712 IC uses hall effect principle to measure the current which is developed by Allegro Micro SystemsACS712 IC consists of a low-offset, precise and linear Hall sensor circuit with a copper conduction path at the surface of the die.

ACS712 Current sensor module application circuit

ACS712 modules has 3 versions with different sensitivities.

You need to choose the right module according to your requirement, as higher the capacity of the sensor lower the accuracy.

5A Module 20A Module 30A Module
185mV/Amp 100mV/Amp 66mV per Amp

From the above table you can see the higher the measuring capacity the sensitivity of measuring the Milli Volts per Amp decreases. To measure smaller currents using smaller range module gives more accurate results than using high range module.

For more details about the ACS712, Please refer ACS712 datasheet : here

ACS712 current sensor module Specifications

  • Measures both AC and DC current
  • Very small in size
  • Available in 5A, 20A and 30A modules
  • 66 to 185 mV/A output sensitivity
  • Outputs analog voltage, so its easy to connect with most of the Microcontrollers.

For Principle, pinout diagrams and Working of ACS712 module in detail please refer our previous article: ACS712 Principle, working and pinout.

Interfacing ACS712 Current sensor with ESP32 to display result over LCD display.

ACS712 current sensor with ESP32 circuit diagram

As you can see from the above circuit diagram the LCD display and ACS 712 current sensor VCC and GND pins are powered through the VIN and GND pins of ESP32. If you are not getting 5volts voltage from the VIN pin of ESP32 connect an external 5V power supply to ACS712 module as it requires exact 5volts for calculations.

The Data pin OUT of ACS712 is connected to Analog pin D34 of ESP32. The I2C communication pins SDA and SCL pins of LCD display are connected to D21 and D22 pins respectively.

If you want to use an LCD display with out I2c refer this article: Interfacing 16X2 LCD Module with ESP32 without I2C

After connecting everything its time to upload the program code.

Connect the AC load to ACS712 module only after uploading the code to ESP32, as AC current has high voltage which can electric shock us.

Program code:

Connect the ESP32 microcontroller board to the PC where Arduino IDE is installed through USB cable. Choose the correct port and board as ESP32 Wrover Module  from Tools menu and install the required libraries from the Library manager or download from the below links and extract them in Arduino Libraries folder.

Required Libraries:

  • Download LiquidCrystal_I2C – Link

Next copy the below code and paste it in IDE workspace and press upload button. That’s it the code will be uploaded.

After uploading the code open serial monitor at baud rate 9600 to check how the sensor is working. Serial monitor shows results as shown in the below output screenshot.

ACS712 current sensor with ESP32 output on serial monitor

Every ACS712 current sensor has some level of error, here I am using 30A version so the sensitivity is low, in the result there are some fluctuations.

Calibrating ACS712 current sensor:

At no load situation open serial monitor and check weither the amp values are near to Zero. If the values are not near to zero, and if the values are positive then substract the error value from the line 36, if the values are negative then add the error value till you reach the near zero level.

Calibration is important to get the nearly accurate results, You can also calibrate with some known current loads and correct the error through the code.


When no load is connected the LCD display outputs as below:

ACS712 current sensor with ESP32 lcd with noload

When a small load is connected the LCD display outputs as below image:

ACS712 current sensor with ESP32 lcd with load connected

If you like this project please subscribe to our YouTube Channel “Circuit Schools to encourage us to publish more interesting projects. If you have any doubts write to us from below comment section.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles


  1. With the center voltage ( zero amps ) at 2.5v (half of the 5v input) calculations show that at full current on any of the sensors
    you are at or over the input voltage of the esp32 adc input, or am I wrong??
    5a = ( .185/a * 5a) = (.925v + 2.5V ) = 3.425v
    20a = (.100/a * 20a) = (2v + 2.5v) = 4.5v
    30a = (.066/a * 30a) = (1.98v + 2.5v) = 4.48v

    Full swing of the sensor output can be 5v with 0v being the negative current rating, 2.5v being 0a, and full rating would be 5v.
    Wouldn’t you need a divider on the input to be safe using the esp32?
    Inquiring as I am in the process of setting up an esp32 with 3*asc712 sensors to monitor a small solar system.

    1. If you are going to measure +5a then you would want a resistor divider to limit the output of the acs712 to 3.3v. However, if you are only measuring DC amperes then wire the ACS712 so that the current is negative and therefore the output voltage will max out at ~2.5v. Do the math to compensate.

Leave a Reply

Your email address will not be published.

Back to top button