As an Amazon Associate we earn from qualifying purchases.
Most electricity grids were built around large power stations, central control and one-way power flow from the utility to the customer. That design copes poorly with intermittent sources such as wind turbines and solar panels, and it gives the utility little live information about what happens at each meter. Smart metering addresses part of this problem by adding two-way communication between the meter and the utility.
This project shows a small-scale version of that idea. An energy meter’s pulses are counted by a microcontroller, the usage is converted into a bill amount, and the result is sent over the ordinary mains wiring to a PC. From the PC you can also change the tariff and switch the load on or off.
What is power line communication?
Power line communication (PLC) sends data over the same cables that carry electricity. A PLC modem adds a small, high-frequency signal to the mains wiring, and another modem elsewhere on the same wiring picks it up and decodes it. No new cable, SIM card or Wi-Fi network is needed between the meter and the monitoring point.
For metering this is a practical choice because meters are already connected to the grid. If you want to see a modem-based design in more detail, see our power line communication modem meter project.
What the system does
- Energy billing: the meter side counts consumption pulses, converts them to units, multiplies by the tariff and shows the amount on an LCD.
- Data transfer: the amount is sent over the power line to the PC side at regular intervals.
- Load control: the PC sends a command that switches a relay, cutting or restoring power to the connected load.
- Tariff update: the PC can send a new unit rate to the meter side without anyone visiting the meter.
Why this approach is useful
Manual meter reading is slow and error-prone. Automatic reading lets a utility bill on actual usage, spot unusual consumption sooner and disconnect or reconnect a load remotely. Extra systems can be added on top. For example, a Geographic Information System (GIS) can be linked to the metering network to show where a fault is likely to be. Finding and fixing faults faster shortens outages.
PLC also has limits. Noise from appliances, long cable runs and transformers can weaken or block the signal, so reliability depends on the installation. Good designs include error checking and retries, which this simple demonstration does not.
BLOCK DIAGRAM
The system has two sides that talk through the power line. The PC side is where the operator sees data and sends commands. The monitoring side sits at the meter, measures consumption and drives the relay.
PC SIDE
MONITORING SIDE
CIRCUIT
The first circuit is the main (meter) side, with the microcontroller, LCD, relay and PLC interface. The second is the PC side, which connects the computer’s serial link to the power line.
Mains voltage is dangerous. If you build this on real wiring, use proper isolation, an enclosure and a relay rated for the load, or test the design in simulation first.
How the program works
The sketch below runs on an Arduino-type board with a 16×2 LCD, a relay on pin 9 and a serial link at 9600 baud to the PLC modem. Its logic is simple:
- Counting pulses: an interrupt on a falling edge counts pulses from the energy meter. In this demo, every 3 pulses add one unit. For a real meter, set this to match its pulse rating.
- Calculating the bill: the amount is units multiplied by the unit rate. The default rate in the code is 2.
- Showing the result: the LCD shows the units and the amount, and the second line shows the relay state.
- Sending data: after a fixed number of loop passes, roughly a minute, the board sends the text AMT1- followed by the last two digits of the amount and a carriage return. It then resets the unit count.
- Receiving commands: the character d turns the relay output high, which switches the load off in this circuit. The character c turns it low and the load back on. The character k followed by a digit sets a new tariff.
Because only two digits of the amount are sent, the code as written cannot report amounts above 99 in one interval. Extend the conversion routine if you need larger values.
PROGRAM
#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);//LCD RS-12,En-11,D4-5,D5- 4,D6-3,D7-2
int t=0,p=0,u=0,y=2,z; //time,pulse,unit,unit rate,amount
char g[5],a;
void setup()
{
pinMode(9,OUTPUT);//relay
lcdstart();
Serial.begin(9600);
attachInterrupt(0, blink, FALLING);
}
void loop()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("unit=");// Print a message to the LCD.
lcd.print(u);// Print a message to the LCD.
z=u*y;
lcd.print(" AMT=");// Print a message to the LCD.
lcd.print(z);// Print a message to the LCD.
delay(100);
power ();
t=t+1;
if(t==600){t=0;
Serial.write('A');del();Serial.write('M');del();
Serial.write('T');del();Serial.write('1');del();Serial.write('-');del();
u=u*y;
adctoascii();
Serial.write(g[2]); del();Serial.write(g[3]); del();Serial.write(0xd); del();
u=0;
}
serial();
}
void serial(void)
{
if(Serial.available()>0)
{
a=Serial.read();
if(a=='d'){lcd.setCursor(0, 1);lcd.print("off");digitalWrite(9,HIGH);}
else if (a=='c'){lcd.setCursor(0, 1);lcd.print("on ");digitalWrite(9,LOW);}
if(a=='k') //tarif
{
while(!(Serial.available()>0));
a=Serial.read();
y=(a-0x30);
}
else;
}
}
void power (void)
{
if(p==3)
{
u=u+1;
p=0;
}
}
void blink()
{
p=p+1;
}
void lcdstart(void)
{
lcd.begin(16, 2);// set up the LCD's number of columns and rows:
lcd.setCursor(0, 0);
lcd.print("WELCOME");// Print a message to the LCD.
delay(500);
lcd.clear();
}
void del(void)
{
delay(500);
}
void adctoascii (void)
{
g[4]=' '; //LSB section
g[3]=(u%10)+0x30;
g[2]=u/10%10+0x30;
g[1]=u/100%10+0x30;
g[0]=u/1000+0x30;//MSB section
}
The comment next to the LCD line does not match the pins actually used in the code. The pin numbers inside LiquidCrystal lcd(3, 4, 5, 6, 7, 8) are the ones that count, so wire the display to match them.
Ways to extend the project
- Add a prepaid energy meter feature that cuts the relay when the balance runs out.
- Add tamper or power theft detection and report it to the PC.
- Control several loads with more relays, as in relay-based home control projects such as our relay-based home control example.
- Combine meter data with appliance control, as in the billing and home automation version of this project.
- Add error checking to the serial messages so noisy power lines do not corrupt readings.
FAQ
How does power line communication send data?
A PLC modem superimposes a modulated signal on the mains wiring. A second modem on the same wiring filters it out and passes the data to a microcontroller or PC.
Do I need internet or Wi-Fi for this system?
No. Data travels over the power wiring between the two sides. Internet would only be needed if you wanted to forward the data to a remote server.
Why does the code count three pulses per unit?
It is a demonstration value so the display changes quickly. For a real meter, use the pulse constant printed on it, which states how many pulses equal one unit of energy.
Is it safe to build this on live mains?
Only with proper isolation, correctly rated parts and experience with mains wiring. Beginners should use a simulation or low-voltage test setup first.