Chapter 5
Chapter 5
Chapter 5
HARDWARE REQUIREMENT
1. ATMEGA 328-P MICROCONTROLLER
2. LCD DISPLAY
3. POWER SUPPLY MODULE
4. ELECTRIC ENERGY METER
5. ACS712 CURRENT SENSOR
6. VOLTAGE SENSOR
7. WI-FI MODULE
1 ATMEGA328-P MICROCONTROLLER
The ATmega328 IC is the brain of the Arduino board and is widely used in various projects. It is not
suitable for industrial use, however, the standalone ATmega328 IC can be used as an alternative to the
Arduino board. It can be programmed using the Arduino IDE, either using FTDI or the Arduino board.
This microcontroller features three Timer/Counters with compare modes and internal/external
interrupts, a USART with serial programming capability, a 2-wire serial interface, an SPI serial port, a
6-channel 10-bit ADC (8 channels on TQFP and QFN/MLF packages), a programmable watchdog timer
with internal oscillator, and five software-selectable power saving modes. The idle mode conserves
power by suspending the CPU, while allowing the SRAM, Timer/Counters, USART, 2-wire serial
interface, SPI port and interrupt system to remain active. The power-down mode maintains the
register contents, freezing all other chip functions until the next interrupt or hardware reset.
The Atmel ATmega328P is a powerful microcontroller that offers a cost-effective solution for many
embedded control applications. The device combines an 8-bit RISC CPU with an in-system self-
programmable flash on a monolithic chip. In standby mode, the crystal/resonator oscillator runs while
the rest of the device is sleeping, allowing for fast start-up with low power consumption.
The on-chip ISP flash allows the program memory to be reprogrammed in-system through an SPI
serial interface, with a conventional non-volatile memory programmer, or with an on-chip boot
program running on the AVR core. The boot program can use any interface to download the
application program into the application's flash memory, and the software in the boot flash section
will continue to run while the application flash section is being updated, providing true read-while-
write operation.. The ATmega328P AVR is supported by a variety of development tools, including C
compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits.
Software in the boot flash section will continue to run while the application flash section is updated,
providing true read-while-write operation. By combining an 8-bit RISC CPU with an in-system self-
programmable flash on a monolithic chip, the Atmel ATmega328P is a powerful microcontroller that
provides a highly flexible and cost-effective solution to many embedded control applications. The
ATmega328P AVR is supported with a full suite of program and system development tools including C
compilers, macro assemblers, program debugger/ simulators, in-circuit emulators, and evaluation
kits.
This register file contains 32 8-bit general purpose working registers with a single clock cycle access
time. This allows for single-cycle arithmetic logic unit (ALU) operations. It is possible to perform
arithmetic and logic operations between registers or between a constant and a register, as well as
single register operations within the ALU.
Six of the 32 registers can be used as three 16-bit indirect address register pointers for data space
addressing – enabling efficient address calculations. One of these address pointers can also be used as
an address pointer for look up tables in flash program memory. The ALU supports arithmetic and logic
operations between registers or between a constant and a register. Single register operations can also
be executed in the ALU. After an arithmetic operation, the status register is updated to reflect
information about the result of the operation. Program flow is provided by conditional and
unconditional jump and call instructions, able to directly address the whole address space.
2 LCD DISPLAY
The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other
which are compatible with HD44580. LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs
which have only 1 controller and support at most of 80 characters, whereas LCDs supporting more
than 80 characters make use of 2 HD44780 controllers.
Most LCDs with 1 controller have 14 Pins and LCDs with 2 controllers has 16 Pins (two pins are extra
in both for back-light LED connections). Pin description is shown in the figure 2.3.
The display gives out real time readings of the processed information from the microcontroller such as
the power consumed from the individual units, total power consumed and power being theft, used for
the monitoring of power from the hardware.
A transformer is commonly used to step the input AC voltage level down or up. Most electronic
circuits operate from voltages lower than the AC line voltage so the transformer normally steps the
voltage down by its turns ratio to a desired lower level.
For example, a transformer with a turns ratio of 10 to 1 would convert the 120 volt 60 Hz input
sine wave into a 12 volt sine wave.
Rectifier:
The rectifier converts the AC sine wave into a pulsating DC wave.
There are several forms of rectifiers used but all are made up of diodes.
Filter:
The rectifier produces a DC output but it is pulsating rather than a constant steady value over time
like that from a battery.
A filter is used to remove the pulsations and create a constant output.
The most common filter is a large capacitor
Regulator:
The regulator is a circuit that helps maintain a fixed or constant output voltage.
Changes in the load or the AC line voltage will cause the output voltage to vary.
Most electronic circuits cannot withstand the variations since they are designed to work properly
with a fixed voltage.
The regulator fixes the output voltage to the desired level and then maintains that value despite
any output or input variations.
A.C. Single Phase, 2 Wire Solid State (Static) Fully Electronic Energy Meter, Accuracy Class 1.0
&Current Rating 5-30 Amp. with Backlit LCD Display for 240 Volt System fitted with Pilfer Proof Meter
Box. This specification covers design, engineering, manufacture, testing, inspection & supply of A.C.
Single phase, two wire solid state (static) fully electronic energy meters of accuracy class 1.0 & current
rating 5-30 A, with backlit LCD display for 240 Volt systems as per requirement in this specification
and pilfer proof meter box (PPMB) made of engineering plastic, FR grade with self-extinguishing
property suitable for single phase meter.
The meter should be capable of recording & displaying energy in KWH & demand in KW for single
phase two wire A.C. loads respectively for power factor range of Zero lag – unity – Zero lead. Meters
should have facility/ capability of recording tamper information.
The meter shall conform in all respects to high standards of engineering, design and workmanship
shall be capable of performing commercial operation continuously in a manner acceptable to
WBSEDCL and shall have the right to reject any work or material which in its judgment is not in
accordance therewith. The offered meter must include all parts and accessories required for the
system to function effectively and without errors for the aforementioned purpose. Whether or not
these components are mentioned specifically in this specification and/or the commercial order, they
will be considered to fall under the scope of the bidders' supply. The original manufacturers of LT A.C.
static energy meters shall only quote against this tender. In case of foreign manufacturers their
authorized agent may also bid provided that they should be registered vendor and shall have all the
testing facilities in India. They should also produce the documents authorizing them as agents, in India
It is mandatory that in case of all manufacturers, the offered meter shall be ISI marked and bidder
shall have to furnish valid BIS certification along with the offer.
ACS712 is a current sensor that can operate on both AC and DC. This sensor operates at 5V and
produces an analog voltage output proportional to the measured current. This tool consists of a series
of precision Hall sensors with copper lines. The output of this instrument has a positive slope when
the current increases through the copper primary conduction path (from pins 1 and 2 to pins 3 and 4).
The internal resistance of the conduction path is 1.2 mΩ.
Figure 5.7. Circuit diagram of ACS712
This sensor has an output voltage of Vcc x 0.5 = 2.5 at the input current 0A and a 5V Vcc power supply.
There are three types based on the readable current range, ± 5A, ± 20A, and ± 30A with output
sensitivity of each type of 185mV / A, 100mV / A, and 66mV / A respectively.
The output of this current sensor is analog, so to read it, the output voltage using voltmeter can be
measured directly or it can be measured by using a microcontroller like Arduino through Analog Read
pin or ADC pin.
The power supply module is used to give ACS712 5V power supply (to 5V pin in ACS712). The ACS712
sensor's ground is also connected to the microcontroller’s ground. For measurement, connect the +
probe of the voltmeter to analog output pin in the ACS712.
6. VOLTAGE SENSOR
The power supply module along with the rectifier enables the voltage sensor to measure the DC
voltages ranging from 0 to 25 Volts. This works as a DC voltmeter with maximum 25V.
As it is known that Arduino and few other microcontroller can measure up to 5V directly from the
analog pins, but to measure the voltage beyond 5V is not possible and even by connecting more than
5V, the chip may get damaged or burnt. So, with the help of this Voltage sensor it can be measured up
to 25V from Arduino Analog pins.
This Voltage sensor is small and low cost module whose principle is based on Resistive voltage divider
circuit. With the help of it the voltage is divided by 5. Which makes the voltage 5 times smaller, 25/5=5
thus with this it can be measured up to 25V.
Arduino AVR chips have 10-bit ADC, so this module simulates a resolution of 0.00488V (5V/1024), so
the minimum voltage of input voltage detection module is 0.00488Vx5(for 25v)=0.02440V.
For 5V systems the input voltage should not be greater than 25V
For 3.3V system the input voltage should not be greater than 16.5v as 3.3X5=16.5.
From the above pinout diagram it is noticed that there are 5 pins to voltage sensor module. 3 pins are
male head connectors which are to be connected to Arduino and other 2 pins has a plastic screw pin
terminals where the voltage to be measured is connected.
VCC: Positive terminal for the external voltage source (0-25v)
GND: Negative terminal for the external voltage source (0-25v)
S: signal pin or Analog output pin
+: Not connected
-: Ground pin
7. WI-FI MODULE
The ESP8266 Wi-Fi Module is a self-contained SOC with an integrated TCP/IP protocol stack that can
give any microcontroller access to the Wi-Fi network. The ESP8266 is capable of either hosting an
application or offloading all Wi-Fi networking functions from another application processor.
Each ESP8266 module comes pre-programmed with an AT command set firmware, meaning, it can be
simply hooked up to the Arduino device and get about as much Wi-Fi-ability as a Wi-Fi Shield offers
(and that's just out of the box)! The ESP8266 module is an extremely cost-effective board with a huge,
and ever growing, community.
This module has a powerful enough on-board processing and storage capability that allows it to be
integrated with the sensors and other application specific devices through its GPIOs with minimal
development up-front and minimal loading during runtime.
Its high degree of on-chip integration allows for minimal external circuitry, including the front-end
module, is designed to occupy minimal PCB area. The ESP8266 supports APSD for VoIP applications
and Bluetooth coexistence interfaces, it contains a self-calibrated RF allowing it to work under all
operating conditions, and requires no external RF parts.
There is an almost limitless fountain of information available for the ESP8266, all of which has been
provided by amazing community support. Additional points to be considered in powering up the
microcontroller and boot loading it are:
The ESP8266 Module is not capable of 5-3V logic shifting and will require an external Logic Level
Converter. Please do not power it directly from the 5V dev board.
This new version of the ESP8266 Wi-Fi Module has increased the flash disk size from 512k to
1MB.
Features:
802.11 b/g/n
Wi-Fi Direct (P2P), soft-AP
Integrated TCP/IP protocol stack
Integrated TR switch, balun, LNA, power amplifier and matching network
Integrated PLLs, regulators, DCXO and power management units
+19.5dBm output power in 802.11b mode
Power down leakage current of <10uA
1MB Flash Memory
Integrated low power 32-bit CPU could be used as application processor
SDIO 1.1 / 2.0, SPI, UART
STBC, 1×1 MIMO, 2×1 MIMO
A-MPDU & A-MSDU aggregation & 0.4ms guard interval
Wake up and transmit packets in < 2ms
Standby power consumption of < 1.0mW (DTIM3)
SOFTWARE REQUIREMENT
1. PROTEUS
2. CCS COMPILER/ARDUINO
8. PROTEUS
Proteus is a software tool for simulating electronic circuits and embedded systems. It allows users to
design and test virtual prototypes of electronic circuits and devices, and can be used for a variety of
applications, including education, training, and prototyping. It is available in several versions,
including Proteus Design Suite, Proteus VSM (Virtual System Modeling), and Proteus Lite. The
software includes a library of components and devices, as well as a graphical user interface
for creating and simulating circuits. Proteus is widely used in industry and academia for a range of
applications, including the development of microcontroller-based systems, simulation of analog and
digital circuits, and the design and testing of printed circuit boards (PCBs). It can also be used to teach
basic electronics and embedded systems concepts to students
and beginners. Overall, Proteus is a valuable tool for designing, testing, and simulating electronic
circuits and systems, and is widely used in the fields of engineering and computer science.
Figure 5.12. Proteus simulated circuit diagram
Figure shows the interfacing of the microcontroller with various components, The ATMEGA328P
controller's second pin is interfaced with transmitter side of WI-FI module and the third pin is
interfaced to the receiver side of the W-IFI module. These connections helps to ensure the
transmission and reception of the controller. The 23rd and 24th pins are connected with the voltage
sensor for monitoring the potential difference across the AC lines. The 25th and 26th pins are
connected to current sensors for noting down the current from the respective nodes.
The pins of 23 and 24 connections are made with LCD interfacing component at serial clock and at
serial data ports. The ports of 4, 5, 6 in LCD interfacing component gets connected with the LCD
display ports of 4, 5, 6 respectively for register select, read/write enable functions. And the ports 10,
11, 12 of LCD interfacing component are connected to ports of 12, 13, 14 of LCD display which are
used to send the data for display.
9. CSS COMPILER/ARDUINO
Boot loading is the process of uploading a program to a microprocessor (a small computer that is
embedded in a device). The program, also known as a bootloader, is a special program that is used to
load other programs or applications into the microprocessor's memory. To bootload a
microprocessor, you will need a computer and a programming tool, such as a programmer or
debugger. The programmer or debugger is a device that connects to the microprocessor and allows
you to upload a program to it. The Arduino IDE is used here to bootload the Atmega328, this is done
by keeping up the target microcontroller placed in the breadboard and the intstructions are provided
from the actual Arduino UNO board that is being connected with the PC via an USB port of the system.
Once the required code along with the functionalities of the microcontroller are entered and debugged
in the IDE then these are compiled and kept ready to be burned onto the microcontroller.
running regularly scheduled MATLAB code or sending a tweet when the data passes a defined
threshold. Thing Speak is used for diverse applications ranging from weather data collection and
analysis, to synchronizing the colour of lights across the world. The heart of Thing Speak is a time-
series database. Thing Speak provides users with free time-series data storage in channels. Each
channel can include up to eight data fields.
3.3. Overview
The ThingSpeak is special and different as it uses simple HTTP Protocol to transfer, store and retrieve
information from different sensors. Also, the ThingSpeak Application allows us to log the sensor data,
track locations and even social networking of things. Another important thing (or rather a unique
feature) about ThingSpeak is its support from MATLAB. The close relationship between ThingSpeak
and MATLAB has lead to integrate several key features of MATLAB into the ThingSpeak Application.
One such feature is to analyse and visualize the user data i.e. the sensor data in a graphical way
without the MATLAB License. Thus, the ThingSpeak Application is a great tool for IoT-related projects.
3.4. Creating ThingSpeak Account
An account is the major stepping stone in the interfacing of the hardware with the ThingSpeak. Since
the collaboration with MATLAB, use the MathWorks credentials to log in to ThingSpeak. The steps in
creating the account are as follows:
After logging in, create a new channel for the data to be stored. For this go to Channels–>My
Channels and click on New Channel.
Set the baud rate to 115200 and also select “Both NL & CR” option in the Serial Monitor. After
receiving the response as “OK”, proceed with connecting the ESP Module to the WiFi Network using
the following command.
AT+CWJAP=”SSID”,”PASSWORD”
Replace SSID with the name of the WiFi Network and enter the password in place of PASSWORD. Now
the confirmation response will be received regarding the WiFi Connection as follows.
WIFI CONNECTED
WIFI GOT IP
OK
Figure 3.2. AT Commands of WIFI module testing
AT+CIPMUX=0
Next step is to connect to the ThingSpeak API using TCP Protocol. For this, use the following
command.
AT+CIPSTART=”TCP”,”api.thingspeak.com”,80
Alternatively, the IP Address of the host api.thingspeak.com can be used i.e. 184.106.15349.
AT+CIPSTART=”TCP”,”184.106.15349”,80
After starting the TCP connection, if action is not performed, the connection will be closed
automatically after some time, usually after 1 minute. Now, the “TCP” connection between the
ESP8266 and ThingSpeak has been successfully enabled. Next, any data can be sent through this TCP
Connection. For this, use the following commands one after the other.
AT+CIPSEND=51
GET /update?api_key=XXXXXXXXXXXXXXXX&field1=255
AT+CIPCLOSE
Once the TCP connection is established, send the data using certain commands. This part can be a little
tricky but trying it for a couple of times, the process is understandable. In order to send the data, send
three different information: One is the actual send command, next is the data along with the
ThingSpeak Field Key and finally the close connection command. Before sending the data, need to
acquire the API Key. For this, go to the channel (the one have been just created) and click on “API
Keys” Tab. Below that, it is found as Write API Key, which is an alphanumeric string of 16 characters.
Make a note of this key. Now, use the following command to initialize the data transmission.
AT+CIPSEND=51
The value 51 is the length of the data to be transmitted. This includes the complete data including the
API Key and the “\r” and “\n” values. For this command, the following response is got.
OK
Now type the following information and hit send. Here, “XXXXXXXXXXXXXXXX” is nothing but the 16
character Write API Key, which is just copied. And the number “143” is the actual data transmitted to
field1.
GET /update?api_key=XXXXXXXXXXXXXXXX&field1=143
After typing this text and hitting on send, there will be no response. It is actually waiting for the close
command. Once hitting the send for the above text, immediately type the following command and
AT+CIPCLOSE
The moment the send gets hit, the following response is displayed (not the exact one, but something
similar).
Recv 51 bytes
SEND OK
+IPD,1:5CLOSED
Here, the number 5 intimates it is the 5th message to that Key. Now, Open the Thing Speak API and
open the channel. In the “Private View” tab, the value ‘143’ in the Field 1 Chart is seen.
If all these steps are executed, then the ESP8266 to ThingSpeak API connection can be successfully
made. To send more data, repeat the steps from creating the TCP Connection.
Since the ESP8266 is controlled through Arduino, the circuit diagram will be slightly different. But the
components will be the same. Typing all the AT Commands manually is not easier, so here comes
Arduino to rescue the difficulty.Make all the connections as per the above circuit diagram and proceed
with the code.
RESULTS:-
A Electricity Theft Detection and monitoring system has been designed and developed with proper
integration of both the hardware and the software. Without any human interface, this system provides
an effective and easy way to detect electrical theft. The use of IoT helps in achieving the numerous
advantages of wireless network communications. Power theft is actually bypassing the energy meter,
but in this project, the theft is detected if some unauthorized consumption is done on the main AC
supply
Using IOT, the illegal usage of power can be solved electronically without any human intervention and
wirelessly. The WI-FI module regularly communicates with the cloud interfacing, sending readings of
the power consumption.
These readings gets continuously stored onto the remote database that is connected and the readings
from the remote database collections are as shown below
2. Blockchain Integration:
Integrating blockchain technology for secure and transparent transactions can help create a tamper-proof
system, ensuring the integrity of electricity consumption data.
4. Predictive Analytics:
Incorporating predictive analytics can help anticipate potential electricity theft based on historical
patterns, enabling proactive measures to prevent unauthorized consumption.
7. Cybersecurity Measures:
Enhancing cybersecurity measures to protect IoT devices from potential cyber threats ensures the
integrity and security of the electricity consumption data, preventing unauthorized access.
9. User-Friendly Interfaces:
Developing user-friendly interfaces, such as mobile apps and web portals, can empower consumers to
monitor and manage their electricity consumption, fostering awareness and reducing the likelihood of theft.
These future scopes highlight the potential for continuous improvement and innovation in IoT-based
electricity theft detection systems, contributing to more efficient and secure energy management.
REFERENCES:-
[1] A. K. Gupta, A. Mukherjee, A. Routray and R. Biswas, “A novel power theft detection algorithmfor
low voltage distribution network,” IECON2017 - 43rd Annual Conference of the IEEE Industrial
Electronics Society, Beijing, 2017, pp. 3603-3608.
[2] M. Golden, B. Min, “Theft and loss of electricityin an Indian Statetechnical report,” Int. Growth
Centre 2012.
[3] Navani JP, Sharma NK and Sapra S. “Technical and non-technical losses in power system and its
economic consequence in Indian economy,” Int JElectron Comp Sci Eng, Vol 1, pp. 757–61, 2012.
[4] W. Han and Y. Xiao, “NFD: A practical scheme to detect non-technical loss fraud in smart grid,”
2014 IEEE International Conference on Communications (ICC), Sydney, NSW, 2014, pp.605-609.
[5] ECI Telecom Ltd., Fighting Electricity Theft with Advanced Metering Infrastructure (March 2011)
[Online] Available: http://www.ecitele.com
[6] J. Nagi, K. S. Yap, S. K. Tiong, S. K. Ahmed and M. Mohamad, “Nontechnical Loss Detection for
Metered Customers in Power Utility UsingSupport Vector Machines,” in IEEE Transactions on Power
Delivery, vol. 25, no. 2, pp. 1162-1171,April 2010.
[7] S.S.S.R. Depuru, “Modeling, Detection, and Prevention of Electricity Theft for Enhanced
Performance and Security of Power Grid,” The University of Toledo, Aug. 2012.
[8] J. Nagi, K.S. Yap, S.K. Tiong, S.K. Ahmed, and A.M. Mohammad, “Detection of abnormalities and
electricity theft using genetic support vector machines,” Proc. IEEE Region 10 Conference TENCON,
Hyderabad, India, Jan. 2009, pp. 1–6.
[9] S. Sahoo, D. Nikovski, T. Muso, and K. Tsuru, “Electricity theft detection using smart meter data,” in
Innovative Smart Grid Technologies Conference (ISGT), IEEE Power and Energy Society, 2015.
[10] S. A. Salinas and P. Li, “Privacy-Preserving Energy Theft Detection in Microgrids: A State
Estimation Approach,” IEEE Trans. Power Syst.,vol. 31, no. 2, pp. 883 - 894, 2016.
[11] Yip, Sook-Chin, KokSheik Wong, Wooi-Ping Hew, Ming-Tao Gan, Raphael C-W. Phan, and Su-Wei
Tan.
“Detection of energy theft and defective smart meters in smart grids using linear regression,”
International Journal of Electrical Power & Energy Systems 2017, vol 91, pp. 230- 240.
[12] Yip, Sook-Chin, Chia-Kwang Tan, Wooi-Nee Tan, Ming-Tao Gan, and Ab-Halim Abu Bakar, “Energy
theft and defective meters detection in AMI using linear regression,” in 2017 IEEE International
Conference on Environment and Electrical Engineering and 2017 IEEE Industrial and Commercial
Power Systems Europe (EEEIC/I&CPS Europe), 2017, pp. 1-6.
[13] M. U. Hashmi and J. G. Priolkar, “Anti-theftenergy metering for smart electrical distribution
system,” in 2015 International Conference on Industrial Instrumentation and Control (ICIC),Pune,
2015, pp. 1424- 1428.
[14] Y. Tawaragi, “Power theft inspection apparatus and method, and recording medium,” U.S. Patent
14/593,160, 2015.
[15] M. Singh and E. V. Sanduja, “Minimizing Electricity Theft by Internet of-Things,” International
Journal of Advanced Research in Computer and Communication Engineering, Vol. 4(8), pp.326-329,
2015.
[16] L. K. Lekha, G. Jegan and M. D. Ranganathan, “IoT Based Household Appliances Control and
Tampering Detection Of Electricity Energy Meter,” ARPN Journal of Engineering and Applied Sciences,
Vol. 11(11), pp. 7376-7379, 2016.