Sunday, June 3, 2018

Arduino DC current & voltage meter with LCD

Arduino DC voltage and current meter
Max. voltage= 50v
Max. current = 30A (There are 3 types of ACS712 sensor, 5A, 20A, 30A)

Parts list:
Arduino board
LCD 16x2
Current sensor ACS712 (There are 3 types of ACS712 sensor, 5A, 20A, 30A)
Connecting wire
Potentiometer 10K
Resistor 10K
Resistor 100K
Resistor 220 ohm
Breadboard

Wiring:

Arduino DC current voltage meter with LCD


Video: 
Please subscribe to my YouTube channel here: 
https://www.youtube.com/c/EngMousaalkaabi?sub_confirmation=1




Code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

//Measuring Current Using ACS712 (30A)

const int analogIn = 0; //Connect current sensor with A0 of Arduino
const int analogIn2 = 1; //Connect voltage sensor with A1 of Arduino
int mVperAmp = 66; // use 100 for 20A Module and 185 for 5A Module
int RawValue= 0;
int VolValue= 0;
int ACSoffset = 2500;
double Voltage = 0; //voltage measuring
double Voltage2 = 0; //voltage measuring
double Amps = 0;// Current measuring
double Volt = 0;// voltage 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(16, 2);  //LCD order
 
}

void loop() //method to run the source code repeatedly
{

 RawValue = analogRead(analogIn);//reading the value from the analog pin
 Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
 Amps = ((Voltage - ACSoffset) / mVperAmp);
 VolValue = analogRead(analogIn2);//reading the value from the analog pin
 Voltage2 = (VolValue / 1023.0) * 5000; // Gets you mV
 Volt = ((Voltage2*11)/1000);
 lcd.clear();//clears the display of LCD

 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(0,0);
 lcd.print("I = ");
 lcd.setCursor(4,0);
 lcd.print(Amps+0.11); //add 0.11 to calibration and show us 0.00V when no load connected
 lcd.setCursor(10,0);
 lcd.print("A"); //unit for the current to be measured
 lcd.setCursor(0,1);
 lcd.print("V = ");
 lcd.setCursor(4,1);
 lcd.print(Volt);
 lcd.setCursor(9,1);
 lcd.print("V");
 delay(1000);
}