Beruflich Dokumente
Kultur Dokumente
Acknowledgement
There are number of individuals who deserve my sincere gratitude for helping me to complete
this work. First and foremost, I would like to express my gratitude and appreciation to my guide
towards Prof. S.S.Vaidya for most valuable guidance and help. I express my deepest gratitude to
Prof. S.S.Vaidya Head of the Department, Sanghavi College Of Engineering, Nashik has given
me ample freedom while doing this work and also provided the moral support at difficult situations. It
was my honor to work under her.
Also, I am very thankful to Prof. N.V. Palde, Principal, Sanghavi College Of Engineering,
Nashik for his suggestions, encouragement and constant support. Last but not the least. I would like to
thank my family for their support, guidance, words of encouragement and unselfish love and all those
people who helped us in making this project a success.
1
IOT Based Smart Energy Meter
Abbreviations
List of Abbreviations
ACC : Accumulator
B : B Register
PSW : Program Status Word
SP : Stack Pointer
DPTR : Data Pointer
DPL : Low byte
DPH : High byte
P0 : Port 0
P1 : Port 1
P2 : Port 2
P3 : Port 3
IE : Interrupt Enable control
IP : Interrupt Priority control
TMOD : Timer/counter Mode control
TCON : Timer/counter control
T2CON : Timer/counter 2 control
T2MOD : Timer/counter mode2 control
TH0 : Timer/counter 0high byte
TL0 : Timer /counter 0low byte
TH1 : Timer/counter 1high byte
TL1 : Timer/counter 1low byte
TH2 : Timer/counter 2 high byte
TL2 : Timer/counter 2 low byte
SCON : Serial control
SBUF : Serial data buffer
PCON : Power control
IR : Infra Red
2
IOT Based Smart Energy Meter
ABSTRACT
Saving energy is high on the agenda for consumers and businesses, but with most of
the electrical devices today, it‘s difficult to know how much energy we are actually using at
any given point in time. Smart Energy Meter is a meter which helps the consumers to know
their day to day power consumption to better control their usage and producers to manage
production. This meter records consumption of electric energy in intervals of hour or less.
Smart meters enable two-way communication between the meter and the central system. The
proposed project comprises of hardware design using a low-cost 8-bit P89C51RD2xx
microcontroller and the complete hardware design will be proposed .The Communication is
through SMS. They are two one is admin password and second is user. By this admin
password the cost per unit can be changed by the concerned officer The system software
driver is also developed using embedded-C programming language in Keil µVision 4 IDE. .
Smart meters are also believed to be a less costly alternative to traditional interval or time-of-
use meters and are intended to be used on a wide scale with all customer classes, including
residential customers. The project also addresses about the various debugging tools such as
Keil µVision 4 C51 debugger and Flash magic tool 9.25 version used to test the implemented
prototype.
3
IOT Based Smart Energy Meter
Contents
Acknowledgement
Abstract
Contents
List of abbreviations
List of figures
List of Tables
1. INTRODUCTION 10
2. LITERATURE SURVEY
2.1 Motivation 12
2.2 Background 12
2.3 Aim 12
2.4 Requirement Analysis 13
2.4.1 Hardware Requirements 13
2.4.2 Software Requirements 13
2.5 Scope 13
2.6 Advantages 14
3. DESIGN METHODOLOGY
3.1 Hardware system design 15
3.1.1 Block level design of Smart Energy Meter 16
3.1.2 Selection of Hardware 16
3.1.3 Design consideration of Microcontroller 17
3.1.3.2.1 I/O ports 19
3.1.3.2.2 Interrupt controls 19
3.1.3.2.3 Bus controllers 20
3.1.3.2.4Registers in 8051 21
3.1.3.2.5 Oscillator 21
4
IOT Based Smart Energy Meter
3.1.3.3 Features 22
3.1.4 Serial communication 23
3.1.4.1 Introduction 24
3.1.4.2 Baud rate 24
3.1.5 Hardware design of LCD 25
3.1.5.1 LCD screen 26
3.1.5.3 Functionality of LCD in project 27
3.1.6 MAX232 28
3.1.6.1 Pin configuration 29
3.1.7 RS232 (Female port) 30
3.1.7.1 Voltage levels 32
3.1.7.2 Pin configuration 33
3.1.7.3 DB9 interfacing microcontroller using MAX232 33
3.1.8 Serial port connector 34
3.1.9 Design of KEYPAD 35
3.1.10 IR sensors and IC NE555 Timer 36
3.1.10.1 Photo transmitter 36
3.1.11 IC NE555 timer 37
3.1.12 Resistors 38
3.1.13 Capacitors 38
3.1.14 Crystal oscillators 39
3.2 Software design 39
3.2.1 Liquid Crystal Display 40
3.2.1.1 Initialization of LCD 40
3.2.2 KEYPAD 41
3.2.2.1 Flow chart of keyboard scanning algorithm 42
4. HARDWARE IMPLEMENTATION
4.1 Hardware implementation 43
4.1.1 Complete Schematic of Smart Energy Meter 43
4.1.2 Connections of P89C51RD2FN 44
4.1.3 Pin connections of LCD 45
4.1.4 Keypad connections 46
4.1.5 MAX232 and DB9 connections 46
4.1.6 IC555 timer and IR transmitter connections 47
5
IOT Based Smart Energy Meter
5. SOFTWARE IMPLEMENTATION
5.1 JHD162A LCD interfacing 48
5.1.1 Initialization of LCD 48
5.1.2 Initialization sequence code 48
5.1.3 Checking the busy state of LCD 49
5.1.4 Writing the command to display 49
5.1.5 Writing data to display 50
5.1.6 Displaying the data into LCD 50
5.1.7 4*4 matrix Keypad interfacing 51
5.1.8 Sensors 52
6. RESULT 53
7. CONCLUSION 54
8. REFERENCES 55
6
IOT Based Smart Energy Meter
List of Figures
3.1 : Functional block diagram of Smart Energy Meter. 16
3.17: IR receiver 37
3.19: Resistors 38
3.20: capacitors 38
8
IOT Based Smart Energy Meter
List of Tables
9
IOT Based Smart Energy Meter
CHAPTER 1 - Introduction
1.1 Introduction
Now-a-days electricity has become a basic need to humans. The consumption of
electricity has increased a lot compared to the past years. The theft of electricity has also
become a problem these days and there is no control over the loss due to theft of electricity.
In this project we present you the smart energy meter device used to measure the
consumption of the electricity by the individual and provide security against theft of
electricity.
A smart meter is usually an electrical meter that records consumption of electric
energy in intervals of an hour or less and communicates that information at least daily back to
the utility for monitoring and billing purposes. Smart meters enable two-way communication
between the meter and the central system. Unlike home energy monitors, smart meters can
gather data for remote reporting.
The term Smart meter often refers to an electricity meter, but it can increasingly also
mean a device measuring natural gas or water consumption. Smart energy meter is software
based, power efficient device that accurately tracks energy consumption and performs
computation. Meter readings can be transmitted to distributors/utilities over wireless media;
thus, eliminating the need of manual meter reading collection process. The smart energy
meter offers major benefits to both customers and companies in terms of efficiency,
reliability, and cost saving.
Imagine if you knew how much energy you were consuming at home at any time of
the day, and knew how much energy each device was using, will you stop using those energy
hog appliances? or use them at the time of the day when the energy is cheapest? in the
economy turmoil we are currently in, I believe all of us are willing to make those small
sacrifices to lower down the bill numbers at the end of the month.
Smart energy meters are devices that will sit on your home, monitor energy data from
your electricity meter, and let you know how much energy you are using – this put more
control on your hands on how you spend your energy at home. Conventional electricity
meters are normally hidden somewhere on a wall on the basement, and the only time you
realize how much energy you’ve been spending is when the bill hit the door.
The new smart meters will provide Indian consumers with information regarding
energy consumption that was not previously available with a traditional meter. This system
will allow the easy disconnection of defaulted customers and power connections from a
10
IOT Based Smart Energy Meter
remote site. The new smart system is also able to instantly detect tampering with the power
lines and sends signals to security personnel if necessary. Utility employees will also have
the ability to change a customer’s billing method from pre-paid to post-paid in a matter of
seconds, without having to physically visit the meter.
11
IOT Based Smart Energy Meter
2.2 Motivation
In the present scenario, the use of advanced technologies such as digital
metering has become extremely necessary to achieve greater efficiency, theft reduction to
reduce AT & C losses and to improve revenue collection. The utilities and planners should
now focus on best use of electronic technology to develop a full ‘smart’ system, which is
capable of offering long term benefits and comprehensive solutions in addition to theft
reduction. In undeveloped and under developing countries proper distribution of power has to
be done. So it’s the duty of us, engineers to develop the equipment’s to reduce the power
losses and power thefts.
12
IOT Based Smart Energy Meter
2.3 Background
An electricity meter or energy meter is a device that measures the amount
of electric energy consumed by a residence, business, or an electrically powered device.
Electricity meters are typically calibrated in billing units, the most common one being the
kilowatt hour. Periodic readings of electric meters establish billing cycles and energy used
during a cycle. In settings when energy savings during certain periods are desired, meters
may measure demand, the maximum use of power in some interval. In some areas, the
electric rates are higher during certain times of day, to encourage reduction in use. The billing
of the electricity consumption in these present days are done with human observation, but this
project deals with the communication for the proper billing through GSM without any human
involvement. Due to theft of electricity leads to power shut down in many of the rural areas in
India.
2.4 Aim:
To design and implement the smart energy meter by using 8051 micro controller
coded in embedded c program.
13
IOT Based Smart Energy Meter
2.6 Scope:
The scope of the project work is to introduce advanced technology in converting dc
voltage in to ac voltage and introducing smart energy metering concept.
In future this project can be used to measuring natural gas or water consumption.
These meters can be connected to GSM module and data (i.e. consumption) can be
transmitted over GSM networks and the bills can be automatically issued to the particular
customer through SMS. By making small modifications in the program (code) we can break
the connection if user does not pay the bills in time. There is no need for the electricity
officials to visit the spot to disconnect the connections i.e., everything can be controlled over
the GSM module. The user can also sell the electricity to the government which is created in
his home using solar cells. These meters can also be used as prepaid energy meters by
slightly modifying them.
2.7 Advantages:
More accurate bills.
Lower bills.
Track of energy usage.
Sell energy back to the grid.
Flexible tariffs.
No more meter readings.
14
IOT Based Smart Energy Meter
15
IOT Based Smart Energy Meter
a. 8051
The 8051 is an 8 bit microcontroller originally developed by Intel in 1980. It is one of
the most popular microcontrollers in the world for its high performance, rich instruction set
and low cost. This device is a Single-Chip 8-Bit Microcontroller manufactured in an
advanced CMOS process and is a derivative of the 8051 microcontroller family. The
instruction set is 100% compatible with the 8051 instruction set. Three criteria in choosing
the microcontrollers are as follows:
1. Meeting the computing needs of the task at hand efficiently and cost
effectively.
2. Availability of software development tools such as compliers, assemblers, and
debuggers.
3. Wide availability and reliable sources of the microcontroller.
16
IOT Based Smart Energy Meter
c. I/O ports:
All 8051 microcontrollers have 4 I/O ports each comprising 8 bits which can be
configured as inputs or outputs. Accordingly, in total of 32 input/output pins enabling the
microcontroller to be connected to peripheral devices are available for use. Pin configuration,
17
IOT Based Smart Energy Meter
i.e. whether it is to be configured as an input (1) or an output (0), depends on its logic state. In
order to configure a microcontroller pin as an input, it is necessary to apply logic zero (0) to
appropriate I/O port bit. In this case, voltage level on appropriate pin will be 0.
The 4I/O ports of 8051 are designated as port 0, port 1, port 2, and port 3. All
these I/O ports have different functions and conditions while connecting to external
peripherals.
d. Port 0 (P0)-
The P0 port is characterized by two functions. If external memory is used then the
lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are
configured as inputs/outputs. The other function is expressed when it is configured as an
output. Unlike other ports consisting of pins with built-in pull-up resistor connected by its
end to 5 V power supply; pins of this port have this resistor left out. If any pin of this port is
configured as an input then it acts as if it “floats”. Such an input has unlimited input
resistance and undetermined potential. When the pin is configured as an output, it acts as an
“open drain”. By applying logic 0 to a port bit, the appropriate pin will be connected to
ground (0V). By applying logic 1, the external output will keep on “floating”. In order to
apply logic 1 (5V) on this output pin, it is necessary to built in an external pull-up resistor.
e. Port 1 (P1)-
P1 is a true I/O port, because it doesn't have any alternative functions as is the case
with P0, but can be configured as general I/O only. It has a pull-up resistor built-in and is
completely compatible with TTL circuits.
f. Port 2 (P2)-
P2 acts similarly to P0 when external memory is used. Pins of this port occupy
addresses intended for external memory chip. This time it is about the higher address byte
with addresses A8-A15. When no memory is added, this port can be used as a general
input/output port showing features similar to P1.
g. Port 3 (P3)-
All port pins can be used as general I/O, but they also have an alternative function. In
order to use these alternative functions, a logic one (1) must be applied to appropriate bit of
18
IOT Based Smart Energy Meter
the P3 register. In terms of hardware, this port is similar to P0, with the difference that its
pins have a pull-up resistor built-in.
h. Interrupts controls:
There are 7 kinds of interrupt controllers that 8051 handles. They are as follows.
There are two types of external hardware interrupts. Pin 12 (P3.2) and pin 13 (P3.3) of the
8051, designated as INT0 and INT1, are used as external hardware interrupts. Upon the
activation of these pins, the 8051 gets interrupted in whatever it is doing and jumps to the
vector table to perform the interrupt service routines (ISR).
Timer 0 and timer 1 interrupts can be used in pooling method. In this method, we
have to wait until the TF is raised. The problem with this method is that the microcontroller is
tied down the controller. If the timer interrupt in the IE register is enabled, whenever the
timer rolls over, TF is raised, and the microcontroller is interrupted in whatever it is doing,
and jumps to the interrupts vector table to service the ISR.
i. Bus Controls
The main bus controllers available in 8051 are ALE, EA, RST and PSEN.
19
IOT Based Smart Energy Meter
RST (Reset):
A high on this pin for two machine cycles while the oscillator is running resets the
device. An internal resistor to VSS permits a power-on reset using only an external capacitor
to VCC.
j. Memory organization
The 8051 has two types of memory and these are Program Memory and Data
Memory. Program Memory (ROM) is used to permanently save the program being executed,
while Data Memory (RAM) is used for temporarily storing data and intermediate results
created and used during the operation of the microcontroller. Depending on the model in use
(we are still talking about the 8051 microcontroller family in general) at most a few Kb of
ROM and 128 or 256 bytes of RAM is used. All 8051 microcontrollers have a 16-bit
addressing bus and are capable of addressing 64 kb memory. It is neither a mistake nor a big
ambition of engineers who were working on basic core development. It is a matter of smart
memory organization which makes these microcontrollers a real “programmers’ goody“.
k. Registers in 8051
In the CPU, registers are used to store information temporarily. That information
could be a byte of data to be processed, or an address pointing to the data to be fetched. The
20
IOT Based Smart Energy Meter
vast majority of 8051 registers are 8- bit registers. In the 8051 there is only one data type: 8
bits. With an 8-bit data type, any data larger than 8 bits must be broken into 8- bit chunks
before it is processed. The most widely used registers of the 8051 are A(Accumulator), B,
and SPF (special function registers) and PSW (Program Status Word).
l. R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even
though they are not true SFRs, they deserve to be discussed here because of their purpose.
They occupy 4 banks within RAM. Similar to the accumulator, they are used for temporary
storing variables and intermediate results during operation. The most widely used registers of
the 8051 are A(Accumulator), B, and SPF (special function registers) and PSW (Program
Status Word).
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even
though they are not true SFRs, they deserve to be discussed here because of their purpose.
21
IOT Based Smart Energy Meter
They occupy 4 banks within RAM.. Active bank is a bank the registers of which are currently
used.
n. Oscillator:
The microcontroller used in this project, P89C51RD2FN requires a baud rate of 9600.
To acquire this baud rate, an 11.0592 MHz crystal must be connected between 19 th and 20th
pins of controller. The determination of machine cycle frequency and Baud rate is as follows.
= (11.0592 * 10^6) / 12
= 921.6 KHz
= (921.6 × 10^3) / 32
= 28800 Hz
XTL = Crystal.
22
IOT Based Smart Energy Meter
To synchronize with timer1 (TH1) to set the baud rate as 9600 we need to set those
register value as -3 (decimal) or FD (Hexadecimal) so as to divide the baud rate i.e..
28800Hz should be dividing with the decimal value of TH1 to get 9600 value.
C1, C2 = 33pF.
o. Features
80C51 Central Processing Unit
On chip Flash Program Memory with In-System Programming (ISP) and In-
Application Programming
Boot ROM contains low level Flash programming routines for downloading via the
UART
Can be programmed by the end-user application(IAP)
Four interrupt priority levels
Seven interrupt sources
Four 8-bit I/O ports
Full-duplex enhanced UART
8-Bit ALU , with 2 registers A & B
11 bit program counter & data pointer
23
IOT Based Smart Energy Meter
3.1.4.1 Introduction
In order to connect microcontroller to a modem or a pc to modem a serial port is used.
Serial is a very common protocol for device communication that is standard on almost every
PC. Most computers include two RS-232 based serial ports. Serial is also a common
communication protocol that is used by many devices for instrumentation; numerous GPIB-
compatible devices also come with an RS232 port. Furthermore, serial communication can be
used for data acquisition in conjunction with a remote sampling device.
Any device you connect to the serial port will need the serial transmission converted
back to parallel so that it can be used. In serial communication, the data will be sent from one
system to another in bit by bit notation. Serial Ports come in two “sizes”, there are the D-
Type 25 pin connector and the D-Type 9 Pin connector both of which are male on the back of
the PC, and thus you will require a female connector on your device. The RS-232 and RS-485
come under serial communication.
24
IOT Based Smart Energy Meter
The LCD (Liquid Crystal Display) used to display the output to the user in the form of
GUI (Graphic User Interface) and a mono chromatic display. LCD used in this project is
JHD162A series. There are 16 pins in all. They are numbered from left to right 1 to 16 (if you
are reading from the backside). LCD shown above is marked to indicate which the 1st pin
was and which the 16th was.
In our project, we use a JHD162A LCD Display which has 2 rows and 16 characters.
It contains internal 1 byte latch. It has a better contrast and a wider viewing angle. To develop
a protocol to interface this LCD with 89C51 first we have to understand how they functions.
These displays contain two internal byte-wide registers, one for command and second for
characters to be displayed. There are three control signals called R/W, RS and EN. Select By
making RS signal 0 you can send different commands to display. These commands are used
to initialize LCD, to display pattern, to shift cursor or screen etc. You can see the markings
right next to 1st and 16th pins. The 16by2 LCD with connections is as given below
of displays have built in backlight (blue or green diodes). When used during operating, a
resistor for current limitation should be used (like with any LE diode)
The main control pins on JHD162A are data lines, read or write and enable.
26
IOT Based Smart Energy Meter
The timing diagram for write and read operation of JHD162A is as follows
Write operation:
Read operation:
The LCD has basically two operating modes: Instruction mode and Character Mode.
Depending on the status of this pin, the data on the 8 data pins (D0-D7) is treated as either an
instruction or as character data. You have to activate the command mode if you want to give
an Instruction to the LCD To set the LCD in Instruction mode, you set the 4th pin of the LCD
(R/S) to GND. To put it in character mode, you connect it to Vcc.
To start with LCD the user should initialize it first which should be programmed with its
LCD commands. The LCD commands are given
28
IOT Based Smart Energy Meter
2 Return home
29
IOT Based Smart Energy Meter
30
IOT Based Smart Energy Meter
0 10V
The microcontroller is connected to the pc via a serial communication port. The serial
communication port is a combination of a female port and a male port. The male port is
connected to the DB-9 connector connected to the microcontroller while the female port is
connected to the serial port of the pc.
33
IOT Based Smart Energy Meter
I/O configuration: Rows are connected to four PIO pins configured as outputs.
Columns are connected to four PIO pins configured as inputs with interrupts. The idle state of
these pins is high level due to four pull-up resistors. PIO interrupt is generated by a low level
applied to these pins (caused by a key pressed). Four additional PIO pins are configured as
outputs to send the value of the pressed key to LEDS.
34
IOT Based Smart Energy Meter
Interrupt: When a key is pressed, a low level is applied to the pin corresponding to
the column associated to the key (pins configured as inputs with interrupts). A falling edge
applied to a column pin creates a PIO interrupt. Then, the processor executes the PIO
interrupt subroutine (debouncing) and comes back to its previous state (in the main program).
After debouncing time, a RC compare timer interrupt occurs and the processor then executes
the timer interrupt subroutine (decoding the pressed key) and comes back to its previous state
(in the main program).
The pair of IR sensors generally constitute of a photo transmitter and a photo receiver.
The photo transmitter generally a photo diode emits IR rays while the receiver receives the IR
rays. Whenever the transmission is blocked the sensor unit sends a interrupt signal to the
microcontroller which then increments the counter.
Photo transmitter:
The photo transmitters are IR LEDs or photo diodes used to emit light. IR
LEDs are just like LEDs which emits IR rays. Since the IR rays are out of the visible range
we cannot observe the rays from the transmitter. A photodiode is a type of photo-detector
capable of converting light into either current or voltage, depending upon the mode of
operation.
Photodiodes are similar to regular semiconductor diodes except that they may be
either exposed (to detect vacuum UV or X-rays) or packaged with a window or optical fibre
connection to allow light to reach the sensitive part of the device. Many diodes designed for
35
IOT Based Smart Energy Meter
use specifically as a photodiode will also use a PIN junction rather than the typical PN
junction.
36
IOT Based Smart Energy Meter
3.1.12 Resistors:
A resistor is a two-terminal passive electronic component that implements electrical
resistance as a circuit element. When a voltage V is applied across the terminals of a resistor,
a current I will flow through the resistor in direct proportion to that voltage. This constant of
proportionality is called conductance, G. The reciprocal of the conductance is known as the
resistance R, since, with a given voltage V, a larger value of R further "resists" the flow of
37
IOT Based Smart Energy Meter
Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens
of megahertz. More than two billion (2×109) crystals are manufactured annually. Most are
used for consumer devices such as wristwatches, clocks, radios, computers, and cell phones.
38
IOT Based Smart Energy Meter
Quartz crystals are also found inside test and measurement equipment, such as counters,
signal generators, and oscilloscopes.
39
IOT Based Smart Energy Meter
To give a command to perform some special functions like move to position, clear
LCD ,blink the curser etc. After finishing the instruction sequence the application must wait
till the LCD completes the instruction by checking the LCD Busy status.
40
IOT Based Smart Energy Meter
Start
RS=0
E=1 RS=
0
Delay
E=1
E=0
Delay
LCD
Bus
y
P0=command
LCD
Bus
y
41
IOT Based Smart Energy Meter
3.2.2 KEYPAD:
3.2.2.1 FLOW CHART OF KEY BOARD SCANNING ALGORITHM
42
IOT Based Smart Energy Meter
43
IOT Based Smart Energy Meter
Pin1 to pin8 (Port 0) of controller are connected to the data lines of keypad (D0-D8).
The reset pin is connected to the 9 th pin (RST) of P89C51RD2FN, as it is used for set
reset the program.
While the 10pin is connected to the 12th pin of MAX232.
11th pin of controller is connected to the 11th pin of MAX232.
The interrupt given by the IR sensors from the 555IC timer should be connected to the
12th pin i.e. INTO pin of controller.
13th pin is used as an external interrupt, but here in this project there is no use with
this pin.
44
IOT Based Smart Energy Meter
The crystal oscillator which gives a frequency of 11.0592 MHz for the required Baud
rate of 9600Hz to the microcontroller. This crystal oscillator is connected in between
18th (XALT 1) and 19th (XALT 2) pins of P89C51RD2FN controller.
The 20th pin of controller is grounded.
The pins from 21st to 28th (port 2 data lines) are used for the external peripheral
connections.
The 29th pin is connected to an on-off switch so as to dump and execute the program.
Whenever the PSEN pin is connected to ground then we can execute the last dumped
program, likewise when 29th pin is connected to VCC then code can be dumped into
the controller.
Address Latch Enable pin (30th pin) of controller is connected to the ground hence no
connections need not to be given to this pin.
External Access Enable or programming supply voltage should be latched when RST
is released and any subsequent changes have no effect. This pin also receives the
programming supply voltage (VPP) during Flash programming. Hence the pin 31 st
must be connected to high i.e. VCC.
Port0 (pins 32 to 39) are connected to LCD in this project. But these should be
connected to other peripherals through pull up resistors.
The 1st and 2nd pins of JHD162A LCD are connected to ground and high voltage VCC
respectively.
3rd pin of LCD is connected to the center pin of the potentiometer or variable resistor
so as to adjust the contrast of LCD.
The 4th, 5th, 6th pins are connected to 26th (P 2.5), 27th (P 2.6), 28th (P 2.7) pins of the
microcontroller respectively.
The 7th to 14th pins are data pins and are connected to the 39th (P 0.0) to 32nd (P 0.7)
pins of the microcontroller respectively.
The 15th and 16th pins are used for backlight purpose. 15 th pin is connected to VCC and
16th pin to ground.
45
IOT Based Smart Energy Meter
Capacitor C10 of capacitance 1Uf is connected across 1st and 3rd pins of MAX232 and
C9 of capacitance 1Uf is connected in between 4th and 5th pins.
Charge pump capacitors are required for the MAX232 to work it as voltage level
shifter. The charge pump capacitors used here are C7 and C8 whose capacitance is
1Uf. C7 is connected between 6th pin and ground, while C8 is connected across 2 nd pin
of MAX232 and Vcc.
12th and 11th pins of MAX232 are connected to the 10th and 11th pins of
P89C51RD2FN controller respectively. These acts as a transmitter and receiver for
the data flow.
46
IOT Based Smart Energy Meter
47
IOT Based Smart Energy Meter
MSDelay(1);
en=1; // Start LCD command
}
}
5.1.4 Writing command to the Display
void lcdcmd (unsigned char value) // LCD command initiation routine
{
Lcdready(); // wait till the LCD executes the instruction
ldata=value; // Set the value(instruction) in Data bus
rs=0; // register select as command
rw=0;
en=1; // set the enable command
MSDelay(1);
en=0; // Reset the enable command
}
49
IOT Based Smart Energy Meter
else if(c1==0)
return '5';
else if(c2==0)
return '8';
else if(c3==0)
return '0';
r2=0; r0=1;r1=1;r3=1;
if(c0==0)
return '3';
else if(c1==0)
return '6';
else if(c2==0)
return '9';
else if(c3==0)
return 'F'; // Down Arrow
r3=0; r0=1;r1=1;r2=1;
if(c0==0)
return 'A';
else if(c1==0)
return 'B';
else if(c2==0)
return 'C'; // Redail
else if(c3==0)
return 'D'; // Enter
}}}
5.1.8 SENSORS:
{
Count++;
Flag=0;
}
}
52
IOT Based Smart Energy Meter
CHAPTER 6 - Results
6.1 RESULTS
Now the most awaited part of the program is final result which can be seen by the
following steps once the kit is ready.
Give 5V Power supply and connect the pc with serial connector to DB9 connector
Now ON the circuit.
We can see on the LCD display “WELCOME RMCE” “SMART ENERGY
METER” and press enter (E) in keypad.
The LCD asks for user id and password. Once they are correct, it shows
“AUTHENTICATED”.
Now main menu is displayed having options:1.Readings
2. Settings
53
IOT Based Smart Energy Meter
Supporting Consumers: a) An end to estimate bills, which are a major source of complaints
for many customers b)A tool to help consumers better manage their energy use - smart meters
with a display can provide up to date information on electricity consumption in the currency
of that country and in doing so help people to better manage their energy use and reduce their
energy bills and carbon emissions .c) voltage levels, and power events can be tracked and
logged across the entire customer base.
Supports Power Grid: The Ability to remotely turn power on or off to a customer, read
usage information from a meter, detect a service outage, detect the unauthorized use of
electricity, know the maximum amount of electricity that a customer can demand at any time.
It is projected to reduce the staff required to read meter data across the customer base.
Supports Environment: The billing is through HyperTerminal or GSM, so lot of paper can
be saved .So Cutting of Trees can be avoided. It is believed that billing customers by time of
day will encourage consumers to adjust their consumption habits to be more responsive to
market prices thereby saving the power by which natural resources are protected.
54
IOT Based Smart Energy Meter
CHAPTER 8 - References
References
1. Janci Gillespie Mazidi, Muhammad Ali Mazidi, The 8051 micro controller and
9. Inc, 2003.
10. http://en.wikipedia.org/wiki/Level_s
IEEE Transactions on Smart Grid, Year: 2020 | Volume: 11, Issue: 4 | Journal Article |
Publisher: IEEE
12. https://www.edgefx.in/microcontroller-based-wireless-energy-meter/
14. https://microcontrollerslab.com/prepaid-energy-meter-gsm-pic/
55