This is an Arduino board based project that can measure the power consumption of devices. When we connect this wattmeter to a device that is in operation, the 16*2 LCD displays its power consumption value in Watts. The project uses an Arduino Pro Miniboard whose ADC feature is used together with the concept of Ohm's law and the voltage divider circuit to develop this Wattmeter.
Figure 1: Arduino-based watt meter prototype
Description
The entire project can be divided into three basic blocks;
1) Power Sensing Unit
2) Processing Unit
3) Display unit
Figure 2: Arduino-based watt meter block diagram
The Power Sensing Unit allows current to flow through a device whose power consumption needs to be measured. The Sensing Unit produces two voltages, one is the voltage output from the power supply and the other is a voltage that varies from 0 to 5V. The difference between these two voltages is proportional to the amount of current flowing through the sensor unit.
The Processor Unit can accept two input voltages, both in the range of 0 to 5V. This unit considers the output of the sensor unit as input voltages and uses the ADC to read these voltages. An algorithm is then applied to calculate the device's power consumption. The unit then sends 4-bit data to the display unit to display power consumption in Watts.
The display unit takes the 4-bit data from the processor unit and produces a 16*2 display for the current consumption of the device.
1) Power Sensing Unit
The Power Sensor in this project is a single low value resistor through which current flows to the load device. The voltage across the resistor and the current flow through the resistor are measured to calculate the power consumption of the device.
In our project we have implemented resistor 'R' in the current flow path whose resistance value is known. Then we measure the voltage at both ends of the resistor to calculate the current flow with the help of the following equation.
I = (V2 – V1) /R
Figure 3: Circuit diagram of the power detection circuit
We have selected a value of R = 10 ohms, now we have the equation for calculating the power;
I = V2 – V1/10
Once the current value 'I' is obtained, the power consumed by the device 'P' can be calculated using the following equation;
P = V2 * I
2) Processing Unit
The processor unit in this project is the Arduino board and uses the ADC module to read the output voltages V1 and V2 of the Sensor Unit. On the Arduino board we are using an 8 channel 10 bit ADC with the reference voltage pin connected to 5 V. The ADC reads the voltage V1, V2 and outputs an equivalent value ' ADC Value' in the ADC register. From this value, the algorithm calculates the voltages V1 and V2 and then the energy consumption.
Once the values of V1 and V2 are obtained, the value of the current flow 'I' is calculated using the known values of R = 10 ohms, with the help of the equation;
I = (V2 – V1) / 10
Power consumption is then calculated using the equation;
P = V2 * I
The following code calculates the power and displays it on the LCD.
dc_power = dc_current_I0 * dc_voltage_V1;
lcd.claro;
lcd.setCursor(0, 0);
lcd.print(dc_power);
lcd.print(”mWDC”);
Display unit and code explanation
3) Display Unit
The display unit uses a standard 16*2 LCD on which the Arduino displays the power consumption value. The LCD was wired in four-bit mode to reduce the number of Arduino board output pins to be used.
Figure 4: Image showing the LCD module used to display resistance
Code description
The code continuously reads ADC channels A0 and A2 one after the other, each time calculating the values of V1 and V2. When both V1 and V2 values are obtained, the code then calculates the power consumption value of the device and that value is displayed on the 16*2 LCD.
The code running on Arduino used the analogRead library function to get the ADC value and lcd.print to display the data on the 16*2 LCD.
Figure 5: Arduino code flow diagram for power measurement
Limitations:
The 10 ohm resistor is a high value compared to the 0.05 ohm precision resistor inside a multimeter. More current flow, more voltage drop across the resistor, and this voltage drop is proportional to the value of the resistance. For current values above 500mA, create a low resistance by connecting as many resistors in parallel as possible. Since the Arduino ADC can only read a maximum of 5V, do not use a current source with a voltage higher than 5V.
Project source code
###
// includes library code:
#include
// initialize the library with the interface pin numbers
Liquid crystal LCD (12, 11, 5, 4, 3, 2);
int adc_value = 0;
int voltage_peak_value = 0;
float voltage_average_value = 0;
floating voltage_cc_V0 = 0;
floating voltage_ac_V0 = 0;
float dc_voltage_V1 = 0;
floating voltage_ac_V1 = 0;
float dc_current_I0 = 0;
float ac_current_I0 = 0;
float dc_power = 0;
float ac_power = 0;
unsigned long endurance;
long unsigned sample_count = 0;
null configuration
{
// configures the number of LCD columns and lines:
lcd.begin(16, 2);
// Prints a message on the LCD.
lcd.print("EG LABS");
pinMode(13, OUTPUT);
}
empty loop
{
// Serial.println("=============================== VOLTAGE =========== ==============================");
voltage_peak_value = 0;
for(sample_count = 0; sample_count < 5000; sample_count ++)
{
adc_value = analogRead(A0);
if(voltage_peak_value < adc_value)
voltage_peak_value = adc_value;
other;
delayMicroseconds(10);
}
dc_voltage_V0 = voltage_peak_value * 0.00488;
voltage_ac_V0 = voltage_cc_V0 / 1.414;
// Serial.println("================================ CURRENT ========== ===============================");
voltage_peak_value = 0;
for(sample_count = 0; sample_count < 5000; sample_count ++)
{
adc_value = analogRead(A2);
if(voltage_peak_value < adc_value)
voltage_peak_value = adc_value;
other;
delayMicroseconds(10);
}
dc_voltage_V1 = voltage_peak_value * 0.00488;
voltage_ac_V1 = voltage_cc_V1 / 1.414;
dc_current_I0 = (dc_voltage_V1 - dc_voltage_V0) * 100;
ac_current_I0 = (ac_voltage_V1 - ac_voltage_V0) * 100;
//================================ POWER ============================ ==========================
dc_power = dc_current_I0 * dc_voltage_V1;
ac_power = ac_current_I0 * ac_voltage_V1;
lcd.claro;
lcd.setCursor(0, 0);
lcd.print(dc_power);
lcd.print("mW");
//========================================================= == ===============================
delay(1000);
}
###
Circuit diagrams
Circuit Diagram-Arduino-Wattmeter |