Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 80

KWAME NKRUMAH UNIVERSITY OF SCIENCE AND TECHNOLOGY

COLLEGE OF ENGINEERING

DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

PROJECT REPORT ON

GSM BASED AUTOMATIC ENERGY METER READING

BY

BADU GODSWAY 4805610

AMAMOO MENSAH NANA 4803310

GADOGBE BRYCE SENA 4808110

Supervisor: DR. PHILIP YAW OKYERE

JANUARY, 2014
ABSTRACT

Electricity is one of the vital requirements for the sustainment of a comfortable and productive
life and as such it should be used judiciously for its proper utilization. Consumers are not
satisfied with the services of power companies with the existing energy meter reading and billing
system. Most of the time they have complains regarding statistical errors in their monthly bills.
The objective of our project is to design and implement an automatic energy meter reading
system that measures and transmits total energy consumption to the Electricity Provider using
the GSM network as well as disconnect or reconnect the meter remotely. This can be achieved
by the use of a microcontroller unit that continuously monitors and records the energy meter
readings in its permanent memory location and a GSM modem that enables the remote
monitoring and control of the energy meter.

The proposed Microcontroller based system continuously records the readings and the live meter
reading can be sent to the provider using the existing short messaging services (SMS) of the
GSM network on request. This system can also be used to disconnect or reconnect the power
supply to the consumer if the need arises. A dedicated GSM modem with a SIM card interfaced
to the ports of the microcontroller is required for each energy meter. With this, a great deal of
energy is saved and the consumer enjoys maximum satisfaction of the electrical energy paid for;
hence an improvement, stability and utilization of electrical energy are achieved as well as
reduction on human dependency.

i
LIST OF ABBREVIATIONS
GSM General System for Mobile Communication

AMR Automatic Meter Reading

RF Radio Frequency

PLC Power Line Carrier

AC Alternating Current

PMWCM Power Meter with Wi-Fi Communication


Module

GAPMR GSM Automatic Power Meter Reading

GPM GSM Power Meter

SMS Short Messaging Service

SIM Subscriber Identity Module

RISC Reduced Instruction Set Computer

EEPROM Electrically Erasable Programmable ROM

UART Universal Asynchronous Receiver


Transmitter

AT command ATtention command

PIC Programmable Interface Controller

LCD Liquid Crystal Display

DC Direct Current

RTC Real Time Counter

IC Integrated Circuit

LED Light Emitter Diode

PC Personal Computer

GPRS General Packet Radio Service

FWAMR Fault-tolerant Wireless Automatic Meter


Reading

ii
CLMCS Customer Load Monitoring and Control
System

EPROM Erasable Programmable ROM

ADC Analog to Digital Convertor

PWM Pulse wave Modulation

AVR Advance Virtual RISC

CISC Complex Instruction Set Computers

CPU Central Processing Unit

POR Power- on Reset

ICSP In-Circuit Serial Programming

PSP Parallel Slave Port

SSP Serial Slave Port

WDT Watch Dog Timer

TDMA Time Division Multiple Access

FDM Frequency Division Multiplexing

GMSK Gaussian Minimum Shift Keying

FDD Frequency Division Duplex

PCMCIA Personal Computer memory Card


International Authority

USB Universal Serial Bus

iii
TABLE OF CONTENT

CHAPTER ONE........................................................................................................................................1
INTRODUCTION.....................................................................................................................................1
1.1 Introduction..........................................................................................................................................1
CHAPTER TWO.........................................................................................................................................3
LITERATURE REVIEW............................................................................................................................3
2.1 Introduction........................................................................................................................................3
2.2 History of automatic meter reading....................................................................................................3
2.3 Automatic meter reading technologies.............................................................................................4
2.4 GSM based automatic meter reading.............................................................................................8
CHAPTER THREE...................................................................................................................................13
THEORY...................................................................................................................................................13
3.1 Block Diagram.................................................................................................................................13
3.2 Microcontroller................................................................................................................................14
This significantly shows that the choice of microcontrollers to be used depends on it application. Due to
dependence on what it would be used to implement, cost involved, its efficiency and capabilities,
microcontrollers vary widely and come in different specifications............................................................16
3.2.1 PIC Microcontroller.............................................................................................................16
3.2.1.2 Memory Organization.......................................................................................................18
3.2.1.3 Data EEPROM and Flash Memory.......................................................................................19
3.2.1.4 I/O Ports..............................................................................................................................19
3.2.1.5 Watchdog Timer (WDT).......................................................................................................20
3.2.1.6 Analog-To-Digital Converter (A/D) Module..........................................................................20
3.2.1.7 Addressable Universal Synchronous Asynchronous Receiver Transmitter [USART].........20
3.2.1.8 Ports/pins and their functions [30].......................................................................................21
3.3 GSM (Global System for Mobile Communication)...........................................................................26
3.3.1 Introduction............................................................................................................................26
3.3.2 GSM Network.......................................................................................................................27
3.3.3 Short Message Service (SMS)...............................................................................................29
3.3.4 GSM Modem.........................................................................................................................29
3.3.5 Interfacing the GSM module...................................................................................................32
iv
3.4.1 Electromechanical Energy Meter...........................................................................................33
3.4.2 Electronic meters..................................................................................................................34
3.5 Relay..............................................................................................................................................35
3.5.1 Basic design and operation.....................................................................................................36
3.5.2 Types of Relays.......................................................................................................................36
3.5.2.1 Solid State Relays........................................................................................................................37
3.5.3 Interfacing the relay................................................................................................................39
3.6 Liquid Crystal Display (LCD)...................................................................................................40
3.6.1 Pin Diagram.............................................................................................................................41
3.6.3 Basic Commands of LCD............................................................................................................42
3.6.4 Interfacing of LCD....................................................................................................................43
3.7 Power supply unit......................................................................................................................43
3.7.1 Transformer............................................................................................................................44
3.7.2 Rectifying unit.........................................................................................................................44
3.7.3 Filtering unit............................................................................................................................45
3.7.4 Voltage regulator.....................................................................................................................45
3.8 Flow Chart.................................................................................................................................46
CHAPTER FOUR..........................................................................................................................................48
METHODOLOGY....................................................................................................................................48
4.1 Introduction..................................................................................................................................48
4.2 Steps taken so far........................................................................................................................48
4.3 Steps to be taken..........................................................................................................................48
CHAPTER FIVE.......................................................................................................................................49
IMPLEMENTATION AND RESULTS..............................................................................................................49
5.1 DESIGN CONSIDERATION.....................................................................................................49
5.2 DESIGN SPECIFICATIONS..............................................................................................................50
5.3 Subsystems of the Design............................................................................................................51
5.3.4 Power Supply Circuit.................................................................................................................53
5.4 COMPLETE CIRCUIT AND MODE OF OPERATTION.......................................................................54
5.5 TESTING AND RESULTS................................................................................................................56
5.5.1 DISCUSSION OF RESULTS..........................................................................................................56
CHAPTER SIX..............................................................................................................................................57
6.1 CONCLUSION......................................................................................................................................57
6.2 FURTHER WORK.................................................................................................................................57

v
REFERENCES..........................................................................................................................................58

TABLE OF FIGURES

Figure 1 : Block Diagram of AMR............................................................................................................13


Figure 2 : Pin Diagram of PIC16F77A......................................................................................................16
Figure 3: SIM300 GSM Modem..................................................................................................................30
Figure 4 :PIC16F887A interfaces with the GSM module..........................................................................32
Figure 5: Electromechanical energy meter................................................................................................34
Figure 6 : Electronic energy meter.............................................................................................................35
Figure 7 : Solid State Relay........................................................................................................................37
Figure 8 : Latching Relay............................................................................................................................38
Figure 9 : Polarized Relay.........................................................................................................................38
Figure 10 : Reed Relay..............................................................................................................................39
Figure 11 :PIC16F877A interfaced with a relay..........................................................................................40
Figure 12 : Pin Diagram of LCD Display......................................................................................................41
Figure 13: PIC16F877A interfaced with 2X16 LCD.....................................................................................43
Figure 14: Block diagram of power supply unit........................................................................................44
Figure 15: Schematic diagram for power supply unit................................................................................44

vi
vii
CHAPTER ONE

INTRODUCTION

1.1 Introduction
A large portion of meter reading for electricity consumption is done by human operators who
move from building to building to collect data for generating the bill. Disconnection of power
supply in the case of consumers who do not pay their bills also requires the human operator to
visit the premises. This requires a large number of operators and long working hours to cover the
required area of interest. This system of meter reading for billing is highly susceptible to human
errors and is time consuming. The operation can be restricted or slowed down by bad weather
conditions. This billing system is inaccurate, inefficient and increases the energy provider
operation cost for meter reading. Recently, the prepaid electronic energy meter was introduced
which partially solved the problem of the need to visit the site in order to take meter readings.
However, some problems still exist as the prepaid card can be easily damaged or lost, the
inability to provide real-time monitoring and the inability to avoid theft are also disadvantages
[1]. As the number of electricity consumers as well as the commercial activities in the electrical
industry increases to a great extent coupled with the fast paced advancement in wireless
communication technology and microelectronics, it became increasingly important to develop
automatic electric energy meters to replace the traditional manual energy meters in order to
achieve efficient meter reading, reduce billing error and operational cost. The Automatic meter
reading is an effective means for data collection that ensures greater data accuracy, allows
frequent reading, improved billing and customer service, timely energy profiles and consumption
trend updates and better use of human resources. Several solutions based on various technologies
such as Wi-Fi, Bluetooth, internet, embedded Radio frequency module and power line
communication have been suggested and developed to provide the efficiency, reliability and
effectiveness of Automatic Energy Meter system. However, these methods either require a
complex setup of infrastructure, are too expensive to implement and operate, or have short
operating distance and still require field intervention of human operators [2][3]. The GSM based
Automatic Energy Meter described in this project takes advantage of the available nationwide
coverage of the GSM infrastructure in the country and the Short Message Service (SMS) feature
to achieve the purpose of an efficient, reliable and effective meter reading system.

1
Aim

The aim of the project is to design a GSM based automatic energy meter reading system.

Objectives

 To design a microcontroller based system to monitor and control domestic energy meter.
 To use a GSM modem to implement monitoring and control in the system.
 To remotely disconnect power supply to the house.

2
CHAPTER TWO

LITERATURE REVIEW

2.1 Introduction
Automatic Meter Reading is the remote collection of consumption data from customers' utility
like Electric meter using radio frequency, telephony, power-line or satellite communication
technologies and processing the collected data to generate the bill and for analysis [4]. Various
Automatic Meter Reading System designs using a variety of technologies have been proposed
and implemented in many countries.

2.2 History of automatic meter reading


The Automated Meter Reading was first tested in 1962 by AT&T in cooperation with a group of
utility companies. After those successful experiments, AT&T offered to provide phone system-
based Automatic Meter Reading services at $2 per meter four times more than the monthly cost
of a person to read the meter at 50 cents. Thus the program was considered economically
unfeasible. The modern era of automatic meter reading began in 1985, when several major full-
scale projects were implemented. Hackensack Water Co. and Equitable Gas Co. were the first to
commit to full-scale implementation of automatic meter reading on water and gas meters,
respectively. In 1986, Minnegasco initiated a 450,000- point radio-based automatic meter
reading system. In 1987, Philadelphia Electric Co., faced with a large number of inaccessible
meters, installed thousands of distribution line carrier automatic meter reading units to solve this
problem. Advances in solid-state electronics, microprocessor components and low-cost surface-
mount technology assembly techniques have facilitated the production of reliable cost-effective
solutions capable of providing the economics and human benefits that justify automatic meter
reading systems on a large, if not full-scale basis [5].

3
2.3 Automatic meter reading technologies
AMR can be implemented using a variety of technologies depending on the scope available
infrastructure and network topologies. Automatic Meter Reading (AMR) technologies include
handheld, mobile and network technologies based on wired and wireless telephony platforms,
radio frequency (RF) or power line transmission. Some existing meter reading techniques
include Touch Technology AMR, Radio Frequency AMR comprising Handheld, Mobile or
"Drive-by" meter reading and Fixed Network AMR, Power Line Communication AMR, Wi–Fi
and Bluetooth based techniques.

With the touch based AMR, a meter reader carries a handheld computer or data collection device
with a probe. The device automatically collects the readings from a meter by touching or placing
the read probe in close proximity to a reading coil enclosed in the touchpad. When a button is
pressed, the probe sends an interrogate signal to the touch module to collect the meter reading.
The software in the device matches the serial number to one in the route database, and saves the
meter reading for later download to a billing or data collection computer. However, the meter
reader still has to go to the site of the meter. [7]

Radio frequency based AMR can take many forms. The more common ones are Handheld,
Mobile, and Fixed network. There are both two-way RF systems and one-way RF systems in use
that use both licensed and unlicensed RF bands.

In a two-way system, a radio transceiver normally sends a signal to a particular transmitter serial
number, telling it to wake up from a resting state and transmit its data. The Meter attached
transceiver and the reading transceiver both send and receive radio signals and data. In a one-
way “bubble-up” or continuous broadcast type system, the transmitter broadcasts readings
continuously every few seconds. This means the reading device can be a receiver only, and the
meter AMR device a transmitter only. Data goes one way, from the meter AMR transmitter to
the meter reading receiver. There are also hybrid systems that combine one-way and two-way
technologies, using one-way communication for reading and two way communication for
programming functions.
Handheld AMR is where a meter reader carries a handheld computer with a built-in or attached
receiver/transceiver (radio frequency or touch) to collect meter readings from an AMR capable
meter. Mobile or "Drive-by" meter reading is where a reading device is installed in a vehicle.

4
The meter reader drives the vehicle while the reading device automatically collects the meter
readings.

These technologies however, still require that the meter reader visits the houses, offices and other
places where the meters are placed. To eliminate this problem, Gurkan Tuna in [6], proposed the
use of unmanned aerial vehicles for automatic meter reading applications and investigated its
potential advantages and associated design challenges. This approach eliminates the need for
installed wired and wireless network infrastructures and can be integrated to existing AMR
systems.

Another form of the Radio frequency based AMR is the Fixed Network AMR. It is a method
where a network is permanently installed to capture meter readings. This method consists of a
series of antennas, towers, collectors, repeaters, or other permanently installed infrastructure to
collect transmissions of meter readings from AMR capable meters and get the data to a central
computer without a person in the field to collect it. There are several types of network
topologies in use to get the meter data back to a central computer. A star network is the most
common, where a meter transmits its data to a central collector or repeater. Some systems use
only collectors which receive and store data for processing. Others also use a repeater which
forwards a reading from a more remote area back to a main collector without actually storing it.
A repeater may be forwarded by RF signal or sometimes is converted to a wired network such as
telephone or IP network to get the data back to a collector. Some manufacturers are
developing mesh networks where meters themselves act as repeaters passing the data to nearby
meters until it makes it to a main collector. The Swedish city of Gothenburg is having their
electric meters connected in this manner, using the ZigBee protocol. A mesh network may save
the infrastructure of many collection points, but is more data intensive on the meters. One issue
with mesh networks is that the battery operated ones may need more power for the increased
frequency of transmitting. It also requires that the meter devices be receivers as well as
transmitters potentially making individual transceiver cost higher. However, the additional cost
may be outweighed by the savings of multiple collectors and repeater antennas and finding
places to mount them.
Some fixed network systems are also capable of being installed as a hybrid AMR system where
mobile and fixed network are intermixed by design. In a hybrid system, part of the system is read
by fixed network, and parts may be read by mobile or other technology, or both. Utilities with
low density rural areas may not cost justify the fixed network infrastructure for parts of their

5
service area, using it only for higher density zones or commercial accounts. Some hybrid
networks allow reading of a meter by both methods concurrently as a source of redundancy. In
the event of a failure of the network due to a natural disaster, sabotage, power failure, or other
network interruption, the mobile reading system is available in their disaster recovery plan as an
alternative means of data collection to the fixed network. [7] [8]

Another ARM technology that makes use of some sort of a “fixed network” is the Power Line
Carrier Communication. Power line communication is very popular in the automatic meter
reading field. Power line Carrier (PLC) AMR makes use of the existing AC (Alternating
Current) electrical power lines as the network medium to provide high speed network access
points in order to transmit electronic data back to the substation, then relayed to a central
computer in the utility's main office. This would be considered a type of fixed network system.
The network being the distribution network which the utility has built and maintains to deliver
electric power. This technology provides the flow of information through the same cable that
supplies electrical power. The powering and signaling circuits are separated by a high-pass filter,
called a coupling interface. The coupling interface makes it possible to connect different circuits
with different voltage levels. [7] [8] [9] [10]
In most cases, building a PLC network using the existing AC electrical wiring is easier than
other networking systems and relatively inexpensive as well. According to Tasfin Mohaimeen
Haq in [10], this method of automatic meter reading however encounters a lot of technical
challenges as the power line is made for transmission of power at 50 or 60 Hz and medium
maybe required to transmit data at high frequencies. The high voltage power line is one of the
most electrically contaminated environments, which makes it very hostile for transmission of
data signals. The channel is characterized by high noise levels and uncertain or varying levels of
impedance and attenuation. In addition, the line offers limited bandwidth in comparison to cable
or fiber-optic links. Power line networks are usually made of a variety of conductor types and
cross sections joined almost at random. Therefore a variety of characteristic impedances are
encountered in the network. This also imposes difficulties in designing the filters for the carrier
communication networks. All these challenges affects the reliability of the Power line Carrier
channel and hence the reading of the meters. Overcoming these challenges makes this method
very complicated to implement. [10]

6
There are also meters using AMR with RF technologies such as Wi-Fi and Bluetooth which
operate on unlicensed frequency bands. Bluetooth is a wireless technology standard for
exchanging data over short distances. Bluetooth operates in the globally unlicensed Industrial,
Scientific and Medical (ISM) 2.4 GHz short-range radio frequency band. According to B.S.
Koay et al in [11], The Bluetooth team from Network Technology Research Center of Nanyang
Technological University in Singapore designed and developed wireless energy meter based on
Bluetooth technology. The design of the Bluetooth based energy meter was divided into two
phases. The first phase was to build an interface between the digital energy meter and the
Bluetooth module. The second phase was to implement the commercially sound application of
the Bluetooth energy meter. Two methods were used in retrieving data from the wireless energy
meter. They are the automatic meter reading (AMR) and automatic polling mechanism (APM).
The ARM method is where information on the power consumption of a household in certain
interval of time is sent to the wirelessly connected reader which is normally a PC. Meanwhile,
APM is another where the energy reader PC polls each and every individual energy meter to
retrieve information or data on the power consumption of every household.

The Wi-Fi is also a short-range wireless technology that uses the 2.4 GHz frequency band. The
network by Wi-Fi is free to use and so greatly reduces the construction and maintenance costs of
AMR system. The Wi-Fi LAN can connect to remote manage center by many ways, such as
through fiber, wire or wireless. As pointed out by Li Li , Xiaoguang Hu and Weicun Zhang in
[12], compared to Bluetooth, the Wi-Fi has a broader transmission coverage; about 100 metres
indoors and 300 metres outdoor as opposed to 15 metres for the Bluetooth. Also, unlike the Blue
tooth, Wi-Fi radio wave can transmit data through load-bearing walls. The city of Corpus
Christi became one of the first cities in the United States to implement city wide Wi-Fi, which
had been free until May 31, 2007, mainly to facilitate AMR after a meter reader was attacked by
a dog. The meters installed in Corpus Christi are not directly Wi-Fi enabled, but rather transmit
narrow-band burst telemetry on the 460 MHz band. This narrow-band signal has a much greater
range than Wi-Fi, so the number of receivers required for the project are far fewer than the
number of Wi-Fi access points covering the same area [7] [8]. These special receiver stations
then take in the narrow-band signal and report their data via Wi-Fi. Today, many meters are
designed to transmit using Wi-Fi, even if a Wi-Fi network is not available, and they are read
using a drive-by local Wi-Fi hand held receiver. In [12], Li Li, Xiaoguang and Weicun Zhang
proposed an AMR system scheme using Wi-Fi technology and an ARM-Based PMWCM (Power
Meter with Wi-Fi Communication Module) scheme. On the basis of the schemes, the designs of
7
the PMWCM hardware system and software system are proposed. The paper also proposes the
functions of wireless communication module and design detail and discusses the security of the
communications.

2.4 GSM based automatic meter reading

The above mentioned methods are either too expensive to implement and operate, require
complex setup of infrastructure, short operating distance or still require field intervention of
human operators to take readings from locations where the meters are placed. The rapid
development of global system for mobile (GSM) infrastructure in the past few decades has made
Automatic Energy Meter system more reliable and possible.

In Automatic Power Meter Reading System Using GSM Network, H.G. Rodney Tan et al
presented the development of a GSM Automatic Power Meter Reading System (GAPMR). This
system consist of two main subsystems, the GSM Digital Power Meters installed in every
consumer unit and electricity e-billing system consisting of an SMS Gateway, Application
Terminal, Database Server, Email Server, Printer Server, web Server and E- commerce Server at
the energy provider side. The system makes use of the existing GSM infrastructure to retrieve
meter readings through its Short Message Service Feature. The GSM Power Meter (GPM)
consists of standard compliance digital kWh power meter with embedded GSM modem which
utilizes the GSM network to send its power usage reading using SMS back to energy provider
wirelessly upon request from the Energy provider SMS gateway. A SIM card with a unique
number is required for the GPM to receive and transmit its meter readings to the energy provider
using SMS. SIM card service number is also used to identify and retrieve the customer details
from the database server for billing purposes. The design of the GSM Power Meter Presented is
an integration of single phase standard compliance digital kWh power meter, Power to
Communication interface board and a GSM modem. An optocoupler is used to couple the
impulse count to any external electronic circuit without direct contact with the power meter
circuitry. The power to communication interface board was implemented by two RISC
microcontrollers. The power microcontroller is used to interface the impulse and synchronize
count from the power meter optocoupler circuit and store the meter reading into its internal non-
volatile EEPROM memory at every single impulse count interval. On the communication side,
the communication microcontroller is used to communicate with the GSM modem using RS232
8
UART serial communication protocol and the AT command. GSM modem SIM-T03 was used in
the implementation.[2]

Unlike the GSM Power Meter design proposed by H.G. Rodney Tan et al which uses two
microcontrollers, Sudhish N George and Ashna in GSM Based Automatic Energy meter Reading
with instant billing [13], presented a GSM meter architecture design that is constructed using a
single 8-bits PIC microcontroller PIC16F877A to both interface impulse count from the power
meter as well as to communicate with the GSM modem. The Circuit design of the meter is
mainly made up of an evaluation board (MCP3905A), Microcontroller (PIC16F877) and LCD
(20x4) and GSM Modem (Fargo Maestro -20). Real Time Clock module is also integrated in the
meter to have time stamped recording of usage details. The GSM unit is interfaced to the micro
controller via a MAX 232 convertor. The user GSM Modem transmits the usage details to the
central office computer. The microcontroller and other devices get power supply from AC to DC
adapter or from direct ac lines through voltage regulator. The adapter output voltage will be 12V
DC non-regulated. The 7805 voltage regulators are used to convert 12V to 5V DC. The
EEPROM used is Atmel 24C256.This memory device is used to store the data for off line
process. i.e. it stores the amount of unit the user consumed while transferring each SMS. This is
used to maintain the real time and date in off line processing. RTC counts seconds, minutes,
hours, date of the month, day of the week, and year with leap-year compensation valid up to
2100. The RTC selected here is the DS1307.

Output pulses from the metering IC are counted using the default timer of PIC Microcontroller
Unit. The microcontroller is programmed to read data from the metering IC every second. When
microcontroller reads the power consumption, it is stored and current reading is incremented in
its software. In this design meter is calibrated such that for 1 unit of energy (kWh) consumption,
it generates 3200 pulses in LED.

Instead of each meter unit transferring data directly to the central office computer using
individual GSM modules, Hung-Cheng Chen and Long-Yi Chang in [1], proposed a system
where the data from each meter is transmitted to ZigBee/GPRS Gateways through a ZigBee
Wireless communication network, then back to central office PC or the database of the energy
provider in RS-232 communication format via GPRS. The development of this System is based
on the high performance, extremely low power consumption due to a short duty circle, high level
of integration and low cost offered by the ZigBee technology. ZigBee technology is a

9
bidirectional short range wireless communication technology in the 2.4GHz ISM band
characterized by low complexity, low cost, low power consumption, and low data rate, mainly
used in automatic control.

However, in spite of all these advantages, the ZigBee technology still has some drawbacks. As
pointed out by Kwang-il Hwang, the ZigBee devices are extremely limited in resources including
processing, memory, and power. In addition, ZigBee is an autonomous network. Therefore, the
network is not always in user-intervention, but operates self-regulated. Sometimes these
characteristics of ZigBee can make the devices more vulnerable to unexpected error
environments such as abrupt system failure, link errors, and resets. These errors are caused by
various hardware faults, battery depletion, or Memory errors such as stack overflow. In addition,
the 2.4GHz band, which is one of the most popular frequency bands supported by the standard, is
directly exposed to numerous other interference sources, such as IEEE802.11, Bluetooth, and
other ZigBee (IEEE802.15.4) networks. These fault environments might obstruct the normal
operation of the ZigBee based AMR network or may even paralyze whole network. To counter
these vulnerabilities, Kwang-il Hwang in [14] proposed a fault-tolerant wireless AMR network
(FWAMR), which is designed to improve the robustness of the conventional ZigBee-based AMR
systems by coping well with dynamic error environments.

J. Tsado et al presented in their paper [15], an SMS based Consumer Load Monitoring and
Control System (CLMCS) whose operation is centered on an AT89C52 microcontroller, a
dedicated GSM modem with a SIM card is interfaced to the ports of the microcontroller through
a PNP transistor (BC557) and a Normally Closed (NC) relay to send SMS notification alert to
user’s mobile phone when power supply is restored to his premises and whenever the energy
consumed exceeds the maximum value set by the end user in this case 1 kW. This enables the
consumer to respond promptly by cutting off power supply to his load unit when not needed.

In [16], P. Rakesh Malhotra and Dr.R.Seethalakshmi, deal with automatic meter reading and
theft control system in energy meter. Current transformer is used to measure the total power
consumption for house or industrial purpose. This recorded reading is transmitted to the
electricity board once every sixty days. For transmitting the readings of the energy meter, a GSM
module is used. To avoid theft, infrared sensor is placed in the screw portion of the energy meter
seal. If the screw is removed from the meter a message is sent to the electricity board. The
measuring of energy meter and monitoring of IR sensor is done with a PIC microcontroller.

10
In [17], S. Chhettri et al designed a digital energy meter using GSM and card reading
technologies for collection, communication and integration of the data. The main objective of the
design is to integrate the GSM module and the debit card reading console with the digital energy
meter so that the electricity bill delivery and the bill payment is made easier.

Abhinandan Jain et al in [18] consider the design and development of GSM based Automatic
Energy meter reading so as to do away with the existing electro-mechanical meters. This project
uses a microcontroller which is interfaced with a digital energy meter. The Microcontroller is
also interfaced with RTC by using two (2) wire serial interfaces for date and time and RTC
memory also for permanent storage of received data.

The Microcontroller is also interfaced with a GSM modem for remote monitoring and control
domestic energy meter. The data is received through the GSM modem and network. Data is sent
to the AMR on request and within a particular interval. Once the meter received the request of
data from the energy provider, SMS gateway will immediately reply the meter reading with that
date and time. The data received from the meter is stored in the data base server through SMS
gateway for processing and records. This data that is received from the meter is stored in the data
base server according to meter ID that is provided to the customer household. The meter
constantly gives information on the rise in meter reading and number of units consumed. The
microcontroller reads the message and the message received number and checks it authenticity.
If the number is authentic then it reads the current data from EPROM and sends the data to the
authentic number or otherwise the GSM AMR sends SMS alert to the energy provider. At the
end of each week, month or year the server using the data from the data base server calculate the
bill amount and sends a complete detail of the consummation of unit and total bill amount. In
cases of large outstanding bills the system has facilities that disconnects the customer from the
energy provider and also has a facility to reconnect if bills are paid. The system also has a power
cut facility that sends SMS alert to the energy provider in cases of power cuts in particular
locations. The AMR process has transparency on the side of both the customer and service
provider. This system has the advantage of being interfaced with certain facilities. Some of
which are Temper alert facility, Auto- disconnect feature that disconnects customers with huge
outstanding bills, data security features that ensures that the AMR avoid data reading errors and
also a data storage facility that permanently stores the received data from the GSM modem. This
system is also interfaced with a power cut feature.

11
Like Abhinandan Jain et al, Bharat Kulkarni also designed and developed a GSM based
automatic meter reading system using ARM Micro- controller. The proposed system
automatically reads the energy meter data and sends it to the service providers on reception of
specific message from the service provider. It uses a GSM modem for this purpose and it also
has power disconnect facility that disconnects the customer for payment related issue. This
system is implemented using an ARM processor based board. It uses a 32- bit processor with
ADC timer or counter module, PWM and UART module to interface a GSM modem and energy
meter. The energy meter which generates pulses as well as counts energy consumed is used. The
digital energy meter has an LED which blinks to indicate the specific amount of energy
consumed (example 1 unit =1600 units). These pulses are fed to the ARM based processor which
are programmed to count these pulses. The system reads these pulses and after counting specific
number of pulses it increments the internal by one which indicates the number of units
consumed. When the service provider sends message to read the energy meter data, GSM
modem which is connected through a UART interface, interrupt ARM. This causes the ARM to
read the number of units burnt and send the data to the UART. Further, the UART sends data to
the GSM modem which sends this meter reading data to the service provider. If the service
provider detects that there pending bills for a customer it sends SMS alert to the energy provider
to disconnect supply to that customer. This objective is achieved by a relay in the ARM. The
Energy provider can now notify the customers of their bills through SMS through their the
individual registered mobile phone number. The design reduces the effort of manual data
collection of energy meters. The data received at the energy provider’s side can be easily
manipulated to generate bills and other needed tasks. With this system as well data can be
accessed at the same time control energy usage.[19]

12
CHAPTER THREE

THEORY

3.1 Block Diagram

LCD DISPLAY

ENERGY METER

GSM MODEM

MICROCONTROLLER

LOAD

RELAY
POWER SUPPLY

UNIT

Figure 1 : Block Diagram of AMR

13
3.2 Microcontroller

A microcontroller (sometimes abbreviated μC, uC or MCU) is a small computer on a single


integrated circuit containing a processor core, memory, and programmable input/output
peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on
chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded
applications, in contrast to the microprocessors used in personal computers or other general
purpose applications [20.] In the 20th century there has been a marked improvement in the
microprocessor technology such that it has become an integral part in the implementation of
many low to high power devices with remarkable results. Coming in all shapes and sizes, these
powerful devices has made the storing, processing and transmission of data much easier than it
has ever been. There are many types of microcontroller families. Basically they are PIC
(Peripheral interface controller), ARM (Acorn RISC Machine), AVR (Advanced Virtual RISC)
and 8051 families. The microcontrollers are based on two major architectures reduced instruction
set computers (RISC) and complex instruction set computers (CISC). RISC combine functions,
or speed them up, so they don't take as much time as CISC thus resulting in high instruction
throughput and impressive real time interrupt response from a small and cost effective chip [3].
In this project together with the GSM module the choice of microcontroller that must be used in
the implementation must come with features that would make it feasible as well as cost effective.
In picking the best microcontroller, there are some requirements that must be taken into
consideration to ensure its effective implementation. Importantly the processor picked must have
non volatile memory storage to record the data from meter readings. It must be high
performance, have very low power consumption, compressive on-chip debug design, flexibility
and scalability, optimal price and fast growing support ecosystem.

8051 is an 8-bit family of microcontroller developed by Intel in the year 1981. This is one of the
most popular families of microcontroller being used all across the world.  This microcontroller
was also referred as “system on a chip” because it has 128 bytes of RAM, 4 Kbytes of ROM, 2
Timers, 1 Serial port, and four ports on a single chip. The CPU can work for only 8bits of data at
a time because 8051 is an 8-bit controller. Most manufacturers have put 4 Kbytes of ROM even
though the quantity of ROM can be exceeded up to 64K bytes [21]. 8051 can access memory

14
directly unlike the other microcontrollers which have to first store data or instructions in their
registers before manipulating them. If the requirement is of large number of I/O lines but not
many peripherals are required then the basic 8051 is the best as it cuts down the cost.
Unfortunately in this kind of controller it is noticed with data of higher word size it would be
difficult to process as it come with an 8 bit processor. Compared to the PIC controller the RAM,
ROM addressable space offered by CPU of this controller is woefully inadequate. Also the 8051
microcontroller has no in built A/D converters though it has external memory bus to enable
addition of peripherals but PIC & AVR have  A/D convertors [22]. This kind of controller is old
and fairs woefully when compared to PIC and AVR models [23][24] .

The AVR ranges from an 8 to 32-bit modified Harvard architecture RISC single chip
microcontroller (µC) which was developed by Atmel starting in 1996. The AVR was one of the
first microcontroller families to use on-chip flash memory for program storage. It possesses
RISC architecture with a little CISC instruction set making it more C friendly. It processes one
instruction per external clock, low power consumption and very efficient. Unlike PICs, AVR has
C friendly nature therefore its development tools are easily available. C is a great language for
microcontrollers. It’s lightweight and fast as it makes use of arrays, functions, pointers. It
assembly code is more efficient compared to the PIC. The PIC does also have its own C
language but it isn’t easily accessible [25][26].

The ARM is a 32-bit reduced instruction set computer (RISC) instruction set architecture (ISA)
developed by ARM Limited. It was known as the Advanced RISC Machine, and before that as
the Acorn RISC Machine. The ARM architecture is the most widely used 32-bit ISA in terms of
numbers produced. They were originally conceived as a processor for desktop personal
computers by Acorn Computers, a market now dominated by the x86 family used by IBM PC
compatible computers. The relative simplicity of ARM processors made them suitable for low
power applications. This has made them dominant in the mobile and embedded electronics
market as relatively low cost and small microprocessors and microcontrollers. These controllers
with 32-bit word size make them faster compared to their 8-bit PIC & AVR models picked for
this project. They are C friendly. Cost wise they are very expensive compared to the other
counterparts and will make the project unrealistic [27].

15
This significantly shows that the choice of microcontrollers to be used depends on it application.
Due to dependence on what it would be used to implement, cost involved, its efficiency and
capabilities, microcontrollers vary widely and come in different specifications.

3.2.1 PIC Microcontroller

3.2.1.1 Introduction
PIC is a family of Harvard architecture microcontrollers made by Microchip Technology,
derived from the PIC1640 originally developed by General Instrument's Microelectronics
Division. The name PIC initially referred to "Programmable Interface Controller" .The PIC
controller uses partly RISC and CISC instructions making it less C programming friendly. With
the Harvard architecture there are separate data and instruction storage units with separate buses
[28]. With this architecture instruction and data can be differentiated easily there by enabling
simultaneous access of data and instruction. PIC microcontrollers are available in 3 different
architectures. Those are 8-bit, 16-bit and 32-bit microcontrollers. PIC has nearly 40 instructions
which all are take 4 clock cycles to execute. The speed of the PIC controller is 3 million
instructions per second. [29]

The PIC16F877A Microcontroller

Figure 2 : Pin Diagram of PIC16F77A

The PIC16F877A microcontroller is one of the most popular microcontrollers manufactured by


Microchip Technology. As most PIC microcontrollers, it uses the Harvard architecture and it is

16
an 8-bit microcontroller [30]. The PIC16F877A comes with 40 pins and it is a low cost and low
power microcontroller. It is a member of the PIC16F87X family.

Features of PIC16F877A [30]

It has the following core features;


o High performance RISC CPU

o Only 35 single word instructions to learn

o All single cycle instructions except for program branches which are two cycle

o Operating speed: DC - 20 MHz clock input

o DC - 200 ns instruction cycle

o Up to 8K x 14 words of FLASH Program Memory,

o Up to 368 x 8 bytes of Data Memory (RAM)

o Up to 256 x 8 bytes of EEPROM Data Memory

o Pin out compatible to the PIC16C73B/74B/76/77

o Interrupt capability (up to 14 sources)

o Eight level deep hardware stack

o Direct, indirect and relative addressing modes

o Power-on Reset (POR)

o Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)

o Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation

o Programmable code protection

o Power saving SLEEP mode

o Selectable oscillator options

o Low power, high speed CMOS FLASH/EEPROM technology

o Fully static design

o In-Circuit Serial Programming (ICSP) via two pins

o Single 5V In-Circuit Serial Programming capability

17
o In-Circuit Debugging via two pins

o Processor read/write access to program memory

o Wide operating voltage range: 2.0V to 5.5V

o High Sink/Source Current: 25 mA

o Commercial, Industrial and Extended temperature ranges

o Low-power consumption: - < 0.6 mA typical @ 3V, 4 MHz

Peripheral Features:
• 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
- Capture is 16-bit, max. Resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit
• Synchronous Serial Port (SSP) with SPI™ (Master mode) and I2C™ (Master/Slave)
• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address
detection
• Parallel Slave Port (PSP) – 8 bits wide with external RD, WR and CS controls (40/44-pin only)
• Brown-out detection circuitry for Brown-out Reset (BOR)

3.2.1.2 Memory Organization

There are three memory blocks in each of the PIC16F87X MCUs. The Program Memory and
Data Memory have separate buses so that concurrent access can occur and is detailed in this
section [30].

18
3.2.1.2.1 Program Memory Organization

The PIC16F87X devices have a 13-bit program counter capable of addressing an 8K x 14


program memory space. The PIC16F877 devices have 8K x 14 words of FLASH program
memory. Accessing a location above the physically implemented address will cause a
wraparound. The RESET vector is at 0000h and the interrupt vector is at 0004h [30].

3.2.1.2.2 Data Memory Organization

The data memory is partitioned into multiple banks which contain the General Purpose Registers
and the Special Function Registers. Bits RP1 (STATUS<6>) and RP0 (STATUS<5>) are the
bank select bits. Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function Registers are General
Purpose Registers, implemented as static RAM. All implemented banks contain Special Function
Registers. Some frequently used Special Function Registers from one bank may be mirrored in
another bank for code reduction and quicker access.

3.2.1.3 Data EEPROM and Flash Memory

The Data EEPROM and FLASH Program Memory are readable and writable during normal
operation over the entire VDD range. These operations take place on a single byte for Data
EEPROM memory and a single word for Program memory. A write operation causes an erase-
then-write operation to take place on the specified byte or word. A bulk erase operation may not
be issued from user code (which includes removing code protection). The EEPROM Data
memory is rated for high erase/ writes cycles (specification D120). The FLASH program
memory is rated much lower (specification D130), because EEPROM data memory can be used
to store frequently updated values. An on-chip timer controls the write time and it will vary with
voltage and temperature, as well as from chip to chip. [30]

3.2.1.4 I/O Ports

19
Some pins for these I/O ports are multiplexed with an alternate function for the peripheral
features on the device. In general, when a peripheral is enabled, that pin may not be used as a
general purpose I/O pin. The I/O pins are grouped into ports A through to port E

3.2.1.5 Watchdog Timer (WDT)


The Watchdog Timer is as a free running on-chip RC oscillator which does not require any
external components. This RC oscillator is separate from the RC oscillator of the OSC1/CLKIN
pin. That means that the WDT will run, even if the clock on the OSC1/CLKIN and
OSC2/CLKOUT pins of the device has been stopped, for example, by execution of a SLEEP
instruction. During normal operation, a WDT time-out generates a device RESET (Watchdog
Timer Reset). If the device is in SLEEP mode, a WDT time-out causes the device to wake-up
and continue with normal operation (Watchdog Timer Wake-up). The TO bit in the STATUS
register will be cleared upon a Watchdog Timer time-out. The WDT can be permanently
disabled by clearing configuration bit WDTE. WDT time-out period values may be found in the
Electrical Specifications section under parameter #31. Values or the WDT prescaler (actually a
postscaler, but shared with the Timer0 prescaler) may be assigned using the OPTION_REG
register.[2][30]

3.2.1.6 Analog-To-Digital Converter (A/D) Module


The Analog-to-Digital (A/D) Converter module has eight inputs for the PIC16F87X devices. The
analog input charges a sample and hold capacitor. The output of the sample and hold capacitor is
the input into the converter. The converter then generates a digital result of this analog level via
successive approximation. The A/D conversion of the analog input signal results in a
corresponding 10-bit digital number. The A/D module has high and low voltage reference input
that is software selectable to some combination of VDD, VSS, RA2, or RA3. The A/D converter
has a unique feature of being able to operate while the device is in SLEEP mode. To operate in
SLEEP, the A/D clock must be derived from the A/D‘s internal RC oscillator [30]

3.2.1.7 Addressable Universal Synchronous Asynchronous Receiver Transmitter


[USART]

20
The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one of the
two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI.)
The USART can be configured as a full duplex asynchronous system that can communicate with
peripheral devices such as CRT terminals and personal computers, or it can be configured as a
half duplex synchronous system that can communicate with peripheral devices such as A/D or
D/A integrated circuits, serial EEPROM’s etc. The USART can be configured in the following
modes:

i. Asynchronous (full duplex)

ii. Synchronous - Master (half duplex)

iii. Synchronous - Slave (half duplex)

Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure pins
RC6/TX/CK and RC7/RX/DT as the Universal Synchronous Asynchronous Receiver
Transmitter. The USART module also has a multi-processor communication capability using 9-
bit address detection.[3][30]

3.2.1.8 Ports/pins and their functions [30]


Port A

RA0/AN0 bit0 TTL Input/output or


analog input.
RA1/AN1 bit1 TTL Input/output or
analog input.
RA2/AN2 bit2 TTL Input/output or
analog input.
RA3/AN3/VREF bit3 TTL Input/output or
analog input or
VREF
RA4/T0CKI bit4 ST Input/output or
external clock input
for Timer0. Output is
open drain type.
RA5/SS/AN4 bit5 TTL Input/output or slave
select input for
synchronous serial

21
port or analog input.

PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA.
Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the
corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0) will make the
corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected
pin). Reading the PORTA register reads the status of the pins, whereas writing to it will write to
the port latch. All write operations are read-modify-write operations.

22
Port B

RB0/INT bit0 TTL/ST Input/output pin or


external interrupt
input. Internal
software
programmable weak
pull-up.
RB1 bit1 TTL Input/output pin.
Internal software
programmable weak
pull-up.
RB2 bit2 TTL Input/output pin.
Internal software
programmable weak
pull-up.
RB3 bit3 TTL Input/output pin or
programming pin in
LVP mode. Internal
software
programmable weak
pull-up.
RB4 bit4 TTL Input/output pin
(with interrupt-on-
change). Internal
software
programmable weak
pull-up.
RB5 bit5 TTL Input/output pin
(with interrupt-on-
change). Internal
software
programmable weak
pull-up.
RB6/PGC bit6 TTL/ST Input/output pin
(with interrupt-on-
change) or In-Circuit
Debugger pin.
Internal software
programmable weak
pull-up. Serial
programming clock.
RB7/PGD bit7 TTL/ST Input/output pin
(with interrupt-on-
change) or In-Circuit
Debugger pin.
Internal software
programmable weak
pull-up. Serial
programming clock.
RB0/INT bit0 TTL/ST Input/output pin or
external interrupt
23 input. Internal
software
programmable weak
pull-up.
Unlike Port A, Port B is an 8-bit wide, bi-directional port with it data direction controlled by
register is TRISB. Setting a TRISB bit to 1 will make the corresponding PORTB pin an input.
Clearing a TRISB bit to bit 0 will make the corresponding PORTB pin an output (i.e., put the
contents of the output latch on the selected pin). The external interrupt input which is common to
all of them allow input interrupt and is great to use for applications when you might need to react
quickly to an outside source. Only interrupt pins configured as inputs can cause this interrupt to
occur. This interrupt can wake the device from SLEEP.

Port C

Name Bit# Buffer Function


RC0/T1OSO/T1CKI bit0 ST Input/output port pin
or Timer1 oscillator
output/Timer1 clock
input.
RC1/T1OSI/CCP2 bit1 ST Input/output port pin
or Timer1 oscillator
input or Capture2
input/ Compare2
output/PWM2 output.
RC2/CCP1 bit2 ST Input/output port pin
or Capture1
input/Compare1
output/ PWM1 output.
RC3/SCK/SCL bit3 ST RC3 can also be the
synchronous serial
clock for both SPI and
I2C modes.
RC4/SDI/SDA bit4 ST RC4 can also be the
SPI Data In (SPI
mode) or data I/O
(I2C mode).
RC5/SDO bit5 ST Input/output port pin
or Synchronous Serial
Port data output.
RC6/TX/CK bit6 ST Input/output port pin
or USART
Asynchronous
Transmit or
Synchronous Clock.
RC7/RX/DT bit7 ST Input/output port pin
or USART
Asynchronous
Receive or
Synchronous Data.

24
PORTC is also an 8-bit wide, bi-directional port with its corresponding data direction register is
TRISC. Like all the other I/O ports setting a TRISC bit to 1 will make the corresponding PORTC
pin an input and clearing it to bit 0 will make the corresponding PORTC pin an output.
PORTC is multiplexed with several peripheral functions .PORTC pins have Schmitt Trigger
input buffers.

Port D

Name Bit# Buffer Function


RD0/PSP0 bit0 ST/TTL(1) Input/output port pin
or parallel slave port
bit0.
RD1/PSP1 bit1 ST/TTL(1) Input/output port pin
or parallel slave port
bit1.
RD2/PSP2 bit2 ST/TTL(1) Input/output port pin
or parallel slave port
bit2.
RD3/PSP3 bit3 ST/TTL(1) Input/output port pin
or parallel slave port
bit3.
RD4/PSP4 bit4 ST/TTL(1) Input/output port pin
or parallel slave port
bit4.
RD5/PSP5 bit5 ST/TTL(1) Input/output port pin
or parallel slave port
bit5.
RD6/PSP6 bit6 ST/TTL(1) Input/output port pin
or parallel slave port
bit6.
RD7/PSP7 bit7 ST/TTL(1) Input/output port pin
or parallel slave port
bit7.

PORTD and TRISD are not implemented on the PIC16F873 or PIC16F876. PORTD is an 8-bit
port with Schmitt Trigger input buffers. Each pin is individually configurable as an input or
output. PORTD can be configured as an 8-bit wide microprocessor port (parallel slave port) by
setting control bit PSPMODE (TRISE<4>). In PSP mode the TRISD register is ignored, since
the external device connected to the slave port controls the direction of data flow. In this mode,
the input buffers are TTL. PORTD operates as an 8-bit wide Parallel Slave Port, with PORTE
providing the control signals in parallel slave mode.

25
3.3 GSM (Global System for Mobile Communication)

3.3.1 Introduction
Global system for mobile communication is a generally accepted standard for digital cellular
communication. GSM is the name of the standardization group created in 1982 to have a
common European mobile telephone standard that would formulate specifications for a pan-
European mobile cellular radio system that would operate at 900MHz. GSM is a standard
developed by the European Telecommunications Standards Institute (ETSI) to describe protocols
for second generation (2G) digital cellular networks used by mobile phones. It became the de
facto global standard for mobile communications with over 80% of market share. The GSM
standard was developed as a replacement for first generation (1G) analog cellular networks, and
originally described a digital, circuit-switched network optimized for full duplex voice
telephony. This was expanded over time to include data communications, first by circuit-
switched transport, then packet data transport via GPRS (General Packet Radio Services)
and EDGE (Enhanced Data rates for GSM Evolution or EGPRS).[31][3]

Subsequently, the 3GPP developed third generation (3G) UMTS standards followed by fourth


generation (4G) LTE Advanced standards, which are not part of the ETSI GSM standard.

"GSM" is a trademark owned by the GSM Association [31].

SPECIFICATION:
Mobile frequency range : Rx: 925- 960, Tx: 880-915
Multiple access method : TDMA/FDM
Duplex method : FDD
Number of channels : 24(8 users per channel)
Channel spacing : 200 kHz
Modulation : GMSK(0.3 Gaussian filter)
Channel bit rate : 270.8333 Kb

3.3.2 GSM Network


GSM modem is a wireless modem that works with a GSM wireless network. The GSM modem
receives and sends data by a wireless means thus through radio waves. The network provides
recommendation not requirements. The GSM modem can be used in two main ways thus as an

26
external device or PC card/PCMCIA card. The external GSM modem is connected to the
computer through a serial cable or USB cable. A GSM modem with a PC/PCMCIA card is
designed for laptop usage. It is slotted into one of the PC/PCMCIA card slot on the laptop
computer. The GSM network is divided into three major systems: The switching system
system(SS), the Base station system(BSS) and the Operating and Supporting system(OSS). The
GSM requires a SIM card from a wireless carrier to operate [3]. The GSM operation supports a
command set of AT commands. The GSM modem can operate like a dial-up system, the only
difference is that the dial-up system uses a telephone like transmission while the GSM uses
radio-waves for transmission. These extended AT commands are defined in GSM standards.
With the extended AT commands the following operations can be undertaken:

 Reading, writing and deleting SMS messages


 Sending SMS messages
 Monitoring the signal strength
 Monitoring the charging level and charging status of the battery
 Reading, writing and searching phone book entries
 The number of SMS messages that can be processed by a GSM modem per minute is
very about six to ten messages per minute

GSM Interfaces:
Serial Port, [3.3V TTL voltage level/ RS232 voltage level optional, 115200bps, No
hardware flow control]
Power supply [DC 7.5V, 500mA]
Antenna interface
Status light [Red light indicate power status]
SIM card holder

SPECIFICATIONS:

*Operation temperature -25 to +60

*Storage temperature -35 to +80

*Humidity (0-95) non-condense

27
*Receive Sensitivity -102dBm

*Maximum Transmit Power -1W

*Dynamic range 62dB

*Frequency Tolerance + or – 0.1ppm

*Power Supply 5V, 7.5V, 12V

*Current Standby 50mA- work 300mA

*Weight 250g

GSM frequency bands: [29]


 The initial design used the 900MHz range
 Uplink to BTS 890- 915 MHz
 Downlink to MS 935- 960MHz
 There 124 channels of 200kHz and 100kHz of guard spectrum at the edges of
bands – and each channel can carry 8 TDMA users.
 Usually an operator does not have access to the full range. GSM maximum range
is 35km due to timing requirements.

3.3.2.1 GSM Security


GSM was designed with a moderate level of security. The system was designed to authenticate
the subscriber using a pre-shared key and challenge-response. Communications between the
subscriber and the base station can be encrypted. The development of UMTS introduces an
optional USIM, that uses a longer authentication key to give greater security, as well as mutually
authenticating the network and the user whereas GSM only authenticated the user to the network
(and not vice versa). The security model therefore offers confidentiality and authentication, but
limited authorization capabilities, and no non-repudiation. GSM uses several cryptographic
algorithms for security. The A5/1 and A5/2 stream ciphers are used for ensuring over-the-air
voice privacy. A5/1 was developed first and is a stronger algorithm used within Europe and the
United States; A5/2 is weaker and used in other countries. A large security advantage of GSM

28
over earlier systems is that the cryptographic key stored on the SIM card is never sent over the
wireless interface. Serious weaknesses have been found in both algorithms, however, and it is
possible to break A5/2 in real- time in a cipher text-only attack. The system supports multiple
algorithms so operators may replace that cipher with a stronger one.

3.3.3 Short Message Service (SMS)


SMS is a test messaging service component of phone, web or mobile communication system. It
uses standardized communication protocols to allow fixed line or mobile phone devices to
exchange short text messages. It is the most widely used data application of all mobile
subscribers. SMS as used on modern handsets originated from radio telegraphy in radio memo
pagers using standardized phone protocols. These where defined in 1985 as part of the Global
system for mobile communications (GSM) series of standards as a means of sending messages of
up to 160 characters to and from GSM mobile handsets [31].

3.3.4 GSM Modem


GSM MODEM is a class of wireless Modem devices that is designed for communication of a
computer with the GSM network. It requires a SIM (Subscriber Identity Module) card to activate
communication with the network. Also they have IMEI (International Mobile Equipment
Identity) number similar to mobile phones for their identification. A GSM Modem can perform
the following operations:
 
1.      Receive, send or delete SMS messages in a SIM.
2.      Read, add, search phonebook entries of the SIM.
3.      Make, Receive, or reject a voice call.
 
A GSM module assembles a GSM modem with standard communication interfaces like RS-232
(Serial Port), USB etc., so that it can be easily interfaced with a computer or microcontroller
based system. The power supply circuit is also built in the module that can be activated by using
a suitable adaptor.

29
The Modem needs AT commands, for interacting with a microcontroller, which are
communicated through serial communication. These commands are sent by the microcontroller.
The Modem sends back a result after it receives a command. Different AT commands supported
by the Modem can be sent by the microcontroller to interact with the GSM cellular network [32].

Figure 3: SIM300 GSM Modem

Commands
SMS functions
Setting up SMS Center number

AT+CSCA=“+23324400XXXXXX”
TEXT parameter

AT+CSMP=17_168_0_0
AT=*MESSAGE*
E.g. AT=*power cut tomorrow*
Display in LCD
Send SMS

AT+CMGS
AT=<S>
30
Power display in LCD

Read single SMS

AT+CMGR=1
AT=<1>
Trip ON
AT=<0>
Trip OFF

List multiple SMS

AT+CMGF=1
AT+CMGF=4

Delete SMS
AT+CMGD

3.3.5 Interfacing the GSM module

Figure 4 :PIC16F887A interfaces with the GSM module

31
The project explains interfacing of the PIC microcontroller with the GSM module and the
HyperTerminal. HyperTerminal is a Windows application. The AT commands are sent by the
HyperTerminal to the GSM module. The Information Response and/or Result Codes are received
at the microcontroller and retransmitted to the HyperTerminal by the controller [33].
A GSM module has an RS232 interface for serial communication with an external peripheral.
The MAX232 is an IC that contains the necessary drivers (two) and receivers (also two), to adapt
the RS-232 signal voltage levels to TTL logic. It became popular, because it just needs one
voltage (+5V) and generates the necessary RS-232 voltage levels (approx. -10V and +10V)
internally. This greatly simplified the design of circuitry. Circuitry designers no longer need to
design and build a power supply with three voltages (e.g. -12V, +5V, and +12V), but could just
provide one +5V power supply [29].

3.4 Energy meter


An energy meter is a device that measures the amount of electric energy consumed over a period
of time. Electricity meters are typically calibrated in billing units, the most common one being
the kilowatt hour (kWh) which is equal to the amount of energy used by a load of
one kilowatt over a period of one hour, or 3,600,000 joules. Electricity meters operate by
continuously measuring the instantaneous voltage and current to give energy consumed kilowatt-
hours. Meters for smaller services such as small residential customers can be connected directly
in-line between source and customer. For larger loads, more than about 200 ampere of
load, current transformers are used, so that the meter can be located other than in line with the
service conductors. The meters fall into two basic categories, electromechanical and electronic.
[34]

(i) Electromechanical Energy meter.


(ii) Electronic Energy meter.

3.4.1 Electromechanical Energy Meter


The most common type of electricity meter is the electromechanical induction watt-hour meter.
The electromechanical induction meter operates by counting the revolutions of a non-magnetic,
but electrically conductive, metal disc which is made to rotate at a speed proportional to the
power passing through the meter. The number of revolutions is thus proportional to the energy
usage. The disc is acted upon by two sets of coils, which form, in effect, a two phase induction
32
motor. One coil is connected in such a way that it produces a magnetic flux in proportion to
the voltage and the other produces a magnetic flux in proportion to the current. The field of the
voltage coil is delayed by 90 degrees, due to the coil's inductive nature, and calibrated using a lag
coil. This produces eddy currents in the disc and the effect is such that a force is exerted on the
disc in proportion to the product of the instantaneous current, voltage and phase angle (power
factor) between them. A permanent magnet exerts an opposing force proportional to the speed of
rotation of the disc. The equilibrium between these two opposing forces results in the disc
rotating at a speed proportional to the power or rate of energy usage. The disc drives a register
mechanism which counts revolutions in order to render a measurement of the total energy used.
The type of meter described above is used on a single-phase AC supply. Different phase
configurations use additional voltage and current coils.[3]

The disc is supported by a spindle which has a worm gear which drives the register. The register
is a series of dials which record the amount of energy used. The dials may be of
the cyclometer type, an odometer-like display that is easy to read where for each dial a
single digit is shown through a window in the face of the meter, or of the pointer type where a
pointer indicates each digit. With the dial pointer type, adjacent pointers generally rotate in
opposite directions due to the gearing mechanism.[34]

The amount of energy represented by one revolution of the disc is denoted by the symbol Kh
which is given in units of watt-hours per revolution. The value 7.2 is commonly seen. Using the
value of Kh one can determine their power consumption at any given time by timing the disc
with a stopwatch.

3600× K h
P=
t

Where:

t = time in seconds taken by the disc to complete one revolution,


P = power in watts.

33
Figure 5: Electromechanical energy meter

3.4.2 Electronic meters


Electronic meters display the energy used on an LCD or LED display, and some can also
transmit readings to remote places. In addition to measuring energy used, electronic meters can
also record other parameters of the load and supply such as instantaneous and maximum rate of
usage demands, voltages, power factor and reactive power used etc. They can also support time-
of-day billing, for example, recording the amount of energy used during on-peak and off-peak
hours.[3]

The meter has a power supply, a metering engine, a processing and communication engine (i.e.
a microcontroller), and other add-on modules such as RTC, LCD display, communication
ports/modules and so on.

The metering engine is given the voltage and current inputs and has a voltage reference, samplers
and quantizes followed by an ADC section to yield the digitized equivalents of all the inputs.
These inputs are then processed using a digital signal processor to calculate the various metering
parameters such as powers, energies etc. The processing and communication section has the
responsibility of calculating the various derived quantities from the digital values generated by
the metering engine. This also has the responsibility of communication using various protocols
and interface with other add-on modules connected as slaves to it.[34]

RTC and other add-on modules are attached as slaves to the processing and communication
section for various input/output functions. On a modern meter most if not all of this will be
implemented inside the microprocessor, such as the real time clock (RTC), LCD controller,
temperature sensor, memory and analog to digital converters.

34
Figure 6 : Electronic energy meter

3.5 Relay

A relay is an electrically operated switch. Many relays use an electromagnet to operate a


switching mechanism mechanically, but other operating principles are also used. 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, repeating the signal coming
in from one circuit and retransmitting it to another. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.[3][34]

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".[34]

35
3.5.1 Basic design and operation

A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core, an iron
yoke which provides a low reluctance path for magnetic flux, a movable iron armature, and one
or more sets of contacts. 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.[3]

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 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.

3.5.2 Types of Relays


There are many types of relays that work on various principles. Some major types are:
.

3.5.2.1 Solid State Relays:


These are a special class of electronic “relays”. They are used to switch AC loads operating
usually in the 100-230V AC range. They typically take a low-current 3-32 VDC control signal,
easily available from a microcontroller, and can switch AC loads up to 10’s of amps. Despite the
“relay” terminology these are purely electronic devices which have no contacts or other moving
parts. They are designed for “zero-crossing” switching, meaning they switch at the moment
where the AC voltage crosses the zero-volt point, thus limiting electrical switching noise and
inductive voltage spikes which would otherwise occur. These devices are easy to apply, can be
quite useful, and can be rather expensive depending on how much current they can handle.

36
Figure 7 : Solid State Relay

3.5.2.2 Latching Relay


Latching relays are also called impulse relays. They work in the bistable mode, and thus have
two relaxing states. They are also called keep relays or stay relays because as soon as the current
towards this relay is switched off, the relay continues the process that it was doing in the last
state. This can be achieved only with a solenoid which is operating in a ratchet and cam
mechanism. It can also be done by an over-centre spring mechanism or a permanent magnet
mechanism in which, when the coil is kept in the relaxed point, the over-centre spring holds the
armature and the contacts in the right spot. This can also be done with the help of a remanent
core

Figure 8 : Latching Relay

3.5.2.3 Polarized Relay


This type of relay has been given more importance on its sensitivity. These relays have been
used since the invention of telephones. They played very important roles in early telephone
exchanges and also in detecting telegraphic distortion. The sensitivity of these relays is very easy

37
to adjust as the armature of the relay is placed between the poles of a permanent magnet. The
poles were on screws, so a technician could first adjust them for maximum sensitivity and then
apply a bias spring to set the critical current that would operate the relay.

Figure 9 : Polarized Relay


3.5.2.4 Reed Relay
A reed relay is a reed switch enclosed in a solenoid. The switch has a set of contacts inside an
evacuated or inert gas-filled glass tube which protects the contacts against atmospheric
corrosion; the contacts are made of magnetic material that makes them move under the influence
of the field of the enclosing solenoid. Reed relays can switch faster than larger relays, require
very little power from the control circuit. However they have relatively low switching current
and voltage ratings. Though rare, the reeds can become magnetized over time, which makes
them stick 'on' even when no current is present; changing the orientation of the reeds with respect
to the solenoid's magnetic field can resolve this problem[23][24][25]

Figure 10 : Reed Relay

3.5.3 Interfacing the relay

38
A microcontroller is not capable of supplying sufficient current required for the working of a
relay. The maximum current that a PIC Microcontroller can source or sink is 25mA while a relay
needs about 50 – 100mA current. A relay is activated by energizing its coil. Microcontroller may
stop working by the negative voltages produced in the relay due to its back emf. A relay can be
easily interfaced with microcontroller using a transistor. From figure, when the pin RB7 of the
PIC microcontroller goes high, the transistor turns on and current flows through the relay.  The
diode D1 is used to protect transistor and the microcontroller from Back EMF generated in the
relays coil. This diode is also known as freewheeling diode. [35]

Figure 11 :PIC16F877A interfaced with a relay

3.6 Liquid Crystal Display (LCD)


A liquid-crystal display (LCD) is a flat panel display, electronic visual display, or video
display that uses the light modulating properties of liquid crystals. Liquid crystals do not emit
light directly. LCDs are available to display arbitrary images (as in a general-purpose computer
display) or fixed images which can be displayed or hidden, such as preset words, digits, and 7-
segment displays as in a digital clock. They use the same basic technology, except that arbitrary
images are made up of a large number of small pixels, while other displays have larger elements.

The LCD screen is more energy efficient and can be disposed of more safely than a CRT. Its low
electrical power consumption enables it to be used in battery-powered electronic equipment. It is
39
an electronically modulated optical device made up of any number of segments filled with liquid
crystals and arrayed in front of a light source (backlight) or reflector to produce images in color
or monochrome [3].

3.6.1 Pin Diagram


Most of the LCD modules conform to a standard interface specification. A 14pin access is
provided having eight data lines, three control lines and three power lines. The connections are
laid out in one of the two common configurations, either two rows of seven pins, or a single row
of 14 pins.[3]

Figure 12 : Pin Diagram of LCD Display

3.6.2 Pin Description

Vcc, Vss, VEE


While Vcc and Vss provide +5v and ground, respectively, VEE is used for controlling LCD
contrast.

RS (Register Select)
There are two very important registers inside the LCD. The RS pin is used for their selection as
follows. If RS = 0, the instruction command code register is selected, allowing the user to send a
command such as clear display, cursor at home, etc. If RS = 1 the data register is selected,
allowing the user to send data to be displayed on the LCD.
R/W (Read/Write)
R/W input allows the user to write information to the LCD or read information from it.

40
R/W = 1 when reading;
R/W = 0 when writing.
En (Enable)
The enable pin is used by the LCD to latch information presented to its data pins. When data is
supplied to data pins, a high - to - low pulse must be applied to this pin in order for the LCD
latch in the data pins. This pulse must be a minimum of 450 ns wide.
D0 - D7
The 8 - bit data pins, D0 - D7, are used to send information to the LCD or read
the contents of the LCD's internal registers. To display letters and numbers, we send
ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making
RS=1.There are also instruction command codes that can be sent to the LCD to clear the
display or force the cursor to the home position or blink the instruction command codes.
We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive
information. The busy flag is D7 and can be read when R/W=1 and RS=0, as follows: if
R/W=1, RS=0. When D7=1 (busy flag=1), the LCD is busy taking care of internal operations
and will not accept any information.[3]

3.6.3 Basic Commands of LCD


Set Cursor Move Direction
04h – Shift cursor to the left
06h – Shift cursor to the right
80h – force cursor to the beginning of the first line
C0h – force cursor to the beginning of second line
02h – return home
Enable Display/Cursor
0Ch - Turn Display On, cursor off
0ah - Turn Cursor On, Display off
08h - Cursor off, Display off
0eh/0fh- display on, cursor blinking
Shift Display
18h – 1Ch - Display Shift to left, right respectively

41
3.6.4 Interfacing of LCD

Figure 13: PIC16F877A interfaced with 2X16 LCD

The interface between this LCD and Microcontroller can be 8 bit or 4 bit and the difference
between them is in how the data or commands are sent to LCD. In the 8 bit mode, 8 bit data and
commands are sent through the data lines DB0 – DB7 and data strobe is given through E input of
the LCD. But 4 bit mode uses only 4 data lines. In this, 8 bit data and commands are split into 2
parts (4 bits each) and are sent sequentially through data lines DB4 – DB7 with its own data
strobe through E input. The idea of 4 bit communication is introduced to save pins of a
microcontroller. The connection of LCD with PIC16F877A is shown in the above diagram.[36]

3.7 Power supply unit

42
Figure 14: Block diagram of power supply unit

Figure 15: Schematic diagram for power supply unit

Most current technologies worldwide all have their dependency on electrical power sources.
Every devices or technology requires the appropriate power source for its efficient operation.
Most electronic devices work within certain specific DC voltage ranges. This is normally from +
or – 5v to + or – 12 V. This range is utilized for the same 230V – 50Hz and stepping down,
rectifying, filtering and regulating the voltage. [29]

3.7.1 Transformer

A step-down transformer is needed to step main supply voltage down to the micro-controller
voltage of 5V. When an AC is applied to the primary side of the transformer the voltage is
stepped down to the appropriate level needed at the micro-controller input. The transformer of
230/5V is used to step down the transmitted voltage of 230V to 5V as needed by the
microcontroller. Apart from stepping down the AC voltage, it gives isolation between power
source and power supply circuitry. [29]

43
3.7.2 Rectifying unit

In most supply units, rectification is normally achieved by diodes in the solid state. The diode
allows the electrons flow in one direction at the appropriate biasing conditions. As AC is
supplied electrons flow only when the anode and cathode are negative. Reversing the polarity of
the voltage will not permit electron flow. A commonly used circuit supplying large DC power is
the bridge rectifier. The bridge rectifier is made up of four diodes that are used to achieve full
wave rectification. Two of the diodes conduct during the negative cycle and the other two during
the positive cycle. The DC voltage appearing across the terminals of the bridge rectifier is
normally less than 90% of the applied rms value. Normally one alteration of the input voltage
will change the polarity. Opposite ends of the transformer will always be 180 degrees out of
phase with each other. For a positive cycle two diodes are connected to the positive diode at the
top winding and only one diode conducts. At the same time one of the other diodes conducts for
the negative voltage that is applied from the bottom winding due to forward bias of that diode.
The output obtained is not a pure DC hence some filtering has to be done. [29]

3.7.3 Filtering unit

Due to the fact that the output obtained is not pure DC, some filtering needs to be done so as to
obtain pure DC. Filter circuit are normally capacitors acting as surge arrestors and always follow
the rectifying unit. These capacitors are called decoupling or by-passing capacitors; it is used not
only to ‘short’ the ripple with frequency of 120Hz to ground but also to leave the frequency of the
DC to appear at the output. A load resistor is used so that a reference to ground is maintained.
C1R1 is for bypassing ripples and C2R2 is used as a low pass filter. The load resistor should be
about 1% to 2.5% of the total load. [29]

3.7.4 Voltage regulator

The voltage regulator is of great importance to the power supply unit. The primary aim of the
voltage regulator is to aid the rectifier and filter circuits in providing a constant DC voltage to the
device. Power supplies without the regulator normally change the value of the DC voltage due to
change in load and also fluctuation in AC line voltage. [29]

44
3.8 Flow Chart

Figure 16 : flow chart

To implement this system, a PIC microcontroller based board is used. It uses an 8-bit
PIC16F877A microcontroller with on-chip ADC, timer/counter module, interrupt, PWM and
UART module to interface a relay circuit, energy meter and the GSM modem. The electronic
energy meter has an LED which blinks for a specific number of times to indicate the energy
consumed. These pulses are fed as an input to the PIC based system which is programmed to
count these pulses and increments the internal counter by one unit after 1600 pulses are counted.

When a message is received from the GSM modem through UART interface, the interrupt
service routine interrupts the PIC controller which first checks the message type and return either
energy meter reading, disconnects the supply or reconnects the power supply depending on the
type of message received.

45
46
CHAPTER FOUR

METHODOLOGY

4.1 Introduction
This chapter gives an overview of the various steps taken so far and the steps that would be taken
to ensure the successful completion of the project.

4.2 Steps taken so far


The following steps have been taken so far towards the completion of the project.
 Understanding the project

 Review of existing literature on the project

 Research of various components required

 Research of Automatic Energy Meters

 Typing of project write-up

4.3 Steps to be taken


 Ordering of components
 Simulation of the final circuit
 Programming of the microcontroller
 Building and implementation of the final circuit
 Testing of the built circuit
 Typing of project write up

47
CHAPTER FIVE

IMPLEMENTATION AND RESULTS

5.1 DESIGN CONSIDERATION

The GSM based automatic energy meter is designed to provide remote meter reading and control
of the energy meter. The design of the automatic energy meter involved the following;

1. Reading extensively on the operations and workings of the pic microcontroller, the
GSM Modem and the electronic energy meter to gain more insight into how we are
going to cordinate all the various parts together to achieve the ultimate working of the
GSM based automatic meter reading system.
2. With an understanding of operation of the microcontroller, electronic energy meter
and GSM module,, a flow chart describing how our design is expected to function
was generated.
3. Generating of a code. Based on the flow chart designed, a code was generated using
Mikro C Pro
4. Selection of components.
After the code was generated, the components needed for the design were carefully
selected with the following factors taken into consideration;
o Their operating voltage range.
The PIC 18F4550 Microcontroller, the Real Time Clock and the 16*2 LCD all
had operating voltage range of 5V.
o Their power consumption.
The components chosen had low power consumption.
o Their compatibility with each other.
The LCD and Real Time Clock, Solid State Relay are microcontroller
compatible, hence interface to the microcontroller was possible and fairly simple.
The output pulses from the energy meter are fed to the microcontroller through an
optocoupler.
5. Selection of power supply.
48
As stated above, the voltage requirements of the components was typically 5V, hence
a power source that could supply 5V and also provide sufficient power to
simultaneously power all components was required.
Two considerations were made;
 A 9V battery which would be regulated to supply 5V.
 A USB Power supply
The latter was chosen because it was able to provide sufficient constant stable
power for the entire circuitry, while the battery only powers for a short while
and runs down.

5.2 DESIGN SPECIFICATIONS


Based on the design considerations enumerated in the previous section, we set out the
specifications for our design. The specifications were as follows:

 An Electronic energy meter with pulse output will be used to record the amount of energy
being consumed.
 The microcontroller was to be used as the controller for our system.
 GSM module would be used for transmission of data on energy usage from the
customer’s outlets to the energy provider and back to the customer making use of the
SMS feature.
 A solid state relay together with a contactor would be used for disconnecting and
establishing connections for customers with outstanding bills
 There would also be a display subsystem (LCD) to display the information of the amount
of energy used for the time interval.

The figure below shows the block diagram of the various components that are put together to
form the GSM based automatic energy meter reading system.

49
5.3 Subsystems of the Design
The system we have implemented can be divided into six subsystems and these are:

 Microcontroller
 Energy meter circuit
 GSM Transmission Circuit
 Switching Circuit
 Power Supply Circuit

50
5.3.1 Microcontroller

The Microchip PIC18F family of high-speed, low-power microcontrollers consists of several


devices with a number of peripherals that are suited for a wide variety of applications. Its low
power modes are designed to make the microcontrollers consume less power even when they are
running a lot of operations.
For our design, we chose the Microchip PIC18F4550 microcontroller as the controller to use in
our system. The PIC18F4550 has 5 bidirectional input/output (I/O) ports comprising a total of 35
I/O pins, a 10-bit analog-to-digital converter, 32 kilobytes of flash program memory and 2048
bytes of SRAM data memory. In addition it has pins that can be used for interfacing in Universal
Serial Bus (USB) and Streaming Parallel Port (SPP) communication and it can be operated over
a wide voltage range (2.0V to 5.5V). ). The PIC18F4550 can be used in applications such as data
logging, sensory applications, wireless data transmission and power management systems.

Figure gives a block diagram of the architecture of the PIC18F4550 microcontroller


.

In order for the microcontroller to operate effectively it is programmed with a control algorithm
by the use of either a programmer or an In-Circuit Debugger (ICD). The source code for the

51
microcontroller is written in a procedural high level language such as mikro C and the micro-
controller was programmed using the PICKit application.

Algorithm showing the flow of control is shown as a flow chart in Figure 4.4.
5.3.2 Switching Circuit
Solid State Relays are used as the switching devices in the system. These relays allow low power
signals to drive high power AC loads with very few components. These relays are also designed to
keep the low voltage sections isolated from the AC mains supply. The relay is connected to a port of
the microcontroller through a 220 Ohm resistor.

5.3.3 GSM Communication Circuit.


The GSM communication Circuit consists of a SIM 300 GSM Module connected to the PIC
microcontroller through aRS232 serial communication interface.

5.3.4 Power Supply Circuit


The power supply for the GSM based automatic meter reading consists of a voltage regulator
circuit which is designed to give a continuous regulated 5V power supply to all the components
in the various systems. The input to the voltage circuit can be obtained from either an
unregulated DC supply between 8-24 V or directly through the main 240V supply which has
been stepped down and rectified in order to produce the unregulated DC supply. The capacitors
in the voltage regulator circuit are used to filter out voltage transients and high frequency noise.
Figure 4.8 shows the power supply circuit for the air conditioner control system using an
unregulated DC supply.

52
5.4 COMPLETE CIRCUIT AND MODE OF OPERATTION

The complete circuit schematic for the GSM based automatic energy meter reading system is shown
in the figure below

53
Snapshot of our GSM based Automatic energy meter design
The Operation of the Complete Circuit is as follows; the energy meter measures the amount of
energy being consumed and produces pulses at a frequency proportional to the quantity of energy
being consumed which are fed through an optocoupler to the PIC microcontroller. A count is
incremented every time 500 pulses have been counted. Each count represents 1KWh of energy
consumed. When an SMS message “read” is sent to the modem, an interrupt flag is raised and
the current count is sent as a text message back to the sender through the GSM modem. When
an SMS message “disconnect” is received, the microcontroller detects it and deenergizes the
relay to opens the circuit to the load and sends a feedback to the sender through the modem. An
SMS message of “reconnect” energizes the relay to reestablish connection to the load and also
send feeback to the sender.

54
5.5 TESTING AND RESULTS

TEST MESSAGE OUTPUT FEEDBACK


SENT
1 read Not Message
Applicable containing
meter reading
received
2 disconnect Load/light Message of
bulbs turn “meter
off disconnected”
3 connect No output No feedback
received
4 connect Load/light Message of
bulbs turned “meter
on reconnected”
received
5 disconnect Load/light Message of
bulbs turned “meter
off disconnected
Received at a
later time
6 read Not Message of
Applicable reading
received at a
later date

5.5.1 DISCUSSION OF RESULTS


During Test 1 We sent a message containing “read” to retrieve the reading of the meter and we received
the reading through SMS some few moments later indicating the reading part was working as expected.

In the next test, we sent “disconnect” and the lamps were turned off and we received a text message
containing “meter disconnected” as expected. However on the third test, when we sent “connect” the
light bulbs didn’t come on. This was later diagnosed to be a programming error where we were instantly
deleting messages that arrived and hence could not read the message to reconnect. This problem was
then solved by inserting a delaying to allow the message to settle and be read properly before deleting.
We got the expected results for reconnection in test 4 as indicated. During test five. The expected
message for confirming disconnection was received at a later time which could be attributed to
problems on the network operators side, the same thing happened for “read” on test 6.

55
CHAPTER SIX
6.1 CONCLUSION
In this project, a device incorporating a microcontroller and GSM modem has been designed and
built in order to take meter reading of the amount of energy used from a consumers unit to
energy provider’s outlet .The data from the energy consumption is processed and the bill sent via
the GSM technology from the energy provider to the consumer. The design was done in order to
make reading and billing more accurate. The system will also help to disconnect customers with
outstanding bills from the system until they have paid all arrears’.

From the work we have done up to now from the conception of the idea to the development of
the final product, we tried as much as possible to keep the design true to those objectives as
much as possible.

56
As a result, the final device is one that is very efficient in obtaining meter reading and data with
minimum margin of error, faster means of transmission from the customer to the energy provider
and vice- versa and frequent notification to the customer through SMS.

6.2 FURTHER WORK


For our GSM based automatic energy meter reading the processes that would be done to improve
it given more time and resources include an e-paying system like mobile money. In this proposed
system bills will be paid by a customer from his phone at his or her own comfort without any
worries. This makes payment also to be done at all times of the day and all days of the week.

The system can also be improved to make it temper proof and also be able to control theft. The
system of each user will be made to have special codes and numbers that make them not be
easily accessible. Also any tempering of the meter or the system will send a signal to the energy
providers outlet for a immediate action to be taken.

REFERENCES
[1] Hung-Cheng, Chen and Chang, Long-Yi. Design and Implementation of a ZigBee-Based Wireless.
2012. ISSN 0033-2097.

[2]. Automatic Power Meter Reading SystemUsing GSM Network. Tan, H.G. Rodney, Lee, C.H. and MOK,
V.H. 2007. The 8th International Power Engineering Conference (IPEC).

[3]. share.pdfonline.com. pdfonline. [Online]


http://share.pdfonline.com/59ba8e52b9ad4c8c98d961d3d0672235/new%20documentation(2)(1)
(1).pdf.

[4]. A reliable and economically feasible automatic meter reading system. Moghavvemi, M, Tan, S.Y.
and Wong, S.K. 2005, International Journal Of Engineering -Materials And Energy Research.

[5]. Automatic Meter Reading as published in Public Power magazine Volume 50, Number 5. Tamarkin,
Tom D. 1992.

[6]. Tuna, Gurkan. Design considerations of UAV-aided automated meter reading. 2011.

[7]. Rom-dev Systems. [Online] http://www.romdev-systems.com/index.php?page=ecm-definition.

[8]. wikipedia. [Online] http://en.wikipedia.org/wiki/Automatic_meter_reading.

57
[9]. Ahmed, Tanvir, et al. Automatic Electric Meter Reading System: A cost-feasible alternative
approach in meter reading for bangladesh perspective using low-cost digital wattmeter and WIMAX
technology. Bangladesh : s.n., 2010.

[10]. Application of Power Line Carrier (PLC) in Automated Meter Reading (AMR). Tasfin, Haq
Mohaimee. August - 2013, International Journal of Engineering Research & Technology (IJERT).

[11]. Koay, B. S., et al. Design and Implementation of Bluetooth Energy Meter. s.l. : Network Technology
Research Centre,School of Electronics & Electrical Engineering,Nanyang Technological
University,Singapore, 2003.

[12]. Li Li, Xiaoguang Hu and Zhang, Weicun. Design of an ARM-Based Power Meter Having WIFI. s.l. :
ICIEA, 2009.

[13]. GSM BasedAutomatic Energy Meter Reading. George, Sudhish N and K, Ashna. 2013.

[14]. Fault-tolerant ZigBee-based Automatic Meter Reading. Hwang, Kwang-il. 4, s.l. : Journal of
Information Processing Systems, 2009, Vol. 5. ISSN 1976-913X.

[15]. An Electrical Energy Consumer Load Monitoring and Control System. J., Tsado, et al. s.l. : Research
Journal of Applied Sciences, Engineering and Technology, 2012. ISSN: 2040-7467.

[16]. Automatic Meter Reading and Theft. Malhotra, P. Rakesh and Dr.R.Seethalakshmi. 2, s.l. :
International Journal of Engineering and Technology (IJET), 2013, Vol. 5. ISSN : 0975-4024.

[17]. GSM Based Automated Meter Reading With Bill. Chhettri, S., Nath, A.K. and Ahmed, M.A. 1, s.l. :
International Journal of Emerging Trends in Electrical and Electronics (IJETEE), 2013, Vol. 4. ISSN: 2320-
9569.

[18]. Smart and Intelligent GSM based Automatic Meter Reading System. Abhinandan, Jain and Dilip,
Kumar, Jyoti Kedia. 3, s.l. : International Journal of Engineering Research and Technology , 2012, Vol. 1.
ISSN: 2278-0181.

[19]. GSM GSM Based ased Automatic utomatic utomatic utomatic utomatic Meter Reading System
Using Meter Reading System Using Meter Reading System Using Meter Reading System GSM Based
Automatic Meter Reading System Using ARM Controller. Kulkarni, Bharat. 5, s.l. : International Journal
of Emerging Technology and Advanced Engineering, 2012, Vol. 2. ISSN 2250-2459.

[20]. wikipedia. [Online] http://en.wikipedia.org/wiki/Microcontroller.

[21]. Engineers garage. [Online] http://www.engineersgarage.com/what-is-8051-microcontroller.

[22]. Sociaety of Robots. [Online] http://www.societyofrobots.com/robotforum/index.php?


topic=11153.5;wap2). .

[23]. 8051 projects. [Online] http://www.8051projects.net/t28834/general-help-guidance-


discussion/comparison-pic-arm-avr.htm#sthash.6YZKyQNP.dpuf.

[24]. hbeon labs. [Online] http://www.hbeonlabs.com.

[25]. Introduction to AVR. atmel.com. [Online]

58
[26]. Shahrara, Reza. Design and Implementation of a Microcontroller Based Wireless Meter.
Gazimagusa : s.n., 2011.

[27]. Arm Based Wireless Energy Meter Reading System Along with POWER on/off CIRCUIT. V V Rajesh,
Parvathala, T, Venkateswarareddy and Prasad, N V G. 2, s.l. : International Journal of Engineering and
Advanced Technology (IJEAT), 2012, Vol. 2. ISSN: 2249 – 8958.

[28]. wikipedia. [Online] http://en.wikipedia.org/wiki/PIC_microcontroller.

[29]. S. MOHAMED, HAJIALI, MARAICAYAR, RIYAZ, G. MOHAMED and MOHAN, P. DIGITAL ENERGY
METER USING GSM. 2008.

[30]. Microchip. PIC16F87XA Data Sheet. microchip.com. [Online]

[31]. wikipedia. [Online] http://en.wikipedia.org/wiki/GSM.

[32]. engineers garage. [Online] http://en.wikipedia.org/wiki/GSM.

[33]. engineers garage. [Online] http://www.engineersgarage.com/microcontroller/8051projects/gsm-


interface-8051-microcontroller-circuit-code.

[34]. wikipedia. [Online] http://en.wikipedia.org/wiki/Electricity_meter.

[35]. Electrosome. [Online] http://electrosome.com/interfacing-relay-with-pic-


microcontroller/#disqus_thread.

[36]. electroSome. [Online] http://electrosome.com/interfacing-lcd-with-pic-microcontroller-hi-tech-c/.

59
APPENDIX
Source code for GSM Based Automatic Energy Meter reading System
sbit LCD_RS at LATE0_bit;

sbit LCD_EN at LATE2_bit;

sbit LCD_D4 at LATD4_bit;

sbit LCD_D5 at LATD5_bit;

sbit LCD_D6 at LATD6_bit;

sbit LCD_D7 at LATD7_bit;

sbit LCD_RS_Direction at TRISE0_bit;

sbit LCD_EN_Direction at TRISE2_bit;

sbit LCD_D4_Direction at TRISD4_bit;

sbit LCD_D5_Direction at TRISD5_bit;

sbit LCD_D6_Direction at TRISD6_bit;

sbit LCD_D7_Direction at TRISD7_bit;

// End LCD module connections

60
char array[8];

char array2[8];

unsigned int cnt;

unsigned int cont;

unsigned int*point;

unsigned char receive[8];

int cnt2;

int x=0;

unsigned char s_num[14];

char array9[8];

char array10[8];

char array5[]="ATE0";

char array6[]="AT+CMGF=1";

char array7[]="AT&W";

char array8[]="AT+CMGR=1";

char array11[]="METER No.456704 READING:";

char array12[]="UNITS USED:";

char array13[]="AT+CMGS=" ;

char array14[]="AT+CMGDA=" ;

char array15[]="DEL ALL" ;

void send()

61
{

UART1_Write_Text(array13);

Delay_ms(1000);

UART1_Write(0x22); //” double qoute

UART1_Write_Text("233242550242"); // Your Telephone Number cd_chr_cp(uart_rd);

Delay_ms(2000);

UART1_Write(0x22); //” double qoute

UART1_Write(13);

UART1_Write(10);// mean Enter

Delay_ms(2000);

void send1(){

Delay_ms(1000);

UART1_Write(0x0D);

Delay_ms(2000);

UART1_Write(26); //Ctr +Z

Delay_ms(2000);

void well(){

UART1_Write_Text("ATE0");

UART1_Write(13);

UART1_Write(10);

Delay_ms(1000);

UART1_Write_Text("AT+CMGF=1");

62
UART1_Write(13);

UART1_Write(10);

Delay_ms(1000);

UART1_Write_Text(array8);

UART1_Write(13);

UART1_Write(10);

int ok_1=0;

int ok_2=0;

void authenticate(){

if (s_num[5]=='4' && s_num[6]== '2' && s_num[7] == '5' && s_num[8] == '5') {

ok_1=1; //Lcd_Out(2,1,".");

void authenticate1(){

if (s_num[5]=='4' && s_num[6]== '2' && s_num[7] == '5' && s_num[8] == '5') {

Lcd_Cmd(_LCD_CLEAR);

ok_1=2; //Lcd_Out(2,16,".");

void authenticate2(){

if (s_num[5]=='4' && s_num[6]== '2' && s_num[7] == '5' && s_num[8] == '5') {

ok_2=1; //Lcd_Out(2,1,".");

63
}

void gsm()

{ unsigned char receive2[100];

const char auth[]= "+233242550242";

int g=0;

int j=0;
//unsigned char receive3[100]={0x00};

int b2=0;

int c=0;

int d=0;

int a=0;

int eu; //int ok_1=0;

CCP1CON= CCP2CON = 0;

ADCON1=ADCON0= 6;

well();

if (UART1_Data_Ready()==1) //FOR REAL THING

uart1_read_text(receive2, "OK",100);

//
delay_ms(500);

while(receive2[g]!='2'&& receive2[g+1]!='3'&& receive2[g+2]!='3')g++;

64
for(d=1;d<=13;d++){ //
LCD_Chr(2,d,receive2[g]);

s_num[d-1]=receive2[g];

//lcd_chr(2,2,s_num[d-1]);

g++;
//LCD_Chr(1,d,auth[d-1]);

//delay_ms(500);

}
//DELAY_MS(2000);

authenticate();

authenticate2();

while(receive2[g]!= 0xA)g++;

g++;

while(receive2[g]){

receive2[j++] = receive2[g++]; receive2[j] ='\0'; }

receive[0] = receive2[0] ;

if(receive[0]=='r' && ok_1==1 )

{ PORTB.F4 = 1;

eu =cnt-x;

inttostr (eu,array9);

inttostr (cnt,array2);

x = cnt;

65
send();

UART1_Write_Text(array11);

UART1_Write_Text(array2);

UART1_Write(10);

UART1_Write_Text(array12);

UART1_Write_Text(array9);

//time_stamp(); //spot

send1();

//Delay_ms(1000);

PORTB.F4 = 0;

else if(receive[0]=='d' && ok_2==1 )

PORTB.F7 = 0; //Turns ON relay

Lcd_Cmd(_LCD_CLEAR);

lcd_out(1,4,"DISCONNECTED");

send();

UART1_Write_Text("METER No.456704 Disconneted");

send1();

UART1_Write_Text(array14);

Delay_ms(1000);

UART1_Write(0X22);

UART1_Write_Text("DEL READ");

Delay_ms(1000);

UART1_Write(0X22);

Lcd_Cmd(_LCD_CLEAR);

66
while(1) {

b2=0;

c=0;

a=0;

d=0;

Lcd_Out(1,1,".");

Delay_ms(30000);

well();

if (UART1_Data_Ready()==1) //FOR REAL THING

uart1_read_text(receive2, "OK",100);

Lcd_Cmd(_LCD_CLEAR);

while(receive2[b2]!='2'&& receive2[b2+1]!='3'&& receive2[b2+2]!='3')b2++;

for(d=1;d<=13;d++){ //
LCD_Chr(2,d,receive2[g]);

s_num[d-1]=receive2[b2];

// lcd_chr(2,2,s_num[d-1]);

b2++;
//LCD_Chr(1,d,auth[d-1]);

//delay_ms(500);

}
67
authenticate1();

while(receive2[b2]!= 0xA)b2++;

b2++;

while(receive2[b2]){

receive2[c++] = receive2[b2++];

receive[0] = receive2[0] ;

receive2[j] ='\0';

if(receive2[0]=='c' && ok_1==2)

PORTB.F7 =1; //Turns Off relay

Delay_ms(1000);

Lcd_Cmd(_LCD_CLEAR);

lcd_out(1,4,"RECONNECTED");

send();

UART1_Write_Text("METER No.456704 RECONNECTED");

//time_stamp(); //spot

send1();

break;

68
}

UART1_Write_Text(array14);

Delay_ms(1000);

UART1_Write(0X22);

UART1_Write_Text("DEL READ");

Delay_ms(1000);

UART1_Write(0X22);

memset( receive2,'0',80);

receive2[0]='\0';

else

goto Error

Error: ;

UART1_Write_Text(array14);

Delay_ms(1000);

UART1_Write(0X22);

UART1_Write_Text("DEL READ");

Delay_ms(1000);

UART1_Write(0X22);

receive2[0]='\0';

memset( receive2,'0',80);

69
}

void main()

int pulses=0;

point = &cnt;

ADCON1=ADCON0= 6; // Changes PORTA to digital

CCP1CON=CCP2CON=0; // Disable analog comparators

PORTA = 0; // Reset port A

TRISA = 0xFF; // All portA pins are configured as inputs

TRISD = 0; // All port B pins are configured as outputs

PORTD = 0x0; // Reset port B

T0CON = 0b11111000; // Counter TMR0 receives pulses through the RA4 pin

PORTE.F1=0;

LATE1_bit=0;

TRISE1_bit=0;

TRISB=0;

PORTB.F7 = 1;

PORTB.F4 = 0; // Prescaler rate is 1:1

Lcd_Init(); // LCD display initialization

Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)

Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)

70
UART1_Init(9600);

Delay_ms(1000);

TMR0L= 240; //TMR0H = ; // Reset timer/counter TMR0

PIR1.TMR0IF = 0;

PIE1.TMR0IE = 1;

INTCON = 0xA0; // Enable interrupt TMR0

cnt = 0; // Variable cnt is assigned a 0

cont = 0;

while(1) {

inttostr (cnt,array2);

Lcd_Out(1,1,array2);

Lcd_Out(1,8,"UNITS");

pulses=TMR0L-240;

inttostr(pulses,array);

Lcd_Out(2,1,array);

if(cont!=cnt)

{ ok_1=0;

ok_2=0;

gsm();

Lcd_Cmd(_LCD_CLEAR);

cont = *point;

71
void interrupt() {

cnt++; // Interrupt causes cnt to be incremented by 1

TMR0L= 240; // Timer TMR0 is returned its initialvalue

INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared

72

You might also like