Arduino Wattmeter that Measure Voltage, Current and Power Consumption. How to?

Programming, Tutorial, Coding, New Design, and/or any project for your Arduino and Raspberry Pi can post your topic /suggestion here.
User avatar
Magdalo
Posts: 12
Joined: Fri Mar 17, 2017 2:17 pm

Arduino Wattmeter that Measure Voltage, Current and Power Consumption. How to?

Wed Sep 05, 2018 7:21 pm

The complete circuit diagram of the arduino wattmeter project.
Arduino-Wattmeter-Circuit-Diagram.png
Arduino-Wattmeter-Circuit-Diagram.png (74.95 KiB) Viewed 1386 times
Circuit Diagram

Building your own meters not only bring down the cost of testing, but also gives us room to ease the process of testing. Like, a wattmeter built using Arduino can easily be tweaked to monitor the results on Serial monitor and plot a graph on Serial plotter or add an SD card to automatically log the values of voltage, current and power at pre-defined intervals. Sounds interesting right!? So let’s get started...

Materials Required
- Arduino Nano
- LM358 Op-Amp
- 7805 Voltage regulator
- 16*2 LCD display
- 0.22 ohm 2 Watt shunt resistor
- 10k Trimmer pot
- 10k,20k,2.2k,1k Resistors
- 0.1uF Capacitors
- Test Load
- breadboard
- Soldering kit (optional)

The circuit is designed to fit into systems operating between 0-24V with a current range of 0-1A keeping in mind the specification of a Solar PV. But you can easily extend the range once you understand the working of the circuit. The underlying principle behind the circuit is to measure the voltage across the load and current through it to calculate the power consumes by it. All the measured values will be displayed in a 16*2 Alphanumeric LCD.

Programming the Arduino

As all programs we begin with, defining the pins that we have used. In out project the A3 and A4 pin is used to measure voltage and current respectively and the digital pins 3,4,8,9,10 and 11 is used for interfacing the LCD with Arduino

Code: Select all

int Read_Voltage  = A3;
int Read_Current  = A4;
const int rs = 3, en = 4, d4 = 8, d5 = 9, d6 = 10, d7 = 11; //Mention the pin number for LCD connection
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
We also have included a header file called liquid crystal to interface the LCD with Arduino. Then inside the setup function we initialise the LCD display and display an intro text as “Arduino Wattmeter” and wait for two seconds before clearing it. The code for the same is shown below.

Code: Select all

void setup() {
  lcd.begin(16, 2); //Initialise 16*2 LCD
  lcd.print(" Arduino Wattmeter"); //Intro Message line 1
  lcd.setCursor(0, 1);
  lcd.print("-Circuitdigest"); //Intro Message line 2
  delay(2000);
  lcd.clear();
}
Inside the main loop function, we use the analog read function to read the voltage value from the pin A3 and A4. As we know the Arduino ADC output value from 0-1203 since it has a 10-bit ADC. This value has to be then converted to 0-5V which can be done by multiplying with (5/1023). Then again earlier in the hardware we have mapped the actual value of voltage from 0-24V to 0-5V and the actual value of current form 0-1A to 0-5V. So now we have to use a multiplier to revert these values back to actual value. This can be done by multiplying it with a multiplier value. The value of the multiplier can either be calculated theoretically using the formulae provided in hardware section or if you have a known set of voltage and current values you can calculate it practically. I have followed the latter option because it tends to be more accurate in real time. So here the value of multipliers is 6.46 and 0.239. Hence the code looks like below

Code: Select all

float Voltage_Value = analogRead(Read_Voltage);
 float Current_Value = analogRead(Read_Current);

 Voltage_Value = Voltage_Value * (5.0/1023.0) * 6.46;
 Current_Value = Current_Value * (5.0/1023.0) * 0.239;
How to measure with more accuracy?

The above way of calculating the value of Actual Voltage and current will work just fine. But suffers from one drawback, that is the relationship between the measured ADC voltage and actual voltage will not be linear hence a single multiplier will not give very accurate results, the same applied for current as well.

So to improve the accuracy we can plot of set of measured ADC values with actual vales using a known set of values and then use that data to plot a graph and derive the multiplier equation using the linear regression method.

Finally, once we have calculated the value of actual voltage and actual current through the load, we can calculate the Power using the formulae (P=V*I). Then we display all the three values on the LCD display using the code below.
lcd.setCursor(0, 0);
lcd.print("V="); lcd.print(Voltage_Value);
lcd.print(" ");
lcd.print("I=");lcd.print(Current_Value);

float Power_Value = Voltage_Value * Current_Value;

lcd.setCursor(0, 1);
lcd.print("Power="); lcd.print(Power_Value);
This Arduino based Wattmeter project has many more upgrades that can be added to increase the performance to auto data logging, plotting graph, notifying over voltage or over current situations etc. So stay curious and let me know what you would use this for.

Complete Code:

Code: Select all

/*
 * Wattmeter for Solar PV using Arduino
 * Dated: 05-09-2018
 * Website: https://dohangout.com
 * 
 * Power LCD and circuitry from the +5V pin of Arduino whcih is powered via 7805
 * LCD RS -> pin 2
 * LCD EN -> pin 3
 * LCD D4 -> pin 8
 * LCD D5 -> pin 9
 * LCD D6 -> pin 10
 * LCD D7 -> pin 11
 * Potetnital divider to measure voltage -> A3
 * Op-Amp output to measure current -> A4
 */

 

#include <LiquidCrystal.h>  //Default Arduino LCD Librarey is included 

int Read_Voltage  = A3;
int Read_Current  = A4;
const int rs = 3, en = 4, d4 = 8, d5 = 9, d6 = 10, d7 = 11; //Mention the pin number for LCD connection
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  lcd.begin(16, 2); //Initialise 16*2 LCD

  lcd.print(" Arduino Wattmeter"); //Intro Message line 1
  lcd.setCursor(0, 1);
  lcd.print("  With Arduino  "); //Intro Message line 2

  delay(2000);
  lcd.clear();

}

void loop() {
 
 float Voltage_Value = analogRead(Read_Voltage);
 float Current_Value = analogRead(Read_Current);

 Voltage_Value = Voltage_Value * (5.0/1023.0) * 6.46;
 Current_Value = Current_Value * (5.0/1023.0) * 0.239;

 lcd.setCursor(0, 0);
 lcd.print("V="); lcd.print(Voltage_Value); 
 lcd.print("  "); 
 lcd.print("I=");lcd.print(Current_Value); 

 float Power_Value = Voltage_Value * Current_Value;

 lcd.setCursor(0, 1);
 lcd.print("Power="); lcd.print(Power_Value); 

 
delay(200);
}
Arduino-Wattmeter-in-action.jpg
Arduino-Wattmeter-in-action.jpg (48.34 KiB) Viewed 1386 times


User avatar
Princess Anna
Posts: 23
Joined: Fri Feb 03, 2017 2:40 pm

Re: Arduino Wattmeter that Measure Voltage, Current and Power Consumption. How to?

Thu Sep 06, 2018 3:41 pm

Question from readers on Facebook:
# how you measure current without current reading modules?

Answers:

>Deb: Use a low ohmage resistor, like 0.1 Ohms, in series with the load and measure the voltage across it.

> Sarah Roberta Wilson Exactly Deb! :-) The multiplication is of course proportional. For instance, 1A will render 100mV. If you're using this method in a power supply and you're not using remote sensing, you can tie the voltage sensing to the output side of this resistor, so its "loss" doesn't become part of the output voltage.

> Good, very practical.
There are lots of transducers in the industrial world that operate in mV /V operation. Some are millivolt square root. Also, 4-20mA devices are measured using a resistor and taking voltage readings.

> Dynaco did this with their MK III and Stereo 70 amplifiers. To set the bias of the output tubes for 100mA for the pair, they tied a 15.6Ω resistor between the tube cathodes and ground, and carried a cathode lead to the front panel. Since it was assumed that most kit builders had a meter of some kind, the voltage at the "Biaset" terminal could be compared to the voltage of a fresh carbon-zinc cell from the corner drug store, which is not incidentally 1.56V open circuit. Which is what's supposed to appear at the "Biaset" terminal.
15.6Ω * 0.1A = 1.56V

Return to “ARDUINO AND RASPBERRY PI”

Links

In total there are 10 users online :: 0 registered, 0 hidden and 10 guests
Registered users: No registered users
Most users ever online was 156 on Sun Jun 17, 2018 7:42 am
Total posts 439
Total topics 318
Total members 62
Our newest member anonymous-kali
No birthdays today