pcbway




Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduinoHello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge with all of you guys about DC Current Sensor ACS712 Arduino Interfacing. First of all, I would like to tell you about importance of current sensing/measuring. Sensing the amount of current passing through any circuit can be useful in a lot of applications. For example, in low power consuming equipment, current sensing will be helpful to understand the system’s impact on its battery life. The current sensing can also be used to make the decisions regarding safety in over current protection circuits.

Simply, we can say that sensing and controlling the flow of the current through the circuits is now a fundamental requirement e.g. over current protection circuits, battery chargers, watt meters, power supplies etc.

DC Current Sensor ACS712 Arduino Interfacing

Basically, there are two types of current senors AC and DC. But, in the tutorial,I am going to do the DC Current Sensor ACS712 Arduino Interfacing, and we will learn about the sensing of the DC current. I will use ACS712 DC current sensor for sensing the DC current.

  • You can download the complete Arduino source code there.
  • Download .rar file, extract it and upload code in your Arduino board:

Arduino Source Code

Components Required

Here I am going to tell you about the components necessary for this projects. The list of all the components is given below.

  • Arduino UNO
  • DC Current Sensor (ACS712)
  • DC Load
  • Wero Board
  • Soldering Iron
  • Soldering Gum
  • Jumper wires
  • Power Supply (12V)
  • 20 x 4 LCD
Description of the Components used

In this section of the tutorial Interfacing DC Current Sensor with Arduino, I will explain the reasons why I have used the specific components for this project.
Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • Arduino UNO acts as the back bone of the project. It manipulates the whole source code uploaded to the board, prints the desired data on the serial monitor and also prints the executed commands on the LCD. You can use the same code of other Arduino boards as well i.e. Arduino Nano, Arduino Pro Mini etc.

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • Power Supply of 12V is used to turn the entire system ON. Because, we can not test and verify our system until we have not switched it ON. Power supply used for this project is shown in the figure. I have used this 9A Battery (I have this available) but you can use 1.5A small battery as well. Battery selection depends on your projects’ power consumption.

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • LCD is used to display the digital values of the data which has been printed on the serial monitor of the Arduino software i.e all the executed commands will be printed on the LCD as well. The LCD which I have used for this is shown in the figure.

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • Jumper Wires are used to make the connections of the all the components, in order to make the complete circuit with proper working. Jumper wires are shown in the figure. There are 3 types of Jumper wires available: Male to Male, Male to Female & Female to Female.

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • ACS712 is used to sense the Direct Current (DC) flowing through the any circuit. The DC current sensor used is shown in the figure.




Flow Chart

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • Here, I would like to explain the entire algorithm with the help of a flow chart for DC Current Sensor ACS712 Arduino Interfacing.
  • The flow chart for this project DC Current Sensor ACS712 Arduino Interfacing is shown in the figure.
  • First of all, I have initialized the Serial Port.
  • After that we are reading the value from our current sensor ACS712.
  • Then data will be displayed on the LCD and Serial Monitor.
Circuit Diagram
  • The complete wiring diagram for this project is shown in the figure below.

Interfacing DC current sensor with arduino, DC current sensor with arduino, Interfacing current sensor in arduino, DC current sensor with arduino, DC current sensor using arduino, How to interface DC ccurrent sensor with arduino

  • You can run this project properly, by making the circuit first, identical to the circuit diagram shown in the figure above.
  • The digital pin 0 of the Arduino UNO will help us in reading the data from the sensor.
  • The other two pins of the sensor are connected to the supply of 5V and ground respectively as you can see from the above figure.
Source Code Description
  • The source code for this project DC Current Sensor ACS712 Arduino Interfacing is given below.
  • You have to just copy and paste the code given below in your Arduino software after properly interfacing DHT11 with the Arduino.
  • After uploading the code onto your Arduino board you will be able to observe the humidity and temperature and humidity level on serial monitor.



// include the library code:
#include <LiquidCrystal.h> //library for LCD

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

//Measuring Current Using ACS712

const int analogIn = 0; //Connect current sensor with A0 of Arduino
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500; 
double Voltage = 0; //voltage measuring
double Amps = 0;// Current measuring

void setup() {
  //baud rate
  Serial.begin(9600);//baud rate at which arduino communicates with Laptop/PC
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);  //LCD order
  // Print a message to the LCD.
  lcd.setCursor(1,1);//Setting cursor on LCD
  lcd.print("www.TheEngineering");//Prints on the LCD
  lcd.setCursor(4,2);
  lcd.print("Projects.com");
  delay(3000);//time delay for 3 sec
  lcd.clear();//clearing the LCD display
  lcd.display();//Turning on the display again
  lcd.setCursor(1,0);//setting LCD cursor
  lcd.print("Reading Values from");//prints on LCD
  lcd.setCursor(1,1);
  lcd.print("DC Current Sensor");
  lcd.setCursor(5,2);
  lcd.print("ACS 712");
  delay(2000);//delay for 2 sec
}

void loop() //method to run the source code repeatedly
{
 
 RawValue = analogRead(analogIn);//reading the value from the analog pin
 Voltage = (RawValue / 1024.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 
//Prints on the serial port
 Serial.print("Raw Value = " ); // prints on the serial monitor
 Serial.print(RawValue); //prints the results on the serial monitor
 
 lcd.clear();//clears the display of LCD
 delay(1000);//delay of 1 sec
 lcd.display();
 lcd.setCursor(1,0);
 lcd.print("Raw Value = ");
 lcd.setCursor(13,0);
 lcd.print(RawValue);
 
 Serial.print("\t mV = "); // shows the voltage measured 
 Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
 
 lcd.setCursor(1,1);
 lcd.print("Voltage = ");
 lcd.setCursor(11,1);
 lcd.print(Voltage,3);
 lcd.setCursor(17,1);
 lcd.print("mV");//Unit for the voltages to be measured
 
 Serial.print("\t Amps = "); // shows the voltage measured 
 Serial.println(Amps,3);// the '3' after voltage allows you to display 3 digits after decimal point
 
 lcd.setCursor(1,2);
 lcd.print("Current = ");
 lcd.setCursor(11,2);
 lcd.print(Amps,3);
 lcd.setCursor(16,2);
 lcd.print("A"); //unit for the current to be measured
 delay(2500); delay of 2.5 sec
}
  • I am going to explain you that how this code is working!
  • Then I have defined the library for LCD.
  • I have defined the pin at which DC current sensor is attached with the Arduino board.
  • Then I have defined the Arduino pins at which the LCD is interfaced.
  • Then by opening the serial port I have started to print the level of temperature and humidity on the serial monitor as well as on the 20×4 LCD.
  • At the end, I have added the delay of few seconds so that the speed of the data to be printed on the serial monitor can be reduced to some extent in order to observe properly.
  • This was the brief description of the source code.

This is all from the tutorial DC Current Sensor ACS712 Arduino Interfacing. I hope you all enjoyed this tutorial. If you face any sort of problem you can ask me anytime in comments without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino further in my later tutorials. Till then, Take care 🙂

5 Comments

  1. Hi. I connected the acs712 module to Arduino like the figure and tried your code, but it shows the module between negative 28 and 30 amps …… I do not know what to do.

  2. Hi, In the source code description you suddenly switch to DHT11 and talk about Humidity and Temperature. I suppose it must be Voltage and Current? You do not show how the LCD is interfaced to the Arduino. You mention pins 8-13 on the Arduino. How is the pins connected to the LCD?
    Thank You

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.