Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

How to measure current using Arduino and ACS712 Current Sensor

September 11, 2019 By EG Projects

In this tutorial, I am going to measure DC current using Acs712 Hall Effect-Based Linear Current Sensor and arduino uno. Acs712 can measure current precisely and accurately if properly managed. I have gone through various blogs on internet about interfacing acs712 current sensor with arduino and other microcontrollers. I found that all of them are measuring current with formulas(derived for acs712 current sensor) which are not precise. So i decided to write a tutorial on acs712 current sensor and put forward a practical example with circuit and code. In this tutorial i will define the best method and precise formula generation for measuring dc current with acs712 current sensor. I will define each and every step of code and circuit thoroughly and deeply with logic. Project code is open source and you can download and modify it according to your needs.
Acs712 current sensor can measure both direct and alternating current. For this post/tutorial/project I am going to measure only dc current. Formula which i derived and explained in the tutorial is only for direct current measurement. You can not use the below formula to measure alternating current with acs712 hall effect current sensor. 

About Acs712

ACS712 is a Hall Effect-Based Linear Current Sensor it can measure both DC(Direct Current) and AC(Alternating Current). The sensor chip is made by Allegro www.allegromicro.com. Pin out and Pin description of the chip is below. 

Picture

IP+ & IP-
Connect the sensor in series to the system whose current you want to measure. Cut the circuit wire and connect one end of wire to IP+ and other to IP-. Recall the high school lectures, current can be measured only in series. So don’t connect the sensor in parallel You may damage it by connecting it in parallel.   
VIout
Viout is the voltage out pin. ACS712 outputs an analog signal in correspond to any variation across the IP+ and IP- pins or in other words it outputs analog voltage on VIOUT pin if their is any variation in the current.

Quiescent output voltage (VIOUT(Q)). The output of the device when the primary current is zero. For a uni-polar supply voltage,it nominally remains at VCC ⁄ 2. Thus, VCC = 5 V translates into VIOUT(Q) = 2.5 V. Variation in VIOUT(Q) can be attributed to the resolution of the Acs712. If the Acs712 is working on 5v(Vcc=5v) and their is no current flowing from input the Viout will be 2.5v. 2.5v is the base voltage at input of 5v, now any change in the input current will bring change in the output voltage. Viout decreases when current start flowing through the acs712 pins.

Acs712 is available in market in three ratings.

  • ACS712ELCTR-05B-T
  • ACS712ELCTR-20A-T
  • ACS712ELCTR-30A-T

Picture

  • ACS712ELCTR-05B-T can measure 5 to -5 Ampere current. Where 185mV change in Output voltage from initial state represents 1-Ampere change in Input current. 
  • ACS712ELCTR-20A-T can measure 20 to -20 Ampere current. Where 100mV change in Output voltage from initial state represents 1-Ampere change in Input current. 
  • ACS712ELCTR-30A-T can measure 30 to -30 Ampere current. Where 66mV change in Output voltage from initial state represents 1-Ampere change in Input current. 

​

Acs712 Dc current measurement formula

Current = (AcsOffset – (Arduino measured analog reading)) / Sensitivity

  • AcsOffset is normal voltage output at Viout pin when no current is flowing through the circuit.
  • Arduino measured analog reading is the analog signal value read and converted to actual voltage from the analog channel to which acs712 output is connected.
  • Sensitivity is Acs712 change in current representing 1 Ampere. For all the acs712 versions it is given in the above picture.

Arduino acs712 current sensor

Reassembled acs712 current sensor boards are available in market. They are easy to install in circuit and connections are pretty straight forward. They have three pins. Two are power pins vcc and gnd. The third one is output pin. A 2 pole connector is also present to insert the wire of device whose current is needed to be measured. A typical arduino acs712 current circuit board looks like the one given below.

Picture

Now i am going to interface the arduino acs712 current sensor with arduino uno. I will interface all the different current rated boards one by one with arduino uno.

ACS712ELCTR-05B-T Interfacing with Arduino Uno

Check out the test that i performed with Acs712-05B -5 to +5 Amperes and arduino uno. Measured current is displayed on the 16×2 lcd. It measures current precisely. Test code and results are summarized in an another post link is below.

Measuring Dc current with arduino using acs712 current sensor and 16×2 lcd

ACS712ELCTR-20A-T Interfacing with Arduino Uno

Project Code

 

Download the project code from the links given at the bottom of the Post.

 

ACS712ELCTR-30A-T Interfacing with Arduino Uno

Arduino direct current measurement – Project circuit diagram

Arduino uno interfacing with acs712 current sensor circuit diagram is given below. The circuit is universal and all the above three codes for different versions of acs712 current sensor can work with the same circuit given below. You just need to insert your acs712 current sensor in circuit and download its corresponding code(given in the post) in arduino uno, rest of the connections are same for all the different acs712 rated current sensors.  

Acs712 with Arduino Uno -Circuit Diagram

Acs712 with Arduino Uno -Circuit Diagram
After making circuit and downloading the code in arduino uno. Open the arduino serial monitor from arduino ide. As soon as you open the arduino serial monitor you will see the measured current value displaying in the arduino ide serial monitor window. If you did’t see any thing in arduino serial monitor check for all the connections. Go through all the possible physical connections. If you see broken alphabets in arduino serial monitor window then set the baud rate of arduino serial monitor window to 9600 bps in order to see the proper data characters and numbers.  

Download Codes

Related Articles Read More >

How to monitor pH levels in an aquarium using Arduino
TV remote hack using Arduino and IR sensor
Gesture sensor using Arduino
How to build a metal detector using an inductive proximity sensor with Arduino

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Getting Started with the ESPlorer IDE
  • SENDING TEXT MESSAGE USING ESP8266
  • CONNECTION BETWEEN TWO ESP8266
  • ESP8266 WIFI HOTSPOT
  • HOME AUTOMATION USING ESP8266
  • Open WiFi Scanner using Esp8266

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • How to monitor pH levels in an aquarium using Arduino
  • What are the different types of fingerprint scanners?
  • TV remote hack using Arduino and IR sensor
  • Gesture sensor using Arduino
  • Diodes adds to its family of voltage-level shifters

RSS EDABOARD.com Discussions

  • Self resonant frequency of MLCC capacitor
  • Force sensing resistor (FSR) nonlinearity?
  • Vivado simulation variables
  • Connecting RF Tx/Rx Modules to SMA via PCB and header pin
  • Help to identify circuit took from a mixer

RSS Electro-Tech-Online.com Discussions

  • Help with circuit design
  • How are you managing with the Covid-19 pandemic?
  • Does anyone have a paper tape punch for sale, to suit 1" tape?
  • Would someone be interested in a raspberry pi?
  • Need to add a question to a thread.
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering