You are on page 1of 26


Wireless electricity theft detection system using ZIGBEE technology present an efficient
and less costly way to adulterate the wireless technique used in this paper. This wireless system
is used to overcome the theft of electricity via bypassing the energy meter and hence it also
controls the revenue losses and utility of the electricity authorized agency. Mainly this system
consists of microcontroller, energy meter and a ZIGBEE module to check for the theft of
electricity and then to send a message to the authorized agency which looks after the electricity
consumed. The wireless technique used in this system provides the major advantages such as low
power consumption and also the low cost of the ZIGBEE module.

The electricity is needed to be protected for efficient power delivery to the consumer
because electricity is indispensable to domestic and industrial development activity. There are
two types of losses technical and Nontechnical losses. Every year the electricity companies fare
the line losses at an average 20-30% according to power ministry WAPDA Companys loss more
than RS.125 billion. T&D losses have been a concern for the Indian: electricity sector. Since
these have been very high when compared with other developed countries. The present T&D
losses including unaccounted energy are about 30% and there is need to reduce these losses
through efficient management the best operation and maintenance practice of the transmission
and distribution. When we talk about T&D losses it also includes the theft of electricity, although
it is the part of commercial loss but there is no way to segregate theft from the T&D losses. In
practice, we know the energy billed and the input energy the difference between these two is
T&D losses obviously the theft is included in this loss. SERC, Mop also ask to segregate T&D
loss and commercial loss but nobody is able to tell how these losses can be segregated, as theft
(the part of commercial loss) is embedded with T&D. Electricity theft is at the centre of focus all
over the world, but electricity theft in India has a significant effect on the Indian economy. The
loss on amount of theft is reflected in ARR of the electricity company. Thus these costs are
routinely passed on to the customers in the form of the higher energy charges.














PIC 16F877A


Power supply block consists of following units:
Step down transformer.
Bridge rectifier circuit.
Input filter.
Voltage regulators.
Output filter.
Indicator unit.


The step-down transformer is used to step down the supply voltage of 230v ac from
mains to lower values, as the various ICs used in this project require reduced voltages. The
transformer consists of primary and secondary coils.
To reduce or step down the voltage, the transformer is designed to contain less number of
turns in its secondary core. The outputs from the secondary coil which is center tapped are the ac
values of 0v, 15v and 15v. The conversion of these ac values to dc values to dc values is done
using the full wave rectifier unit.


A diode bridge is an arrangement of four diodes connected in a bridge circuit. That

provides the polarity of output voltage of any polarity of the input voltage. When used in its most
common application, for conversion of alternating current (A.C) input into direct current (D.C)
output, it is known as a bridge rectifier.
The diagram describes a diode-bridge design known as a full wave rectifier. This design
can be used to rectify single phase A.C. when no transformer center tap is available. 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.
For both positive and negative swings of the transformer, there is a forward path through
the diode bridge. Both conduction paths cause current to flow in the same direction through the
load resister, accomplishing full-wave rectification. While one set of diodes is forward biased,
the other set is reversing biased and effectively eliminated from the circuit.

Capacitors are used as filters. The ripples from the dc voltages are removed and pure dc
voltage is obtained. The primary action performed by capacitor is charging and discharging. It
charges in positive half cycle of the ac voltage and it will discharge in negative half cycle. So it
allows only ac voltage and does not allow the dc voltage. This filter is fixed before the regulator.
Capacitors used here are of the value 1000uF.

Regulator regulates the output voltage to a specific value.

The output voltage is

maintained irrespective of the fluctuations in the input dc voltage. Whenever there are any ac
voltage fluctuations, the dc voltage also changes, and to avoid this regulators are used.


1. Positive regulator, which regulates the positive voltage(7805,7812)

1. > input pin

2. > ground pin
3. > output pin

2. Negative regulator, which regulates the negative voltage (7912).

1. > ground pin
2. > input pin
3. > output pin

Regulators used in this application are: 7805 which provides 5v dc

7812 which provides 12v dc
7912 which provides -121v dc

This filter is fixed after the Regulator circuit to filter any of the possibly found ripples in
the output received finally. Capacitors used here are of value 10F.



Microcontroller PIC16F877A
The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with
the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256
bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit
Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port
that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave

High-Performance RISC CPU

Lead-free; RoHS-compliant
Operating speed: 20 MHz, 200 ns instruction cycle
Operating voltage: 4.0-5.5V
Industrial temperature range (-40 to +85C)
15 Interrupt Sources
35 single-word instructions
All single-cycle instructions except for program branches (two-cycle)

Special Microcontroller Features

Flash Memory: 14.3 Kbytes (8192 words)
Data SRAM: 368 bytes
Data EEPROM: 256 bytes
Self-reprogrammable under software control
In-Circuit Serial Programming via two pins (5V)
Watchdog Timer with on-chip RC oscillator
Programmable code protection
Power-saving Sleep mode

Selectable oscillator options

In-Circuit Debug via two pins

Peripheral Features
33 I/O pins; 5 I/O ports
Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler
Can be incremented during Sleep via external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
Two Capture, Compare, PWM modules
16-bit Capture input; max resolution 12.5 ns
16-bit Compare; max resolution 200 ns
10-bit PWM
Synchronous Serial Port with two modes:
SPI Master
I2C Master and Slave
USART/SCI with 9-bit address detection
Parallel Slave Port (PSP)
8 bits wide with external RD, WR and CS controls
Brown-out detection circuitry for Brown-Out Reset
Analog Features
10-bit, 8-channel A/D Converter
Brown-Out Reset

Analog Comparator module

2 analog comparators
Programmable on-chip voltage reference module
Programmable input multiplexing from device inputs and internal VREF
Comparator outputs are externally accessible










Since memory made in FLASH technology can be programmed and cleared more than once, it
makes this microcontroller suitable for device development.
EEPROM - data memory that needs to be saved when there is no supply.
It is usually used for storing important data that must not be lost if power supply suddenly stops.
For instance, one such data is an assigned temperature in temperature regulators. If during a loss
of power supply this data was lost, we would have to make the adjustment once again upon









RAM - Data memory used by a program during its execution.

In RAM are stored all inter-results or temporary data during run-time.
PORTS are physical connections between the microcontroller and the outside world.
PIC16F877A has five I/O Ports and 33 pins in all 5 ports.

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of

the program. On every fourth clock of the oscillator it increments its value until it reaches the
maximum (255), and then it starts counting over again from zero. As we know the exact timing
between each two increments of the timer contents, timer can be used for measuring time which
is very useful with some devices.

CENTRAL PROCESSING UNIT has a role of connective element between other blocks
in the microcontroller. It coordinates the work of other blocks and executes the user program.

Fig.3.1 Architectures of the System.

It has already been said that PIC16F877A has a RISC architecture. This term is often
found in computer literature, and it needs to be explained here in more detail. Harvard
architecture is a newer concept than von-Neumann's. It rose out of the need to speed up the work
of a microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a
greater flow of data is possible through the central processing unit, and of course, a greater speed
of work. Separating a program from data memory makes it further possible for instructions not to
have to be 8-bit words. PIC16F877A uses 14 bits for instructions which allows for all
instructions to be one word instructions. It is also typical for Harvard architecture to have fewer
instructions than von-Neumann's, and to have instructions usually executed in one cycle.
Microcontrollers with Harvard architecture are also called "RISC microcontrollers".
RISC stands for Reduced Instruction Set Computer. Microcontrollers with von-Neumann's
architecture are called 'CISC microcontrollers'. Title CISC stands for Complex Instruction Set
Since PIC16F877A is a RISC microcontroller, that means that it has a reduced set of
instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have
over hundred instructions) All of these instructions are executed in one cycle except for jump and
branch instructions. According to what its maker says, PIC16F877A usually reaches results of
2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its class.

PIC16F877A perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is
also ideal for smart cards as well as for battery supplied devices because of its low consumption.
EEPROM memory makes it easier to apply microcontrollers to devices where permanent
storage of various parameters is needed (codes for transmitters, motor speed, receiver
frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F877A
applicable even in areas where microcontrollers had not previously been considered (example:
timer functions, interface replacement in larger systems, coprocessor applications, etc.).
System Programmability of this chip (along with using only two pins in data transfer)
makes possible the flexibility of a product, after assembling and testing have been completed.
This capability can be used to create assembly-line production, to store calibration data available
only after final testing, or it can be used to improve programs on finished products.

Clock / instruction cycle

Clock is microcontroller's main starter, and is obtained from an external component
called an "oscillator". If we want to compare a microcontroller with a time clock, our "clock"
would then be a ticking sound we hear from the time clock. In that case, oscillator could be
compared to a spring that is wound so time clock can run. Execution of instruction starts by
calling an instruction that is next in string. Instruction is called from program memory on every
Q1 and is written in instruction register on Q4. Decoding and execution of instruction are done
between the next Q1 and Q4 cycles. On the following diagram we can see the relationship
between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks
Q1-Q4. Program counter (PC) holds information about the address of the next instruction.

Fig 3.2 Clock/Instruction Cycle

Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing
instructions are connected in such a way that in order to make a call, one instruction cycle is
needed, and one more is needed for decoding and execution. However, due to pipelining, each
instruction is effectively executed in one cycle. If instruction causes a change on program
counter, and PC doesn't point to the following but to some other address (which can be the case
with jumps or with calling subprograms), two cycles are needed for executing an instruction.
This is so because instruction must be processed again, but this time from the right address.
Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and
executing begins with Q2, Q3 and Q4 clocks.

Fig 3.3 Instruction Pipeline Flow

TCY0 reads in instruction MOVLW 55h (it doesn't matter to us what instruction
was executed, because there is no rectangle pictured on the bottom).TCY1 executes instruction
MOVLW 55h and reads in MOVWF PORTB.TCY2 executes MOVWF PORTB and reads in
CALL SUB_1.TCY3 executes a call of a subprogram CALL SUB_1, and reads in instruction
BSF PORTA, BIT3. As this instruction is not the one we need, or is not the first instruction of a
subprogram SUB_1 whose execution is next in order, instruction must be read in again. This is a
good example of an instruction needing more than one cycle. TCY4 instruction cycle is totally

used up for reading in the first instruction from a subprogram at address SUB_1.TCY5 executes
the first instruction from a subprogram SUB_1 and reads in the next one.

Pin description
PIC16F877A has a total of 40 pins. It is most frequently found in a DIP40 type of case
but can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual
In Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to
go through when mounting aren't necessary in soldering this type of a component.

Fig.3.4 Pin Diagram of PIC16F877A

A relay is

an electrically operated switch.




an electromagnet to

mechanically operate a switch, but other operating principles are also used, such as solid-state
relays. Relays are used where it is necessary to control a circuit by a low-power signal (with
complete electrical isolation between control and controlled circuits), or where several circuits
must be controlled by one signal. The first relays were used in long distance telegraph circuits as
amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another
circuit. Relays were used extensively in telephone exchanges and early computers to perform
logical operations.

A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform switching. Relays with
calibrated operating characteristics and sometimes multiple operating coils are used to protect
electrical circuits from overload or faults; in modern electric power systems these functions are
performed by digital instruments still called "protective relays".


A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core,
an iron yoke which provides a low reluctancepath for magnetic flux, a movable iron armature,
and one or more sets of contacts (there are two in the relay pictured). The armature is hinged to
the yoke and mechanically linked to one or more sets of moving contacts. It is held in place by
a spring so that when the relay is de-energized there is an air gap in the magnetic circuit. In this
condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open.
Other relays may have more or fewer sets of contacts depending on their function. The relay in
the picture also has a wire connecting the armature to the yoke. This ensures continuity of the
circuit between the moving contacts on the armature, and the circuit track on the printed circuit
board (PCB) via the yoke, which is soldered to the PCB.

When an electric current is passed through the coil it generates a magnetic field that
activates the armature, and the consequent movement of the movable contact(s) either makes or
breaks (depending upon construction) a connection with a fixed contact. If the set of contacts
was closed when the relay was de-energized, then the movement opens the contacts and breaks
the connection, and vice versa if the contacts were open. When the current to the coil is switched
off, the armature is returned by a force, approximately half as strong as the magnetic force, to its
relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in
industrial motor starters. Most relays are manufactured to operate quickly. In a low-voltage
application this reduces noise; in a high voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise
generate a voltage spike dangerous to semiconductor circuit components. Some automotive
relays include a diode inside the relay case. Alternatively, a contact protection network consisting
of a capacitor and resistor in series (snubbercircuit) may absorb the surge. If the coil is designed
to be energized with alternating current (AC), a small copper "shading ring" can be crimped to
the end of the solenoid, creating a small out-of-phase current which increases the minimum pull
on the armature during the AC cycle.[1]
Relays are used wherever it is necessary to control a high power or high voltage circuit
with a low power circuit. The first application of relays was in long telegraph systems, where the
weak signal received at an intermediate station could control a contact, regenerating the signal
for further transmission. High-voltage or high-current devices can be controlled with small, low
voltage wiring and pilots switches. Operators can be isolated from the high voltage circuit. Low
power devices such as microprocessors can drive relays to control electrical loads beyond their
direct drive capability. In an automobile, a starter relay allows the high current of the cranking
motor to be controlled with small wiring and contacts in the ignition key.



including Strowger and Crossbar telephone

exchanges made extensive use of relays in ancillary control circuits. The Relay Automatic
Telephone Company also manufactured telephone exchanges based solely on relay switching
techniques designed by Gotthilf Ansgarius Betulander. The first public relay based telephone

exchange in the UK was installed in Fleetwood on 15 July 1922 and remained in service until
The use of relays for the logical control of complex switching systems like telephone
exchanges was studied by Claude Shannon, who formalized the application of Boolean
algebra to relay circuit design in A Symbolic Analysis of Relay and Switching Circuits. Relays
can perform the basic operations of Boolean combinatorial logic. For example, the boolean AND
function is realised by connecting normally open relay contacts in series, the OR function by
connecting normally open contacts in parallel. Inversion of a logical input can be done with a
normally-closed contact. Relays were used for control of automated systems for machine tools
and production lines. The Ladder programming language is often used for designing relay
logic networks.

Early electro-mechanical computers such as the ARRA, Harvard Mark II, Zuse Z2,
and Zuse Z3 relays for logic and working registers. However, electronic devices proved faster
and easier to use.
Because relays are much more resistant than semiconductors to nuclear radiation, they
are widely used in safety-critical logic, such as the control panels of radioactive waste-handling
machinery. Electromechanical protective relays are used to detect overload and other faults on
electrical lines by opening and closing circuit breakers.

ZigBee is a specification for a suite of high-level communication protocols used to
create personal area networks built from small, low-power digital radios. ZigBee is based on
an IEEE 802.15.4 standard. Though its low power consumption limits transmission distances to

meters line-of-sight,







characteristics, ZigBee devices can transmit data over long distances by passing data through
a mesh network of intermediate devices to reach more distant ones. ZigBee is typically used in
low data rate applications that require long battery life and secure networking (ZigBee networks
are secured by 128 bit symmetric encryption keys.) ZigBee has a defined rate of 250 kbit/s, best
suited for intermittent data transmissions from a sensor or input device. Applications include
wireless light switches, electrical meters with in-home-displays, traffic management systems, and
other consumer and industrial equipment that requires short-range low-rate wireless data transfer.
The technology defined by the ZigBee specification is intended to be simpler and less expensive
than other wireless personal area networks (WPANs), such as Bluetooth or Wi-Fi.
ZigBee is a low-cost, low-power, wireless mesh network standard targeted at wide
development of long battery life devices in wireless control and monitoring applications. Zigbee
devices have low latency, which further reduces average current. ZigBee chips are typically
integrated with radios and with microcontrollers that have between 60-256 KB flash memory.
ZigBee operates in the industrial, scientific and medical (ISM) radio bands: 2.4 GHz in most
jurisdictions worldwide; 784 MHz in China, 868 MHz in Europe and 915 MHz in the USA and
Australia. Data rates vary from 20 kbit/s (868 MHz band) to 250 kbit/s (2.4 GHz band).




natively supports

both star and tree networks,


generic Mesh networking. Every network must have one coordinator device, tasked with its
creation, the control of its parameters and basic maintenance. Within star networks, the
coordinator must be the central node. Both trees and meshes allow the use of ZigBee routers to
extend communication at the network level.
ZigBee builds on the physical layer and media access control defined in IEEE standard
802.15.4 for low-rate WPANs. The specification includes four additional key components:

network layer, application layer, ZigBee device objects (ZDOs) and manufacturer-defined
application objects which allow for customization and favor total integration. ZDOs are
responsible for a number of tasks, including keeping track of device roles, managing requests to
join a network, as well as device discovery and security .

ZigBee is one of the global standards of communication protocol formulated by the

relevant task force under the IEEE 802.15 working group. The fourth in the series, WPAN Low
Rate/ZigBee is the newest and provides specifications for devices that have low data rates,
consume very low power and are thus characterized by long battery life. Other standards like
Bluetooth and IrDA address high data rate applications such as voice, video and LAN

Input Voltage - 5Volts DC

Baud Rate - 9600 RS 232 Interface & TTL Interface
Range Max 30 Mtrs - Line of Sight
Channels - 3 Ch - JP1 & JP2 - Ch 1 On On

Released specifications:

ZigBee Home Automation 1.2

Smart Energy 1.1b

Telecommunication Services 1.0

Health Care 1.0

RF4CE Remote Control 1.0

RF4CE Input Device 1.0

Remote Control 2.0

Light Link 1.0

IP 1.0

Building Automation 1.0

Gateway 1.0

Green Power 1.0 (Optional feature of ZigBee 2012)

Retail Services

The ZigBee Smart Energy V2.0 specifications define an IP-based protocol to monitor,
control, inform and automate the delivery and use of energy and water. It is an enhancement of
the ZigBee Smart Energy version 1 specifications, [14] adding services for plug-in electric
vehicle (PEV) charging, installation, configuration and firmware download, prepay services, user

information and messaging, load control, demand response and common information and
application profile interfaces for wired and wireless networks. It is being developed by partners

HomeGrid Forum responsible for marketing and certifying ITU-T technology and

HomePlug Powerline Alliance

International Society of Automotive Engineers SAE International

IPSO Alliance

SunSpec Alliance

Wi-Fi Alliance.
In 2009 the RF4CE (Radio Frequency for Consumer Electronics) Consortium and ZigBee

Alliance agreed to jointly deliver a standard for radio frequency remote controls. ZigBee RF4CE
is designed for a wide range of consumer electronics products, such as TVs and set-top boxes. It
promises many advantages over existing remote control solutions, including richer
communication and increased reliability, enhanced features and flexibility, interoperability, and
no line-of-sight barrier.[15] The ZigBee RF4CE specification lifts off some networking weight and
does not support all the mesh features, which is traded for smaller memory configurations for
lower cost devices, such as remote control of consumer electronics.
With the introduction of the second ZigBee RF4CE application profile in 2012 and increased
momentum in MSO market, the ZigBee RF4CE team provides an overview on current status of
the standard, applications, and future of the technology.


The radio design used by ZigBee has been carefully optimized for low cost in large scale
production. It has few analog stages and uses digital circuits wherever possible.
Though the radios themselves are inexpensive, the ZigBee Qualification Process involves a
full validation of the requirements of the physical layer. All radios derived from the same
validated semiconductor mask set would enjoy the same RF characteristics. An uncertified
physical layer that malfunctions could cripple the battery lifespan of other devices on a ZigBee
network. ZigBee radios have very tight constraints on power and bandwidth. Thus, radios are
tested with guidance given by Clause 6 of the 802.15.4-2006 Standard. Most vendors plan to
integrate the radio and microcontroller onto a single chip[18] getting smaller devices.







2.4 GHz (worldwide),

915 MHz (Americas and Australia) and 868 MHz (Europe) ISM bands. Sixteen channels are
allocated in the 2.4 GHz band, with each channel spaced 5 MHz apart, though using only 2 MHz
of bandwidth. The radios use direct-sequence spread spectrum coding, which is managed by the
digital stream into the modulator. Binary phase-shift keying (BPSK) is used in the 868 and
915 MHz bands, and offset quadrature phase-shift keying (OQPSK) that transmits two bits per
symbol is used in the 2.4 GHz band.
The raw, over-the-air data rate is 250 kbit/s per channel in the 2.4 GHz band, 40 kbit/s per
channel in the 915 MHz band, and 20 kbit/s in the 868 MHz band. The actual data throughput
will be less than the maximum specified bit rate due to the packet overhead and processing

delays. For indoor applications at 2.4 GHz transmission distance may be 1020 m, depending on
the construction materials, the number of walls to be penetrated and the output power permitted
in that geographical location. Outdoors with line-of-sight, range may be up to 1500 m depending
on power output and environmental characteristics.

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide
range of applications. A 16x2 LCD display is very basic module and is very commonly used in
various devices and circuits. These modules are preferred over seven segments and other multi
segment LEDs. The reasons being: LCDs are economical; easily programmable; have no
limitation of displaying special & even custom characters (unlike in seven segments), animations
and so on.A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In
this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data.The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it, clearing its
screen, setting the cursor position, controlling display etc. The data register stores the data to be
displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.


Pin Description:




Ground (0V)
Supply voltage; 5V (4.7V 5.3V)

Selects command register when low; and data register when high

Register Select


Low to write to the register; High to read from the register

Sends data to data pins when a high to low pulse is given
8-bit data pins



resistor VEE


Backlight VCC (5V)

Backlight Ground (0V)