Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » GSM Based Prepaid Electricity Energy Meter using Arduino
Arduino Projects

GSM Based Prepaid Electricity Energy Meter using Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:August 3, 20235 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
GSM Based Prepaid Electricity Energy Meter using Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this project, we will make a GSM Based Prepaid Electricity Energy Meter using Arduino. Prepaid Electricity Energy Meter is one of the best concepts for the current electricity payment system. In this system, you can recharge the device and update the balance as we do on our mobile phones.

By sending a simple SMS, you can recharge the electricity balance through this system. It can also disconnect the home power supply connection if there is a low or zero balance in the system. And this system will read the energy meter readings and automatically send some updates to the user’s mobile phone like low balance alert, cut off alert, resume alert and recharge alert. The Anti-Theft Alert can also be detected when someone tries stealing the meter by opening the lid. So, let us see how we can build this project.

There is an advance version of this project based on Internet of Thing, which you may look into:
1. IoT AC Energy Meter using Old Blynk
2. IoT AC Energy Meter using New Blynk
3. IoT DC Energy Meter


Bill of Materials

Following is the list of materials that you need to make an Arduino & GSM Based Prepaid Energy Meter. You can purchase all the components from the following link.

S.N.ComponentsQuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
2SIM800/900 GSM Module1Amazon | AliExpress
3Single Channel Relay1Amazon | AliExpress
416x2 I2C LCD Display1Amazon | AliExpress
5Micro Limit Switch1Amazon | AliExpress
65V Buzzer1Amazon | AliExpress
7Optocoupler IC 4N351Amazon | AliExpress
8Energy Meter1Amazon
910K Resistor1Amazon | AliExpress
10Zero PCB1Amazon | AliExpress
119V Power Adapter1Amazon | AliExpress




Hardware Setup & Circuit Diagram

The circuit diagram for GSM Based Prepaid Energy Meter is very simple. The Analog Electricity Energy Meter input terminal connects to 220V AC Power Supply. Its output terminal connects to the output of the single-channel Relay Module. All the loads for electricity also connect to the Relay as shown in the circuit.

Arduino Prepaid Electricity Energy Meter

The 16×2 I2C LCD Display connects to the I2C Pins of the Arduino UNO Board. We have used SIM800 GSM Module for GMS SMS functions which is the most important part of this project. The GSM has UART Pin as Tx & Rx which connects via Software Serial to digital pins 11 and 12 of Arduino. The GSM Module requires 9V Power Supply. So an external 9V DC power supply like DC Power Adapter can be used. Hence the GSM and Arduino both are powered via 9V DC Adapter.

The Relay, Buzzer, and Limit Switch are connected to D8, D7 & A0 of Arduino. Remember to take precautions as this circuit is dangerous due to AC Mains.

Prepaid Energy Meter Circuit

As shown here, you can assemble the circuit in a combined board. The top of the board has only the analog meter and LCD Display. Inside the box, the Arduino Board, GSM Module, Relay, and 4N35 Optocoupler IC are placed together. The Limit switch is placed at the opening of the meter door. It is used to check whether the box is opened or not and can prevent theft.

GSM Prepaid Electricity Energy Meter

In this project, you can connect anything to the load such as Fan, Bulb, Heater, and everything that you use at home. To test this system you can connect the whole device directly to the 220V AC power supply.



How to Connect the Analog Meter to Arduino

The most important thing is how do you connect the meter to the Arduino. For this open the meter first. At the back of the meter, there is a Pulse LED or Cal LED terminals which are basically cathode and Anode.

You need to solder two wires to these terminals. After these, connect the anode & cathode terminal of the LED at pin number 1 and pin number 2 of the optocoupler. Now, this optocoupler is connected to digital pin D2 of Arduino.


Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on a breadboard and you want PCB for the project, then here is the PCB for you. I used EasyEDA to design the PCB & Schematic. The Schematic & PCB Board for Prepaid Energy Meter looks something like the below.

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: Prepaid Energy Meter

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.

You can assemble the components on the PCB Board.


Source Code/program: Arduino GSM Prepaid Energy Meter

The complete program for GSM Based Prepaid Energy Meter using Arduino is given below. The code is mostly formatted for GSM AT Commands to recharge and test the system along with output feedback messages.

1
2
String phone_no1 = "+91xxxxxxxxxx";
String phone_no2 = "+91xxxxxxxxxx";

You need to make changes to the above lines in this code. Replace the mobile number in the following lines of the code with the number you want the SMS to send.

You can copy the code and upload it to the Arduino Board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
#include <SoftwareSerial.h>
SoftwareSerial GSM(10, 11);
 
#define buzzer 7
#define relay  8
#define bt_theft  A0
 
#define pulse_in 2
 
char inchar;
 
int unt_a = 0, unt_b = 0, unt_c = 0, unt_d = 0;
long total_unt = 7;
 
int price = 0;
long price1 = 0;
 
int Set = 10;
 
int pulse = 0;
 
 
String phone_no1 = "+91xxxxxxxxxx";
String phone_no2 = "+91xxxxxxxxxx";
 
int flag1 = 0, flag2 = 0, flag3 = 0;
 
void setup() {
  Serial.begin(9600);
  GSM.begin(9600);
 
  pinMode(bt_theft,   INPUT_PULLUP);
  pinMode(relay, OUTPUT);
  pinMode(buzzer, OUTPUT);
 
  pinMode(pulse_in,   INPUT);
  attachInterrupt(0, ai0, RISING);
 
  lcd.begin();
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(5, 0);
  lcd.print("WELCOME");
  lcd.setCursor(2, 1);
  lcd.print("Energy Meter");
  digitalWrite(buzzer, HIGH);
 
  Serial.println("Initializing....");
  initModule("AT", "OK", 1000);
  initModule("ATE1", "OK", 1000);
  initModule("AT+CPIN?", "READY", 1000);
  initModule("AT+CMGF=1", "OK", 1000);
  initModule("AT+CNMI=2,2,0,0,0", "OK", 1000);
  Serial.println("Initialized Successfully");
  delay(100);
  sendSMS(phone_no1, "Welcome To Energy Meter");
  digitalWrite(buzzer, LOW);
  lcd.clear();
 
  if (EEPROM.read(50) == 0) {}
  else {
    Write();
  }
 
  EEPROM.write(50, 0);
 
  pulse = EEPROM.read(10);
 
  Read();
  if (total_unt > 0) {
    digitalWrite(relay, HIGH);
  }
 
}
 
void loop()
{
 
  if (GSM.available() > 0)
  {
    inchar = GSM.read();
    if (inchar == 'A')
    {
      delay(10);
      inchar = GSM.read();
      if (inchar == 'T')
      {
        delay(10);
        inchar = GSM.read();
        if (inchar == 'r')
        {
          delay(10);
          inchar = GSM.read();
          if (inchar == 'e')
          {
            delay(10);
            inchar = GSM.read();
            if (inchar == 'c')
            {
              delay(10);
              inchar = GSM.read();
              if (inchar == 'h')
              {
                delay(10);
                inchar = GSM.read();
                if (inchar == '1')
                {
                  price = 100 / Set;  total_unt = total_unt + price;
                  sendSMS(phone_no1, "Your Recharge is Done: 100");
                  sendSMS(phone_no2, "Your Recharge is Done: 100");
                  load_on();
                }
                else if (inchar == '2')
                {
                  price = 200 / Set;  total_unt = total_unt + price;
                  sendSMS(phone_no1, "Your Recharge is Done: 200");
                  sendSMS(phone_no2, "Your Recharge is Done: 200");
                  load_on();
                }
                else if (inchar == '3')
                {
                  price = 300 / Set;  total_unt = total_unt + price;
                  sendSMS(phone_no1, "Your Recharge is Done: 300");
                  sendSMS(phone_no2, "Your Recharge is Done: 300");
                  load_on();
                }
                else if (inchar == '4')
                {
                  price = 400 / Set;  total_unt = total_unt + price;
                  sendSMS(phone_no1, "Your Recharge is Done: 400");
                  sendSMS(phone_no2, "Your Recharge is Done: 400");
                  load_on();
                }
                delay(10);
              }
            }
          }
        }
      }
    }
 
    else if (inchar == 'D')
    {
      delay(10);
      inchar = GSM.read();
      if (inchar == 'a')
      {
        delay(10);
        inchar = GSM.read();
        if (inchar == 't')
        {
          delay(10);
          inchar = GSM.read();
          if (inchar == 'a')
          {
            Data();
          }
        }
      }
    }
  }
 
  lcd.setCursor(0, 0);
  lcd.print("Unit:");
  lcd.print(total_unt);
  lcd.print("   ");
 
  lcd.setCursor(0, 1);
  lcd.print("Price:");
  lcd.print(price1);
  lcd.print("   ");
 
  lcd.setCursor(11, 0);
  lcd.print("Pulse");
 
  lcd.setCursor(13, 1);
  lcd.print(pulse);
  lcd.print("   ");
 
  if (total_unt == 5)
  {
    if (flag1 == 0)
    {
      flag1 = 1;
      digitalWrite(buzzer, HIGH);
      sendSMS(phone_no1, "Your Balance is Low Please Recharge");
      digitalWrite(buzzer, LOW);
    }
  }
 
  if (total_unt == 0)
  {
    digitalWrite(relay, LOW);
    if (flag2 == 0)
    {
      flag2 = 1;
      digitalWrite(buzzer, HIGH);
      sendSMS(phone_no1, "Your Balance is Finish Please Recharge");
      digitalWrite(buzzer, LOW);
    }
  }
 
  if (digitalRead (bt_theft) == 0)
  {
    if (flag3 == 0)
    {
      flag3 = 1;
      sendSMS(phone_no2, "Theft Alarm");
    }
  }
  else
  {
    flag3 = 0;
  }
 
  delay(5);
}
 
void load_on()
{
  Write();
  Read();
  digitalWrite(relay, HIGH);
  flag1 = 0, flag2 = 0;
}
 
void sendSMS(String number, String msg)
{
  GSM.print("AT+CMGS=\""); GSM.print(number); GSM.println("\"\r\n");
  delay(500);
  GSM.println(msg);
  delay(500);
  GSM.write(byte(26));
  delay(5000);
}
 
void Data()
{
  GSM.print("AT+CMGS=\""); GSM.print(phone_no1); GSM.println("\"\r\n");
  delay(1000);
  GSM.print("Unit:"); GSM.println(total_unt);
  GSM.print("Price:"); GSM.println(price1);
  delay(500);
  GSM.write(byte(26));
  delay(5000);
}
 
void Read()
{
  unt_a = EEPROM.read(1);
  unt_b = EEPROM.read(2);
  unt_c = EEPROM.read(3);
  unt_d = EEPROM.read(4);
  total_unt = unt_d * 1000 + unt_c * 100 + unt_b * 10 + unt_a;
  price1 = total_unt * Set;
}
 
void Write()
{
  unt_d = total_unt / 1000;
  total_unt = total_unt - (unt_d * 1000);
  unt_c = total_unt / 100;
  total_unt = total_unt - (unt_c * 100);
  unt_b = total_unt / 10;
  unt_a = total_unt - (unt_b * 10);
 
  EEPROM.write(1, unt_a);
  EEPROM.write(2, unt_b);
  EEPROM.write(3, unt_c);
  EEPROM.write(4, unt_d);
}
 
 
void initModule(String cmd, char *res, int t)
{
  while (1)
  {
    Serial.println(cmd);
    GSM.println(cmd);
    delay(100);
    while (GSM.available() > 0)
    {
      if (GSM.find(res))
      {
        Serial.println(res);
        delay(t);
        return;
      }
      else
      {
        Serial.println("Error");
      }
    }
    delay(t);
  }
}
 
void ai0()
{
  if (digitalRead(pulse_in) == 1)
  {
    pulse = pulse + 1;
    if (pulse > 9)
    {
      pulse = 0;
      if (total_unt > 0)
      {
        total_unt = total_unt - 1;
      }
      Write();
      Read();
    }
    EEPROM.write(10, pulse);
  }
}




Project Working & Demonstration

When you power on the device, the LCD will display the unit, pulse, and price as zero.

Now we need to send an SMS to operate this device. Before that, we need to recharge this meter as there is no money to operate this device. You can recharge 100, 200, 300 & 400 at a single time. With the recharged money the electricity load will always be active as long as the amount doesn’t reach to zero.

To recharge with 100 balance, type ATrech1 & send. Here 1 means 100. If you want to recharge it with 200 simply replace 1 with 2. You will get a feedback message as an SMS that says “recharge is done”. The LCD will also display the same. Immediately the load will turn on.

As long as the pulse LED blinks, the counting goes on and the pulse count is displayed on LCD Screen. Also, there is a deduction in the recharged amount. We also set the limit to 60. As the amount goes to 60, the GSM will send an SMS saying the balance is low and you need to recharge it again. So basically, it’s an indication as well as a warning.

When the power consumption increases and the price goes further down till the amount reaches zero. In this instance, the load will turn off and there is an electricity cut-off. You will receive an SMS saying the balance is finished and you need to recharge it again.

So you can recharge again. A similar process continues again and again.

This process continues even after there is a power cut. This is because the last pulse count and price value are stored in the EEPROM of the microcontroller.


Video Tutorial & Guide

GSM Based Prepaid Electricity Energy Meter using Arduino with Automatic Billing & Theft-Alert System
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleVideo Streaming Car Robot using Raspberry Pi & Camera
Next Article Desktop Dimming Light using Raspberry Pi Pico

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 5 Comments

5 Comments

  1. zubair ul haq on January 5, 2023 11:33 AM

    Hello sir i face a problem in uploading the program
    Its show’s error

    Reply
  2. Ananya Cs on May 31, 2023 1:30 AM

    Did you got solution for the errors

    Reply
  3. Ananya Cs on May 31, 2023 1:31 AM

    Did you got the solution for your errors.

    Reply
  4. Kailash Kumar Saini on April 19, 2024 1:23 AM

    Please provide report on this project

    Reply
  5. Kaji Mahammadafazal Mohammadmasum on July 25, 2024 9:40 AM

    What is the name of the software to simulate the project.

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.