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

Overview:

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 Microcontroller1https://amzn.to/3s0Sut6https://amzn.to/3Kw2np2
ACS712 current sensor module1https://amzn.to/3v4ok8yhttps://amzn.to/3EaJ9Dz
LCD 16X2 module with or without I2C adapter1https://amzn.to/3BNSRuphttps://amzn.to/363ki7F
5V power supply (Micro USB or External).1https://amzn.to/3s1a8g3https://amzn.to/364yInH
Few Connecting Wireshttps://amzn.to/3H2BV4ehttps://amzn.to/3J0WVu2
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.

Outputs:

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

Leave a Reply

Your email address will not be published.

Back to top button