INTRODUCTION
1.1 INTRODUCTION
GSM and GPRS based Designs have developed another innovative and public utility
product for mass communication .The purpose of this project is to remote monitoring
and control of the Domestic Energy meter. This system enables the Electricity
Department to read the meter readings regularly without the person visiting each house.
This can be achieved by the use of micro controller unit that continuously monitors and
records the Energy Meter readings in its permanent (non-volatile) memory location.
This system also makes use of a GSM modem for remote monitoring and control of
Energy Meter.
The Microcontroller based system continuously records the readings and the live
meter reading can be sent to the Electricity department on request. This system also can
electricity bills. A dedicated GSM modem with SIM card is required for each energy
meter.
The main aim of the project will be to design a SMS electronic ENERGY
METER toolkit which can replace the traditional ENERGY METER. The toolkit send
SMS to Electricity Department number, the system is made efficient by SIMs so that the
SMS can be received by number of devices boards in a locality using techniques of time
These components are integrated with the device board and thus incorporate the
1|Page
Wireless features. The GSM modem receives the SMS. The AT commands are serially
transferred to the modem. In return the modem transmits the stored message through the
wireless link. The microcontroller used in this case is ATMEL AT89S52. SIMCOM 300
is used as the GSM modem. In this prototype model, LCD display is used for simulation
purpose. The results presented in the thesis support the proper functionalities and
working of the system. The timing diagram suggests the response of the modem to
1.2 METHODOLOGY
The method used to carry out this project is the principle of serial communication in
collaboration with embedded systems. As the analog energy meter shows load reading
while microcontroller kit with GSM modem reads actual reading where theft taken into
account and that reading will be send by SMS to EB officer . The latest technology used
System will work like when the user wants to receive a SMS on the energy
consumption in houses and offices; the modem sent a message through the subscriber
2|Page
1.3 SCOPE OF WORK
In this project, liquid crystal display is used for displaying the message; and also use
will send message to any phone irrespective of the GSM network through the modem
The proposed project work aims on the design and development of energy theft
prevention aspect.
The concept of this project to prevent the illegal usage of electrical power this
system would provide a simple way to detect an electrical power theft without
3|Page
1.5 BLOCK DIAGRAM
REGULATED POWER
SUPPLY (5 V)
ANALOG
ENERGY METER
LCD
MICRO
RELAY CONTROLLER
(12 V)
BUZZER
MOBILE PHONES
4|Page
1.6 LIST OF COMPONENTS
Regulator 7805 1 U1
Regulator 7812 1 U3
Diode(INL0074) 4 D1,D2,D3,D4
Push Button 1
Mobile Phone 1
LCD 16*2 1
40 Pin Base 1 U2
16 Pin Base 1 U5
Load (60 W )
5|Page
8051(AT89S52) 1
Oscillator 11.0592mhz 1 X1
LED 2 D5,D7
Resistance 1k 1 R3
Buzzer 1 BUZ1
BC547(Transistor)(NPN) 1 Q1
Energy meter(240V,5-30A) 1
6|Page
2. THEORETICAL BACKGROUND AND
LITERATURE REVIEW
2.1 THEORETICAL BACKGROUND
GSM (Global System for Mobile communications: originally from GROUPE Special
Mobile) is the most popular standard for mobile phones in the world. Its promoter, the
GSM Association, estimates that 80% of the global mobile market uses the standard.
GSM is used by over 3 billion people across more than 212 countries. Its ubiquity
makes international roaming very common between mobile phone operators enabling
subscribers to use their phones in many parts of the world. GSM differs from its
predecessors in that both signaling and speech channels are digital, and thus is
considered a second generation (2G) mobile phone system. This has also meant that data
mobile phone and a microcontroller. Currently the main work that has been done on this
proposed system is through serial port to the computer but not wireless. If they want to
switch on and off the appliance, they have to go to the remote area and one /off the
appliance. But in this new design, the systems need not be reprogrammed to control
another home appliance without changing the programming of microcontroller. The user
will send SMS from his phone and he will be able to control the appliance.
7|Page
2.3 GSM ARCHITECTURE
GSM is a complex system and difficult to understand. The Mobile Station (MS) refers to
the mobile equipment. The Base Station Subsystem controls the radio link with the
Mobile Station. The Network Subsystem performs main functions such as switching of
calls between mobile users, mobility management operations, and proper operation and
setup of a network. These functions are controlled by the Mobile Services Switching
Center (MSC).
GSM is a cellular network, which means that mobile phones connect to it by searching
GSM networks operate in a number of different frequency ranges (separated into GSM
frequency ranges for 2G and UMTS frequency bands for 3G). Most 2G GSM networks
Operate in the 900 MHz or 1800 MHz bands. Some countries in the Americas
(including Canada and the United States) use the 850 MHz and 1900 MHz bands
because the 900 and 1800 MHz frequency bands were already allocated. Most 3G GSM
8|Page
2.6 NETWORK STRUCTURE
The network behind the GSM seen by the customer is large and complicated in order to
The Base Station Subsystem (the base stations and their controllers).
The Network and Switching Subsystem (the part of the network most similar to a
fixed network). This is sometimes also just called the core network.
The GPRS Core Network (the optional part which allows packet based Internet
connections).
One of the key features of GSM is the Subscriber Identity Module, commonly known
as a SIM card. The SIM is a detachable smart card containing the user's subscription
information and phone book. This allows the user to retain his or her information after
switching handsets. Alternatively, the user can also change operators while retaining the
handset simply by changing the SIM. Some operators will block this by allowing the
phone to use only a single SIM, or only a SIM issued by them; this practice is known as
GSM was designed with a moderate level of security. The system was designed to
Communications between the subscriber and the base station can be encrypted.
9|Page
3. SIMULATOR
simulated on a computer before being loaded onto the microcontroller. The software
used is c programming
10 | P a g e
μVision3 is an IDE (Integrated Development Environment) that helps write,
A project manager.
A make facility.
Tool configuration.
Editor.
A powerful debugger.
3. Select Project –Select Device and select a device from Device Database.
5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and
add the
6. Select Project - Options and set the tool options. Note that when the target device
is selected from the Device Database all-special options are set automatically.
11 | P a g e
To create a new project, simply start micro vision and select “Project”=>”New
Project” from the pull–down menus. In the file dialog that appears, a filename and
directory was chosen for the project. It is recommended that a new directory be
created for each project, as several files will be generated. Once the project has been
named, the dialog shown in the figure below will appear, prompting the user to
select a target device. The chip being used is the “AT89S52,” which is listed under
Next, Micro Vision was instructed to generate a HEX file upon program
compilation. A HEX file is a standard file format for storing executable code that is to
be loaded onto the microcontroller. In the “Project Workspace” pane at the left, right–
click on “Target 1” and select “Options for ‘Target 1’ ”.Under the “Output” tab of the
resulting options dialog, ensure that both the “Create Executable” and “Create HEX
Next, a file must be added to the project that will contain the project code. To do
this, expand the “Target 1” heading, right–click on the “Source Group 1” folder, and
select “Add files…” Create a new blank file (the file name should end in “.c”), select it,
and click “Add.” The new file should now appear in the “Project Workspace” pane
under the “Source Group 1” folder. Double-click on the newly created file to open it in
the editor. To compile the program, first save all source files by clicking on the “Save
All” button, and then click on the “Rebuild All Target Files” to compile the program as
shown in the figure below. If any errors or warnings occur during compilation, they will
12 | P a g e
be displayed in the output window at the bottom of the screen. All errors and warnings
will reference the line and column number in which they occur along with a description
When the program has been successfully compiled, it can be simulated using the
At the left side of the debugger window, a table is displayed containing several
key parameters about the simulated microcontroller, most notably the elapsed time
(circled in the figure below). Just above that, there are several buttons that control code
execution. The “Run” button will cause the program to run continuously until a
breakpoint is reached, whereas the “Step Into” button will execute the next line of code
and then pause (the current position in the program is indicated by a yellow arrow to the
13 | P a g e
PRO51 BURNER SOFTWARE
PRO51 BURNER provides you with software burning tools for 8051 based
Microcontrollers in their Flash memory. The 51 BURNER tools, you can burn
AT89C/SXXXX series of ATMEL microcontrollers.
14 | P a g e
4. SIMULATION AND ITS RESULTS
Output
15 | P a g e
4.2 Power supply for microcontroller (230 V to 5 V)
Output
16 | P a g e
4.3 Power supply for GSM module (230 V to 12 V)
Output
17 | P a g e
5 HARDWARE PROTOTYPE AND RESULTS
supplies electrical or other types of energy to an output load or group of loads is called a
power supply unit or PSU. The term is most commonly applied to electrical energy
18 | P a g e
Here in our application we need a 5v DC power supply for all electronics involved in the
project. This requires step down transformer, rectifier, voltage regulator, and filter
circuit for generation of 5v DC power. Here a brief description of all the components are
given as follows
5.2 TRANSFORMER:
A transformer is a device that transfers electrical energy from one circuit to another
for air-core transformers, the conductors are commonly wound around a single iron-rich
core, or around separate but magnetically-coupled cores. A varying current in the first or
"primary" winding creates a varying magnetic field in the core (or cores) of the
transformer. This varying magnetic field induces a varying electromotive force (EMF)
Fig5.2 Transformer
19 | P a g e
If a load is connected to the secondary circuit, electric charge will flow in the secondary
winding of the transformer and transfer energy from the primary circuit to the load
The secondary induced voltage VS, of an ideal transformer, is scaled from the primary
VP by a factor equal to the ratio of the number of turns of wire in their respective
windings:
VS/VP=NNS/NP
by making it
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave
rectification. This is a widely used configuration, both with individual diodes wired as
shown and with single component bridges where the diode bridge is wired internally.
20 | P a g e
5.4 REGULATOR IC (7805)
regulated DC current.
Normally we get fixed output by connecting the voltage regulator at the output of the
filtered DC (see in above diagram). It can also be used in circuits to get a low DC
voltage from a high DC voltage (for example we use 7805 to get 5V from 12V). There
are two types of voltage regulators 1. Fixed voltage regulators (78xx, 79xx) 2.Variable
+ve voltage regulators and -ve voltage regulators. Positive voltage regulator this include
78xx voltage regulators. The most commonly used ones are 7805 and 7812. 7805 gives
21 | P a g e
5.5 THE CAPACITOR FILTER
The simple capacitor filter is the most basic type of power supply filter. The application
of the simple capacitor filter is very limited. It is sometimes used on extremely high-
voltage, low-current power supplies for cathode ray and similar electron tubes, which
the power-supply ripple frequency is not critical; this frequency can be relatively high.
The capacitor (C1) shown in figure is a simple filter connected across the output of the
When this filter is used, the RC charge time of the filter capacitor (C1) must be short
and the RC discharge time must be long to eliminate ripple action. In other words, the
capacitor must charge up fast, preferably with no discharge at all. Better filtering also
results when the input frequency is high; therefore, the full-wave rectifier output is
easier to filter than that of the half-wave rectifier because of its higher frequency.
22 | P a g e
5.6 RELAY
The relay takes advantage of the fact that when electricity flows through a coil, it
attached to a switch. So the switch's motion (ON and OFF) is controlled by the current
flowing to the coil, or not, respectively. A very useful feature of a relay is that it can be
used to electrically isolate different parts of a circuit. It will allow a low voltage circuit
(e.g. 5VDC) to switch the power in a high voltage circuit (e.g. 100 VAC or more).The
23 | P a g e
6. DESIGN AND CONSTRUCTION
6.1GSM MODEM
A GSM modem is a wireless modem that works with a GSM wireless network. A
wireless modem behaves like a dial-up modem. The main difference between them is
that a dial-up modem sends and receives data through a fixed telephone line while a
wireless modem sends and receives data through radio waves. Like a GSM mobile
phone, a GSM modem requires a SIM card from a wireless carrier in order to operate.
24 | P a g e
6.2 Microcontroller – Modem Interfacing
DTE and DCE
The terms DTE and DCE are very common in the data communications market. DTE is
short for Data Terminal Equipment and DCE stands for Data Communications
Equipment. As the full DTE name indicates this is a piece of device that ends a
communication line, whereas the DCE provides a path for communication. Let's say we
have a computer on which we want to communicate with the Internet through a modem
and a dial-up connection. To get to the Internet we tell our modem to dial the number of
our provider. After our modem has dialed the number, the modem of the provider will
answer our call and we will hear a lot of noise. Then it becomes quiet and we see our
login prompt or our dialing program tells us the connection is established. Now we have
a connection with the server from our provider and we can surf the Internet.
25 | P a g e
6.3 MICROCONTROLLER – LCD INTERFACING
Above is the quite simple schematic. The LCD panel’s Enable and Register Select is
connected to the Control Port. The Control Port is an open collector / open drain output.
Therefore by incorporating the two 10K external pull up resistors, the circuit is more
portable for a wider range of computers, some of which may have no internal pull up
resistors. We make no effort to place the Data bus into reverse direction. Therefore we
had wire the R/W line of the LCD panel, into write mode. This will cause no bus
conflicts on the data lines. As a result we cannot read back the LCD’s internal Busy Flag
which tells us if the LCD has accepted and finished processing the last instruction. This
problem is overcome by inserting known delays into our program. The 10k
Potentiometer controls the contrast of the LCD panel. Nothing fancy here.
We used a power supply of 5volt. The user may select whether the LCD is to operate
with a 4-bit data bus or an 8- bit data bus. If a 4-bit data bus is used, the LCD will
require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total of
11 data lines. LCD with 8-bit data bus is used for this design. The three control lines are
26 | P a g e
EN, RS, and RW. EN line must be raised/lowered before/after each instruction sent to
the LCD regardless of whether that instruction is read or write text or instruction. In
DISPLAY
After validity check the control flow goes into the LCD program module to display the
valid message stored in the memory. In case of multiple valid numbers all invalid stored
messages are deleted by proper branching in the code to the “delete-message” module.
27 | P a g e
6.4. PROGRAMMER
When we have to learn about a new computer we have to familiarize about the machine
capability we are using, and we can do it by studying the internal hardware design
(devices architecture), and also to know about the size, number and the size of the
registers.
A microcontroller is a single chip that contains the processor (the CPU), non-volatile
memory for the program (ROM or flash), volatile memory for input and output (RAM),
a clock and an I/O control unit. Also called a "computer on a chip," billions of
microcontroller units (MCUs) are embedded each year in a myriad of products from
toys to appliances to automobiles. For example, a single vehicle can use 70 or more
microcontroller.
using Atmel’s high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the
embedded control applications. The AT89S52 provides the following standard features:
8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers,
28 | P a g e
three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex
serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed
with static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port, and interrupt system to continue functioning. The Power-
down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip
functions until the next interrupt. The hardware is driven by a set of program
instructions, or software. Once familiar with hardware and software, the user can then
apply the microcontroller to the problems easily. The pin diagram of the 8051 shows
29 | P a g e
The following are some of the capabilities of 8051 microcontroller.
Internal ROM 4k
Two external and three internal interrupt sources Oscillator and clock
circuits.
30 | P a g e
Circuit diagram
31 | P a g e
Result
32 | P a g e
7 CONCLUSION
The power theft identifier using microcontroller and GSM is very effective topology to
control electricity theft percentage. The hardware prototype is built by using microcontroller
(89S52) and GSM module. The hardware results are obtained for household load and
household load including with theft load. And from hardware result it concluded that, as the
analog energy meter shows load reading by using microcontroller reads actual reading
where theft taken into account and that reading will be send by SMS to EB officer by using
GSM modem. If there is difference between internal reading and energy meter reading,
immediately EB officer take action, make supply OFF by sending OFF command. It works
for all 24 hours. In commercial areas, municipal, Agriculture application and specially
for rural areas, it can be most applicable. By using this system, preventing the illegal
usage of the electrical power and tariff rate can be reduced. This method can make the
country economically strong, save electricity & removes the problem of load shedding.
Problem Encountered
During soldering, many of the connection become short circuit. So we desolder the
A leg of the crystal oscillator was broken during mounting. So it has been replaced.
LED`s get damaged when we switched ON the supply so we replace it by the new
one.
33 | P a g e
FUTURE SCOPE
In this project, for sending and receiving sms GSM modem is used. This GSM
This system can be used by computer software for sms purpose in place of
mobile phone.
We can use free sms service website for reducing sms charges.
34 | P a g e
REFERENCES
[1] T.B. Smith, “Electricity theft- comparative analysis,” Energy Policy, vol. 32, pp.
2067–2076, Aug. 2003.
[2] “Electricity thefts on the rise,” : http://www.wtsp.com/news
/local/story.aspx?storyid=109056.
[3] “Electricity theft: Dangerous trend that's costing honest Houstonians money,”
: http://www.khou.com/news/Electricity-theft-a-dangerous-trend-thats-costing-
honest-Houstonians-money-92450694.html.
[4] “Anti theft,” Maharashtra State Electricity Distribution Company, [Online].
Available: http://www.mahadiscom.in/anti-theft-photo/anti-theft-photo-01.jpg.
[5] V. J. Vibhute, “The 8051Microcontroller”.Chapter 4, 5, 6. Page 4.1-6.59
Second edition, publication-Tech Max.
[6] Muhammad Ali Mazidi, “The 8051 Microcontroller and Embedded Systems”.
Second edition, publication-prentice Hall.
[7] Vijay Garg, “Principles and Applications of GSM”, first edition. Publication-
prentice Hall.
35 | P a g e
APPENDICES
SOURCE CODE
#include<reg52.h>
//---------------------------------Defining Macros-------------
//
sbit RS=P3^7;
sbit EN=P3^6;
sbit RLY1=P1^0;
//---------------------------------------
// Forward function declaration
//---------------------------------------
void send_cmd(unsigned char *cmd);
void Txmsg(unsigned char *no,unsigned char *msg,unsigned char a1);
unsigned char Rxmsg(void);
void lcdinit(void);
void lcdclear(void);
void lcdData(unsigned char l);
void lcdcmd(unsigned char k);
void DelayMs(unsigned int count);
void InitModem(void);
void lcd_puts(unsigned char *p);
void uart_puts(unsigned char *p);
void uart_gets(unsigned char *p,unsigned char len);
void uart_putchar(unsigned char p);
void uart_getchar(unsigned char *p);
void wait();
36 | P a g e
void acknowledge();
void signal_strength(void);
//---------------------------------------
// Main rotine
//---------------------------------------
void main()
{
TMOD=0x40; // Configure UART at 9600 baud rate
TH1=0xFa;
SCON=0x50;
TR1=1;
EA=1;
EX0=1;
IT0=0;
RLY1=0;
}
}
//----------------------------------------------------
// send command subroutine to check the connectivity of modem
37 | P a g e
//----------------------------------------------------
//---------------------------------------
// Modem initialization subroutine
//---------------------------------------
retry:
j++;
send_cmd("at"); // AT command sending to check
the connectivity
lcdclear();
uart_puts("at+cmgs=\"");
lcdcmd(0xC0);
uart_puts(no);
DelayMs(100);
uart_putchar('"');
uart_putchar(0x0d);
lcdclear();
uart_getchar(buff);
uart_puts(msg);
while(a1!=0)
38 | P a g e
{
d1=a1%10;
d1+=0x30;
//digits before desible point
a1=a1/10;
d2=a1%10;
d2+=0x30;
a1=a1/10;
d3=a1%10;
d3+=0x30;
a1=a1/10;
}
uart_putchar(d3);
uart_putchar(d2);
uart_putchar(d1);
uart_putchar(26);
lcdclear();
uart_gets(buff,20);
DelayMs(1000);
//---------------------------------------
// Recieve message subroutine
//---------------------------------------
unsigned char Rxmsg(void)
{
unsigned char i=0,ret=0;
unsigned int j=0;
unsigned char c[84];
retry:
if(push==1)
{
return 4;
}
39 | P a g e
send_cmd("at"); // AT command sending to check
the connectivity
DelayMs(100);
lcdclear();
uart_puts("at+cmgr=1");
DelayMs(100);
uart_putchar(0x0d);
lcdcmd(0xC0);
EA=0;
for(i=0;i<84;i++)
{
j=0;
while(RI==0)
{
if(j>=TIMEOUT)
goto timeout;
wait();
j++;
}
c[i]=SBUF;
RI=0;
lcdData(c[i]);
}
//EA=1;
DelayMs(1000);
timeout:
for(i=0;i<5;i++) //command to recv data
{
if((c[i]=='O') || (c[i]=='K'))
return ret;
}
goto retry;
sucess1:
i=i+7;
for(j=0;j<13;j++)
{
mno[j]=c[i];
i++;
DelayMs(10);
}
40 | P a g e
mno[j]='\0';
for(;i<84;i++)
{
if((c[i]=='3') && (c[i+1]=='5') && (c[i+2]=='7') && (c[i+3]=='9') && (c[i+4]=='1'))
goto sucess;
}
goto delete;
sucess:
for(i=0;i<84;i++)
{
if((c[i]=='O') && (c[i+1]=='N'))
{
RLY1=1;
ret=1;
}
//---------------------------------------
// Lcd initialization subroutine
//---------------------------------------
void lcdinit(void)
{
lcdcmd(0x38);
DelayMs(250);
lcdcmd(0x0E);
DelayMs(250);
lcdcmd(0x01);
DelayMs(250);
lcdcmd(0x06);
DelayMs(250);
41 | P a g e
lcdcmd(0x80);
DelayMs(250);
}
//---------------------------------------
// Lcd initialization subroutine
//---------------------------------------
void lcdclear(void)
{
lcdcmd(0x01);
DelayMs(1);
lcdcmd(0x80);
DelayMs(1);
}
//---------------------------------------
// Lcd data display
//---------------------------------------
void lcdData(unsigned char l)
{
P2=l;
RS=1;
EN=1;
DelayMs(1);
EN=0;
}
//---------------------------------------
// Lcd command
//---------------------------------------
void lcdcmd(unsigned char k)
{
P2=k;
RS=0;
EN=1;
DelayMs(1);
EN=0;
}
//---------------------------------------
// Delay mS function
//---------------------------------------
void DelayMs(unsigned int count)
{
// mSec Delay 11.0592 Mhz
42 | P a g e
unsigned int i;
// Keil v7.5a
while(count) {
i = 115;
// 115 exact value
while(i>0) i--;
count--;
}
}
//---------------------------------------------------------------------------------------------------------
------------------
//--------------------------a small delay fxn to ensure the line settels down after transition---
----------------------------
void wait()
{
char i;
for(i=0;i<=10;i++)
i++;
return;
}
while(p[i]!='\0')
{
lcdData(p[i]);
if(i==16)
lcdcmd(0xC0);
i++;
}
}
43 | P a g e
void uart_putchar(unsigned char p)
{
SBUF=p;
while(TI==0);
TI=0;
}
i=0;
do
{
j=0;
while(RI==0)
{
if(j>=TIMEOUT)
break;
wait();
j++;
}
p[i]=SBUF;
RI=0;
lcdData(p[i]);
44 | P a g e
i++;
} while(p[i]!='>' && i<5);
}
void signal_strength(void)
{
unsigned char i,buff[12];
retry:
lcdclear();
uart_puts("at+csq"); // Sending Command
uart_putchar(0x0d); // Enter
lcdcmd(0xC0);
uart_gets(buff,12); // Receive response
DelayMs(1000);
45 | P a g e