Arduino Current Sensor

Dive into the realm of electrical monitoring and unleash your creativity with Robotshapers in our exciting blog, Arduino Current Sensor. Discover the incredible potential of integrating a current sensor like ACS712 with the versatile Arduino microcontroller board. Witness the magic as Arduino reads the analog voltage output from the sensor, enabling precise measurement and monitoring of current levels in various applications.

Arduino Current Sensor

Arduino Current Sensor is about using a current sensor like ACS712 with Arduino microcontroller board. Arduino boards can be interfaced with current meters to measure and monitor current levels in a variety of applications. The Microcontroller can read the analog voltage output from the sensor by connecting the output of the current sensor to one of the analog input pins on the Arduino board. Given the known sensitivity of the current sensor, the Arduino can convert the analog voltage reading to the current value. This function offers many possibilities for tasks and applications.
For example, Arduino-based sensors can now be designed to track energy usage in real time, allowing users to review and optimize their energy usage. The Arduino can also be programmed to trigger an alarm or perform a special function when the current level exceeds a certain threshold, providing additional safety and control. Moreover, by combining the digital and analog capabilities of the Arduino, the current sensor can be integrated into many tasks related to the control of motors, robots, building automation or energy management. Arduino's versatility and community support make it a popular choice for integrating existing functionality into many DIY electronics projects.

Components required:

  1. Arduino Uno
  2. 16X2 LCD 
  3. ACS712 Current Sensor
  4. Lamp or other load
  5. 10K Variable Resistor
  6. 5v DC Power Supply

ACS712 Current Sensor:

ACS712 is a popular current sensor widely used to measure and monitor current in many applications. It is an integrated circuit (IC) sensor that provides a simple way to measure AC and DC current. Here are some details about the ACS712 current sensor:


 
Working Principle: The ACS712 works according to the Hall Effect principle. It uses a Hall effect sensor to measure the magnetic field produced by current flowing through a conductor. This magnetic field is converted into an analog voltage proportional to current that can be measured by a microcontroller or other monitoring device.
Type: ACS712 has different models according to the current rating. The most commonly used models are the ACS712-05A, ACS712-20A and ACS712-30A, which can measure current up to 5A, 20A and 30A respectively. There are now other versions with higher ratings.
Operating Voltage: The ACS712 is designed to operate from a supply voltage of 4.5 V to 5 V.
5V makes it compatible with most microcontrollers and digital systems.
Output: The output of the ACS712 is an analog voltage linearly proportional to the measured current. The output voltage has a certain precision that is specified in millivolts per ampere (mV/A). For example, the sensitivity of the ACS712-05A is 185 mV/A, which means that the output voltage increases by 185 millivolts for every amp of current flowing through the sensor.
interface: ACS712 has three terminals: Vcc (power supply), GND (ground) and OUT (output).
When connecting Vcc and GND to the power supply, the OUT terminal provides an analog voltage output representing the measured current.
Accuracy and calibration: The ACS712 has good current measurement, usually ±1.5% of the measured current. However, it is worth noting that calibration may be needed for optimum results as individual sensors may differ slightly.
Applications: The ACS712 is widely used in many applications that require current measurement and monitoring.
Some applications include electronics, battery chargers, motor control systems, energy monitoring systems, robotics and industrial automation.

Circuit diagram:

Code:

#include 
LiquidCrystal lcd(2,3,4,5,6,7);
const int sensorIn = A0;      // pin where the OUT pin from sensor is connected on Arduino
int mVperAmp = 185;           // this the 5A version of the ACS712 -use 100 for 20A Module and 66 for 30A Module
int Watt = 0;
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
void setup() {
  Serial.begin (9600); 
  Serial.println ("ACS712 current sensor"); 
  lcd.begin(16, 2);

 lcd.setCursor(0,0);
  lcd.print("ROBOTSHAPERS");
   lcd.setCursor(0,0);
   delay(1500);
   lcd.setCursor(0,1);
   delay(1500);
  lcd.print("CURRENT SENSOR");
  delay(1500);
  lcd.clear();   
}
 
void loop() {
 
  Serial.println ("");
  
  Voltage = getVPP();
  VRMS = (Voltage/2.0) *0.707;   //root 2 is 0.707
  AmpsRMS = (VRMS * 1000)/mVperAmp;
  Serial.print(AmpsRMS);
  Serial.print(" Amps RMS  ---  ");
  Watt = (AmpsRMS*240/1.3);      // 1.3 is an empirical calibration factor
  Serial.print(Watt);
  Serial.println(" W");
  lcd.setCursor(0,0);
  lcd.print("Ci-");
    lcd.print(AmpsRMS);
    lcd.setCursor(8,0);
    lcd.setCursor(0,1);
  lcd.print("W:");
    lcd.print(AmpsRMS);
    lcd.setCursor(8,1);
}
float getVPP()
{
  float result;
  int readValue;                // value read from the sensor
  int maxValue = 0;             // store max value here
  int minValue = 1024;          // store min value here
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the minimum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;
 }

Applications:

  1. Current sensors (like the ACS712) are used in many ways. They are used in power monitoring systems to measure and monitor current consumption. Sensors are now also used in motor control applications to provide feedback for motor control and guidance.
  2. They play an important role in energy management, from current measurement to load measurement to energy consumption. In addition, current sensors are used in renewable energy systems such as solar and wind energy to monitor current production and increase efficiency.
  3. Its compact size, precision and versatility make it an essential component in many industrial, commercial and residential applications.

Best projects in Bhilai, Chhattisgarh, India. Contact : 7067150002