0% found this document useful (0 votes)
447 views55 pages

Smart Electricity Billing

The document discusses the problems with traditional electricity billing systems and proposes a smart electricity billing system using IoT. The system uses a smart energy meter connected to a microcontroller that sends meter readings to the cloud wirelessly. This allows accurate billing without human meter readers and alerts consumers when reaching usage thresholds.

Uploaded by

Abhishek Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
447 views55 pages

Smart Electricity Billing

The document discusses the problems with traditional electricity billing systems and proposes a smart electricity billing system using IoT. The system uses a smart energy meter connected to a microcontroller that sends meter readings to the cloud wirelessly. This allows accurate billing without human meter readers and alerts consumers when reaching usage thresholds.

Uploaded by

Abhishek Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

GOVERNMENT POLYTECHNIC ASTHAWAN

Nalanda, Bihar - 803107

Session : 2020-23

A REPORT ON

“Smart Electricity Billing”

Submitted By:-
SWATI KUMARI ( 1281520002 )

Under the supervision of


Prof. Paritosh Kumar
And
Prof. Saurabh Kumar

Department of
“Civil Engineering”
Government Polytechnic Asthawan, Nalanda
Approved by AICTE New Delhi, Affiliated to S.B.T.E. Bihar (Patna)

1|Page
CERTIFICATE
Certified that the project work entitled “Smart Electricity Billing” carried out by
Swati Kumari and his team ( Student Of Government Polytechnic Asthawan )
describes the work carried out by him in Project, under my overall supervision.

Prof. Saurabh Kumar Prof. Paritosh Kumar Dr. Anand Krishna Principal
Dept. of Civil Engg. , Dept. Of Civil Engg. Govt. Poly. Asthawan,Nalanda
Govt. Poly. Asthawan, Nalanda Govt. Poly. Asthawan, Nalanda

2|Page
ABSTRACT
There are many problems in metering and billing processes like the going of
meter reader to each customer meter to manually take the meter reading, the
probability of the non-existence of the customers at their homes during that
time, the lack of integrity and credibility of some of the meter readers, the
safety and the outback areas represent a huge drawback cannot be neglected.

In other hand, the in service classical energy meter type (induction type)
suffers from well-known measuring errors. The above problems result in two
significant points, waste of much money due to the large number of employees
(meter readers) and the weakness in electricity management which results in
lack in electric power.

This project provides an excellent solution to the problems mentioned above


where the system has been designed based on the use of energy smart meter to
read electrical energy consumed to get an accurate reading. Then the energy
reading is sent to the control centre in the electricity department based on
GSM/SMS technology.

The system in the electricity department receives readings and makes


processing operations on them and extracts the bills that must be paid by the
customer.

The system also sends a message to the own customer mobile phone which
contains the current bill, due bill, and total bill every two months have to be
paid. In addition the system has the ability to print out a hard copy of the
customer bill.

Finally the proposed system has the ability of automatic power outage if the
customer refrains or delays for certain time in paying the bills by means of an
SMS.
Keywords: Energy Meter, Node-MCU, Current Sensor, Voltage Regulator

3|Page
ACKNOWLEDGMENT

We express our thanks to the support given by the management in


completing our project. We express our sincere gratitude & deep
sense of respect to Paritosh Sir, department of Civil Engineering. We
express our sincere thanks to our project guide Prof. Paras Nath Sir
Assistant Professor for his support to completion of this project. We
thankful to the teaching and non- teaching staff of Civil department
for their direct as well as indirect help in our project.

4|Page
TABLE OF CONTENTS
TOPIC PAGE NO.

I. COVER PAGE 01

II. CERTIFICATE 02
III. ABSTRACT 03
IV. AKNOWLEDGEMENT 04

V. TABLE OF CONTENTS 05

VI. LIST OF FIGURES 06

VII. INTRODUCTION 07-11

VIII. METHODS AND MATERIAL 12-14


ENERGY METER 12
NODE MCU(ESP8366) 13
CURRENT METER 14
VOLTAGE REGULATOR 14

IX. STEPS TO CREATE SMART ELECTRICITY BILLING SYSTEM 15-48


CIRCUIT SETUP 15
CALIBRATION 16-18
WIFI CONNECTIVITY 19-21
DATA COLLECTION 21-24
BILLING CALCULATION 24-27
REMOTE CONTROL 28-31
DISPLAY AND INTERFACE 32-35
ENERGY MONITORING AND ALERT 35-39
SECURE COMMUNICATION 39-42
TESTING AND OPTIMIZATION 43-45
USER INTERACTION 46-48

X. WORKING PRINCIPLE 49-51


XI. RESULT AND DISCUSSION 52-53

XII. REFRENCES 54-55

5|Page
LISTS OF FIGURES

FIGURES PAGE NO.


Fig.1: Energy Meter 11

Fig.2:Node MCU(ESP8266) 13

Fig.3:Voltage Regulator 51

Fig.4:Block Diagram of IOT 51


based Smart Energy Meter

Fig.5: Proposed Model 51

6|Page
INTRODUCTION

➢ The world is changing towards automatic wireless technologies,


which prefer not only reducing human efforts but is helping in
making systems automatic and efficient.

➢ A system is said to be intelligent when it can decide what to do


without any instruction and can work automatically.

➢ An Electric or Energy meter measures the total electrical energy


in units used by the appliances which consume electrical energy
from the main power supply.

➢ Electromechanical and Electronic meter are two types of meter


Available in the market to measure the unit
consumption.

➢ Electromechanical meters are commonly used in village areas,


where the uses of modern technology are not as high as it
is in cities. Electromechanical meters have become out of date
nowadays.

➢ Electronic meters replace electromechanical meters. This meter


consists of LCD/LED to display the reading.

➢ Calibration Led is used on the meter which shows the units


consumed.

7|Page
➢ Manpower is required to read the meter and note down the
reading. The reading on the meter is increasing which is used to
generate the electricity bill.

➢ An IOT Based Smart Electricity Meter and billing System does


the same task without human efforts.

➢ IOT Based SEM system is controlled using Arduino Mega, which


is a microcontroller board.

➢ The purpose behind choosing this board is its efficiency and


memory. It is more efficient in terms of memory and GPIO.

➢ The data obtained is then sent to the cloud through the internet.
Data obtained can be easily sent wirelessly over long distance
without any noise disturbance using the internet.

➢ As the data is directly sent to the cloud there is no occurrence of


range and distance problem and is highly accurate and efficient
because of no human interference.

➢ Other wireless technologies such as Zigbee, Bluetooth etc. have


limited range thus cannot be used over very long distances .

8|Page
➢ This project envisages the use internet and the concept of IOT by
which the base station, as well as users, remain updated with the
current consumed units, changing the present problems faced by
the electricity board and the user.

➢ In the present billing system the distribution companies are


unable to keep track of the changing maximum demand of
consumers.

➢ The consumer is facing problems like receiving due bills for bills
that have already been paid as well as poor reliability of
electricity supply and quality even if bills are paid regularly.

➢ The remedy for all these problems is to keep track of the


consumers load on timely basis, which will held to assure
accurate billing, track maximum demand and to detect threshold
value.

➢ These are all the features to be taken into account for designing
an efficient energy billing system.

➢ The present project “IoT Based Smart Energy Meter” addresses


the problems faced by both the consumers and the distribution
companies.

9|Page
➢ The paper mainly deals with smart energy meter, which utilizes
the features of embedded systems i.e. combination of hardware
and software in order to implement desired functionality.

➢ The paper discusses comparison of Arduino and other


controllers, and the application of GSM and Wi-Fi modems to
introduce ‘Smart’ concept.

➢ With the use of GSM modem the consumer as well as service


provider will get the used energy reading with the respective
amount, Consumers will even get notification in the form text
through GSM when they are about to reach their threshold
value, that they have set.

➢ Also with the help of Wi-Fi modem the consumer can monitor
his consumed reading and can set the threshold value through
webpage.

➢ This system enables the electricity department to read the meter


readings monthly without a person visiting each house.

➢ This can be achieved by the use of Arduino unit that


continuously monitor and records the energy meter reading in
its permanent (non- volatile) memory location.

➢ This system continuously records the reading and the live meter
reading can be displayed on webpage to the consumer on
request.

10 | P a g e
➢ This system also can be used to disconnect the power supply of
the house when needed.

Fig.1Energy Meter

11 | P a g e
METHODS AND MATERIAL

ENERGY METER:

➢ Energy Meter or Watt-Hour Meter is an electrical instrument


that measures the amount of electrical energy used by the
consumers.

➢ Utilities are one of the electrical departments, which install these


instruments at every place like homes, industries, organizations,
commercial buildings to charge for the electricity consumption
by loads such as lights, fans, refrigerator, and other home
appliances.

➢ The basic unit of power is watts and it is measured by using a


watt meter.

➢ One thousand watts make one kilowatt. If one uses one kilowatt
in one-hour duration, one unit of energy gets consumed.

➢ So energy meters measure the rapid voltage and currents,


calculate their product and give instantaneous power.

12 | P a g e
NODE-MCU (ESP8266):

➢ Node MCU is an open source IOT platform.

➢ It includes firmware which runs on the ESP8266 Wi-Fi SOC


from Express if Systems, and hardware which is based on the
ESP-12 module.

➢ The term "Node MCU" by default refers to the firmware rather


than the development kits. The firmware uses the LUA scripting
language.

➢ It is based on the LUA project, and built on the Express if Non-


OS SDK for ESP8266. It uses many open source projects, such as
LUA-CJISON and SPIFFS.

Fig.2 NODE-MCU (ESP8266)

13 | P a g e
CURRENT SENSOR:

➢ A current sensor is a device that detects electric current in a wire,


and generates a signal proportional to that current.

➢ The generated signal could be analog voltage or current or even


a digital output.

➢ The generated signal can be then used to display the measured


current in an ammeter, or can be stored for further analysis in a
data acquisition system, or can be used for the purpose of control.

VOLTAGE REGULATOR:

➢ Voltage sources in a circuit may have fluctuations resulting in not


providing fixed voltage outputs.

➢ A voltage regulator IC maintains the output voltage at a constant


value.

➢ 7805 IC, a member of 78xx series of fixed linear voltage


regulators used to maintain such fluctuations, is a popular voltage
regulator integrated circuit (IC).

➢ The xx in 78xxindicates the output voltage it provides. 7805 IC


provides +5 volts regulated power supply with provisions to add
14 | P a g e
STEPS TO CREATE SMART ELECTRICITY
BILLING SYSTEM

1. CIRCUIT SETUP:

Certainly, here's a basic circuit setup for your smart electricity billing system
using NodeMCU. Please note that the exact connections might vary based on
the specific sensors and components you're using.

Components Needed:
- NodeMCU development board
- ACS712 Current Sensor
- Voltage Sensor (AC or DC, based on your application)
- Breadboard and jumper wires

Circuit Connections:

1. Connect the ACS712 Current Sensor:


- Connect the VCC pin of the ACS712 to the 5V pin on the NodeMCU.
- Connect the GND pin of the ACS712 to the GND pin on the NodeMCU.
- Connect the OUT pin of the ACS712 to an analog input pin on the
NodeMCU (e.g., A0).

2. Connect the Voltage Sensor:


- Connect the VCC pin of the Voltage Sensor to the 3.3V or 5V pin on the
NodeMCU (based on the sensor's requirements).
- Connect the GND pin of the Voltage Sensor to the GND pin on the
NodeMCU.
15 | P a g e
- Connect the output pin of the Voltage Sensor to an analog input pin on
the NodeMCU (e.g., A1).

3. Power Supply for NodeMCU:


- Connect the Vin pin on the NodeMCU to a suitable power source (e.g.,
USB or external 5V power supply).
- Connect the GND pin on the NodeMCU to the common ground of the
circuit.

Note: Always double-check the voltage levels of your components and


ensure compatibility. Additionally, consider using level shifters if your
components operate at different voltage levels to prevent damage to the
NodeMCU.

Once you have the circuit set up, you can proceed with programming the
NodeMCU to read data from the current and voltage sensors, calculate power
consumption, and send this data to a remote server or display it on an
interface.

2. CALIBRATIONS:

Calibrating the current and voltage sensors is crucial to ensure accurate


measurements of power consumption. Each sensor may have its own
sensitivity and offset, and these values need to be accounted for in your
calculations. Here's a general procedure for calibrating the ACS712 current
sensor and a voltage sensor:

16 | P a g e
Calibrating the ACS712 Current Sensor:

1. Zero Current Calibration:


- Disconnect any load from the current sensor.
- Measure and record the analog output value (ADC reading) of the current
sensor.
- This value corresponds to the sensor's offset or zero-current reading.

2. Full Scale Calibration:


- Connect a known load (e.g., a light bulb with a known power rating) to
the current sensor.
- Measure and record the analog output value.
- Calculate the difference between this value and the zero-current reading.
- This difference represents the sensor's full-scale output for the load.

3. Calculate Sensitivity:
- The sensitivity of the sensor is the change in analog output per unit
change in current. Calculate it using the following formula:
Sensitivity = Full Scale Output / Maximum Current Rating of Sensor

Calibrating the Voltage Sensor:

1. Zero Voltage Calibration:


- Ensure that there is no voltage applied to the voltage sensor.
- Measure and record the analog output value (ADC reading) of the voltage
sensor.
- This value corresponds to the sensor's offset or zero-voltage reading.

17 | P a g e
2. Full Scale Calibration:
- Apply a known voltage (e.g., using a stable power source) to the voltage
sensor.
- Measure and record the analog output value.
- Calculate the difference between this value and the zero-voltage reading.
- This difference represents the sensor's full-scale output for the applied
voltage.

3. Calculate Sensitivity:
- The sensitivity of the sensor is the change in analog output per unit
change in voltage. Calculate it using the following formula:
Sensitivity = Full Scale Output / Maximum Voltage Rating of Sensor

Using Calibrated Values in Code:

Once you have the sensitivity and offset values for both the current and
voltage sensors, you can use these values in your code to convert the ADC
readings to actual current and voltage values. Then, you can calculate power
consumption and energy usage accurately.

For the ACS712 current sensor, the formula to calculate current is:
Current (Amps) = (ADC Reading - Zero Current Reading) * Sensitivity

For the voltage sensor, the formula to calculate voltage is:


Voltage (Volts) = (ADC Reading - Zero Voltage Reading) * Sensitivity

Remember to test your system with different loads and voltage levels to
ensure that the calibration values are accurate and consistent across different
scenario.

18 | P a g e
3. WIFI CONNECTIVITY:

Setting up WiFi connectivity for your NodeMCU is essential to enable


communication between your device and other systems, such as remote
servers or user interfaces. Here's a general guide to help you establish WiFi
connectivity on your NodeMCU:

1. Include Required Libraries:


Start by including the necessary libraries in your Arduino IDE sketch to
work with the WiFi module of the NodeMCU. These libraries provide
functions for connecting to WiFi networks and managing network
communication.

```cpp
#include <ESP8266WiFi.h>
```

2. Set WiFi Credentials:


You'll need to provide your WiFi network credentials (SSID and password)
to connect to your local network. Replace `"YourSSID"` and
`"YourPassword"` with your actual WiFi network details.

```cpp
const char* ssid = "YourSSID";
const char* password = "YourPassword";
```

3. Connect to WiFi:
In the `setup()` function of your Arduino sketch, use the following code to

19 | P a g e
connect to the WiFi network using the provided credentials.

```cpp
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);

Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nConnected to WiFi");
}
```

The above code continuously prints dots while the NodeMCU is attempting
to connect to the WiFi network. Once the connection is established, it prints
"Connected to WiFi."

4. Display IP Address:
After connecting to WiFi, you can print the assigned IP address to the
serial monitor. This IP address will be used to communicate with the
NodeMCU over the network.

```cpp
void setup() {
// ... Previous code ...

20 | P a g e
Serial.print("Connected to WiFi\nIP address: ");
Serial.println(WiFi.localIP());
}
```

5. Complete Sketch:
Your `setup()` function is now configured to establish a WiFi connection.
You can continue adding other functionalities to your sketch in the `loop()`
function. This might include reading sensor data, calculating energy usage,
and sending data to a remote server.

6. Upload and Monitor:


Upload your sketch to the NodeMCU using the Arduino IDE. Open the
Serial Monitor to see the output, including the progress of WiFi connection
and the assigned IP address.

4. DATA COLLECTION:

Data collection involves reading data from your sensors (current sensor and
voltage sensor) and processing it to calculate power consumption, energy
usage, and other relevant information. Here's a general outline of how you
can approach data collection using the NodeMCU:

1. Read Sensor Data:

21 | P a g e
In your `loop()` function, you can read the analog values from your
sensors using the `analogRead()` function. Convert these analog readings to
actual current and voltage values using the calibration values you determined
earlier.

```cpp
// Read analog values from sensors
int currentSensorValue = analogRead(A0); // Analog pin for current sensor
int voltageSensorValue = analogRead(A1); // Analog pin for voltage sensor

// Convert analog readings to actual values using calibration


float currentAmps = (currentSensorValue - zeroCurrentReading) *
currentSensitivity;
float voltageVolts = (voltageSensorValue - zeroVoltageReading) *
voltageSensitivity;
```

2. Calculate Power Consumption and Energy Usage:


With the current and voltage values, you can calculate power consumption
(in watts) using the formula: `Power (W) = Current (A) * Voltage (V)`. You
can also calculate energy usage (in watt-hours) over a period of time (e.g., per
second or per minute).

```cpp
float powerWatts = currentAmps * voltageVolts;
float energyWh = powerWatts * timeInSeconds / 3600; // Energy in watt-
hours
```

22 | P a g e
3. Data Storage or Transmission:
Depending on your project's requirements, you can decide whether to store
the calculated data locally (e.g., display on an OLED screen) or transmit it to
a remote server for further analysis or billing.

- **Local Display (Example):**


If you have an OLED display connected, you can use a display library to
show the calculated values on the screen.

```cpp
display.clear();
display.drawString(0, 0, "Power: " + String(powerWatts) + " W");
display.drawString(0, 20, "Energy: " + String(energyWh) + " Wh");
display.display();
```

- **Remote Transmission (Example):**


To send data to a remote server, you would need to use protocols like
HTTP or MQTT. Here's a basic example using HTTP to send data to a server:

```cpp
#include <ESP8266HTTPClient.h>

void sendDataToServer(float power, float energy) {


HTTPClient http;
String url = "http://your-server.com/update?power=" + String(power) +
"&energy=" + String(energy);
http.begin(url);
int httpResponseCode = http.GET();

23 | P a g e
http.end();
}
```

4. Delay and Loop:


To control the frequency of data collection, you can introduce a delay in
your `loop()` function using the `delay()` function.

```cpp
void loop() {
// Read sensor data, calculate, and store/transmit
// ...

// Introduce a delay before the next iteration


delay(5000); // Delay for 5 seconds (adjust as needed)
}
```

5. BILLING CALCULATIONS:

Billing calculation involves converting the energy consumption measured by


your system into a monetary amount based on your local electricity rates.
Here's how you can perform billing calculation using the energy usage data
collected by your smart electricity billing system:

1. Retrieve Energy Usage Data:


Use the energy usage data (in watt-hours) that you calculated from the

24 | P a g e
sensor readings over a specific period of time.

2. Understand Electricity Rates:


Obtain information about your local electricity rates, which are usually
provided in terms of cost per kilowatt-hour (kWh). Electricity rates can vary
based on factors such as time of day, usage tiers, and seasons.

3. Calculate Billing Amount:


- Convert the energy usage from watt-hours (Wh) to kilowatt-hours (kWh)
by dividing by 1000 (since 1 kWh = 1000 Wh).
- Multiply the energy usage in kWh by the cost per kWh to calculate the
billing amount.

```cpp
float energyKWh = energyWh / 1000; // Convert to kilowatt-hours
float costPerKWh = 0.15; // Example electricity rate ($0.15 per kWh)
float billingAmount = energyKWh * costPerKWh;
```

Adjust the `costPerKWh` value to match the actual electricity rates in


your area.

4. Display or Transmit Billing Information:


Depending on your setup, you can display the billing information locally
(e.g., on an OLED display) or transmit it to a remote server for further
processing.

- **Local Display (Example):**


Display the calculated billing amount on your OLED screen.

25 | P a g e
```cpp
display.drawString(0, 40, "Billing: $" + String(billingAmount, 2)); //
Display with 2 decimal places
display.display();
```

- Remote Transmission (Example):


If sending data to a remote server, you can include the billing amount in
the URL parameters or as part of an HTTP POST request.

```cpp
#include <ESP8266HTTPClient.h>

void sendBillingToServer(float billingAmount) {


HTTPClient http;
String url = "http://your-server.com/update?billing=" +
String(billingAmount, 2); // Display with 2 decimal places
http.begin(url);
int httpResponseCode = http.GET();
http.end();
}
```

5. Reset Energy Usage Counter:


Depending on your billing cycle, you might want to reset the energy usage
counter after generating the billing amount.

```cpp

26 | P a g e
// Reset energyWh to start measuring for the next billing cycle
energyWh = 0;
```

6. Implement User Interaction :


If you have a user interface, consider providing users with the ability to
view their real-time usage, historical data, and billing information.

27 | P a g e
6. REMOTE CONTROL:

Implementing remote control functionality allows you to remotely manage


appliances or devices connected to your smart electricity billing system.
Here's how you can add remote control capabilities using NodeMCU:

1. Identify Controlled Devices:


Determine which devices or appliances you want to control remotely.
These could be lights, fans, heaters, or any other electrical devices.

2. Connect Relays:
If you haven't already, connect relay modules to the NodeMCU. Relays
allow you to switch high-voltage devices using low-voltage signals from the
NodeMCU.

3. Include Relay Library:


You might need to include a library in your Arduino sketch to control the
relays. The library name might depend on the relay module you're using. For
example, if you're using the "Arduino Relay Module" library, include it like
this:

```cpp
#include <Arduino_Relay_Module.h>
```

4. Control Relays:
In your code, you can control the relays using the relay library functions.
You'll typically need to set up the relay pins as output and use functions to
turn the relays on or off.

28 | P a g e
```cpp
const int relayPin1 = D1; // Replace with the actual pin connected to the
relay
const int relayPin2 = D2; // Replace with the actual pin connected to the
relay

void setup() {
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
}

void turnRelayOn(int pin) {


digitalWrite(pin, HIGH);
}

void turnRelayOff(int pin) {


digitalWrite(pin, LOW);
}
```

5. Remote Control Mechanism:


There are several ways you can implement remote control:

- **Web Interface:** Create a web interface that allows you to toggle the
relays on and off remotely. You can use HTTP requests to trigger relay
actions.

- **Mobile App:** Develop a mobile app that communicates with your

29 | P a g e
NodeMCU over WiFi. The app can send commands to turn the relays on or
off.

- **Voice Control:** Integrate voice assistants like Amazon Alexa or Google


Assistant to control the relays using voice commands.

6. Implement Remote Control Logic:


Depending on your chosen remote control mechanism, implement the
logic to listen for commands and control the relays accordingly.

For example, if you're using a web interface, you might set up an HTTP
server on the NodeMCU to handle incoming requests and trigger relay
actions.

```cpp
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

void setup() {
// ... Previous setup code ...

server.on("/relay1on", []() {
turnRelayOn(relayPin1);
server.send(200, "text/plain", "Relay 1 turned on");
});

30 | P a g e
server.on("/relay1off", []() {
turnRelayOff(relayPin1);
server.send(200, "text/plain", "Relay 1 turned off");
});

// Set up similar routes for other relays

server.begin();
}

void loop() {
server.handleClient();
}
```

7. Security Considerations:
When implementing remote control, it's crucial to consider security. Use
authentication mechanisms to prevent unauthorized access to your system.
For example, you can use HTTPS for secure communication, implement
username and password-based authentication, or use token-based
authentication.

8. Testing and User Interface:


Test your remote control functionality thoroughly and ensure that the
relays respond correctly to commands. If you're implementing a web
interface or a mobile app, design a user-friendly interface that allows users to
easily control the connected devices.

31 | P a g e
7. DISPLAY AND INTERFACE:

Implementing a display and interface can provide a user-friendly way to


monitor energy consumption, view billing information, and control devices
in your smart electricity billing system. Here's how you can create a display
and interface using NodeMCU:

1. Choose Display Type:


Decide whether you want to use an OLED display, a web-based interface,
or a combination of both.

2. OLED Display Setup:


If you're using an OLED display, you'll need to include the appropriate
libraries and set up the display in your code.

```cpp
#include <SSD1306Wire.h>

SSD1306Wire display(0x3c, D2, D1); // OLED display I2C address and pins
```

3. Display Data:
Display relevant data such as real-time power consumption, energy usage,
and billing information on the OLED screen.

```cpp
void displayData(float powerWatts, float energyWh, float billingAmount) {
display.clear();
display.drawString(0, 0, "Power: " + String(powerWatts) + " W");

32 | P a g e
display.drawString(0, 20, "Energy: " + String(energyWh) + " Wh");
display.drawString(0, 40, "Billing: $" + String(billingAmount, 2));
display.display();
}
```

4. Web Interface Setup:


For a web-based interface, you can create an embedded web server on the
NodeMCU to serve HTML and handle HTTP requests.

```cpp
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);
```

5. Web Page HTML:


Create an HTML page that users can access to view data and control
devices. You can include buttons to toggle relays, display energy usage, and
billing information.

```html
<!DOCTYPE html>
<html>
<head>

33 | P a g e
<title>Smart Energy Monitor</title>
</head>
<body>
<h1>Energy Consumption Monitor</h1>
<p>Power: <span id="power">0</span> W</p>
<p>Energy: <span id="energy">0</span> Wh</p>
<p>Billing: $<span id="billing">0.00</span></p>
<button id="toggleRelay">Toggle Relay</button>

<script>
// JavaScript code to update data and control devices
</script>
</body>
</html>
```

6. JavaScript and AJAX:


Use JavaScript and AJAX (Asynchronous JavaScript and XML) to update
data on the web page without refreshing the entire page. You can also send
HTTP requests to control relays.

```javascript
document.addEventListener('DOMContentLoaded', function() {
setInterval(updateData, 5000); // Update data every 5 seconds

document.getElementById('toggleRelay').addEventListener('click',
function() {
// Send an HTTP request to toggle the relay
var xhr = new XMLHttpRequest();

34 | P a g e
xhr.open('GET', '/toggleRelay', true);
xhr.send();
});
});

function updateData() {
// Update data using AJAX and update HTML elements
// Fetch data from server and update power, energy, and billing elements
}
```

7. Web Server Routes:


Set up routes on the web server to handle requests from the web interface.

```cpp
void setup() {
// ... Other setup code ...

server.on("/", HTTP_GET, []() {


server.send(200, "text/html", webPageHTML);
});

server.on("/toggleRelay", HTTP_GET, []() {


// Toggle the relay
// Send appropriate response back to the client
});

// ... Other routes ...

35 | P a g e
server.begin();
}
```

8. Testing and Styling:


Test your interface by accessing the NodeMCU's IP address from a web
browser. You can also apply CSS styling to make the web page visually
appealing.

9. Responsive Design :
If you want your web interface to be accessible on different devices,
consider implementing responsive design techniques to ensure a good user
experience on both desktop and mobile devices.

Remember that creating a user interface involves both hardware and


software components. You'll need to design the layout, handle user
interactions, and ensure that the interface remains responsive and user-
friendly.

8. ENERGY MONITORING AND ALERTS:

Energy monitoring and alerts enhance the functionality of your smart


electricity billing system by providing insights into usage patterns and
notifying you about anomalies. Here's how you can implement energy
monitoring and alerts using NodeMCU:

1. Collect and Analyze Historical Data:


Store historical energy usage data over time to analyze trends, patterns, and
peak usage periods. You can use this information to make informed decisions

36 | P a g e
about energy conservation.

2. Implement Threshold Alerts:


Set up threshold values for energy consumption that, when exceeded,
trigger alerts. These alerts can be sent via email, SMS, or push notifications.

3. Include Libraries for Notifications:


Depending on the notification method you choose, include relevant
libraries in your code. For example, if you want to send emails, you can use
the `ESP8266EmailClient` library.

4. Define Alert Thresholds:


Decide on appropriate thresholds for energy consumption that warrant
alerts. For instance, you might set a threshold for high energy consumption
during non-peak hours.

5. Check Thresholds and Send Alerts:


Regularly check the current energy consumption against the defined
thresholds. If a threshold is crossed, send an alert using the chosen
notification method.

```cpp
void checkAndSendAlert(float currentEnergyUsage, float threshold) {
if (currentEnergyUsage > threshold) {
// Send alert using the chosen method (email, SMS, push notification)
sendAlert("High energy consumption detected!");
}

37 | P a g e
6. Implement Email Notifications:
To send email alerts, use the `ESP8266EmailClient` library or a similar
library. Configure your email server settings and provide recipient email
addresses.

```cpp
#include <ESP8266EmailClient.h>

void sendAlert(const char* message) {


EmailClient.send("[email protected]", "[email protected]",
"Alert", message);
}
```

7. Implement SMS Notifications :


If you want to send SMS alerts, you can use third-party APIs like Twilio or
Nexmo to integrate SMS functionality into your system.

8. Implement Push Notifications (Optional):


Push notifications can be sent using platforms like Firebase Cloud
Messaging (FCM) or Pushbullet. Implement the necessary API calls to send
push notifications to your mobile devices.

9. Configure Alert Frequency:


To prevent excessive alerts, implement a delay or cooldown period
between sending alerts for the same issue. This ensures that users are not
overwhelmed with repeated alerts.

38 | P a g e
10. Web Interface Integration:
If you have a web interface, provide users with the ability to configure
alert thresholds and notification settings.

11. Debugging and Testing:


Thoroughly test your alert system to ensure that alerts are triggered
accurately when energy consumption exceeds defined thresholds.

12. Review and Fine-Tuning:


Monitor the alerts over time and adjust the threshold values as needed.
Fine-tune the system based on feedback and observations of energy
consumption patterns.

Energy monitoring and alerts are crucial for identifying inefficiencies,


promoting energy conservation, and preventing unexpected spikes in energy
usage. Properly configuring and testing the alert system will help you
effectively manage your energy consumption.

9. SECURE COMMUNICATION:

Securing communication in your smart electricity billing system is essential


to protect sensitive data, user privacy, and the integrity of your system.
Here's how you can implement secure communication using NodeMCU:

1. Use HTTPS (HTTP Secure):


Whenever possible, use HTTPS for communication between your
NodeMCU and any remote servers. HTTPS encrypts data to prevent

39 | P a g e
eavesdropping and tampering. Many web servers offer HTTPS support, and
you can use libraries like `ESP8266WiFiSecure` and
`ESP8266HTTPClientSecure` for secure communication.

```cpp
#include <ESP8266WiFiSecure.h>
#include <ESP8266HTTPClientSecure.h>
```

2. Secure WiFi Connection:


Make sure your NodeMCU establishes a secure WiFi connection using
WPA/WPA2 authentication. Avoid using open networks or weak security
protocols.

3. Secure Data Transmission:


When sending data to remote servers or receiving commands, use secure
protocols like HTTPS or MQTT with secure configurations. Verify server
certificates to prevent man-in-the-middle attacks.

4. Implement Encryption and Authentication:


Implement encryption to protect sensitive data during transmission. You
can use SSL/TLS for HTTPS communication or secure MQTT protocols.

```cpp
WiFiClientSecure client;
client.setInsecure(); // Disable certificate verification (not recommended
for production)
```

40 | P a g e
5. Use API Keys or Tokens:
If your system involves web or mobile apps, use API keys or tokens to
authenticate and authorize access. This prevents unauthorized access to your
system.

6. Hash Passwords and Sensitive Data:


If your system involves user authentication, hash passwords and sensitive
data before storage or transmission. Use secure hashing algorithms like SHA-
256.

7. Secure Storage of Credentials:


Avoid hardcoding sensitive credentials (e.g., WiFi passwords, API keys)
directly into your code. Store them in separate configuration files or use
secure storage mechanisms.

8. Regularly Update and Patch:


Keep your NodeMCU firmware, libraries, and server software up to date to
benefit from security patches and improvements.

9. Implement Rate Limiting and IP Whitelisting:


Prevent abuse and attacks by implementing rate limiting for requests and
IP whitelisting to allow only trusted sources to interact with your system.

10. Implement Firewall Rules:


If applicable, configure your network firewall to allow only necessary
communication to and from your NodeMCU and remote servers.

41 | P a g e
11. Penetration Testing :
Conduct penetration testing or security assessments to identify
vulnerabilities in your system. This helps you uncover and fix potential
security issues.

12. Security Audits:


Regularly review and audit your code and system architecture for security
vulnerabilities. Consider involving security experts if needed.

Security should be a top priority when designing and implementing your


smart electricity billing system. By following best practices for secure
communication, you can ensure that your system remains safe and resilient
against potential threats.

42 | P a g e
10. TESTING AND OPTIMIZATION:

Testing and optimization are critical phases in the development of your smart
electricity billing system. Thorough testing helps ensure that your system
functions as intended, while optimization improves its efficiency and
reliability. Here's how to approach testing and optimization:

Testing:
1. Unit Testing: Test individual components, functions, and modules of your
code in isolation to ensure they work correctly.

2. Integration Testing: Test how different components interact with each


other. Verify that data flows correctly between sensors, controllers, displays,
and external servers.

3. Functional Testing: Test the overall functionality of your system. Perform


end-to-end tests that mimic real-world scenarios.

4. Data Accuracy Testing: Check the accuracy of sensor readings,


calculations, and billing amounts. Compare the results with known values.

5. Boundary Testing: Test how your system handles extreme values and edge
cases. For example, test the behavior when energy consumption is very low
or very high.

6. Stress Testing: Simulate high loads or usage to see how your system
performs under stress. This can help uncover performance bottlenecks and
potential crashes.
43 | P a g e
7. Security Testing: Test your system's security measures, including
encryption, authentication, and access controls. Try to identify
vulnerabilities and address them.

8. User Acceptance Testing (UAT): If applicable, involve users or testers to


evaluate your system's usability and identify any issues from a user
perspective.

9. Real-World Testing: Deploy your system in a real-world environment and


monitor its performance over an extended period. This can help identify
issues that may not appear during controlled testing.

Optimization:

1. Code Optimization: Review your code for efficiency, readability, and


maintainability. Remove unnecessary code, reduce redundant calculations,
and use optimized algorithms.

2. Power Efficiency: Optimize power usage by minimizing the time sensors,


displays, and other components remain active. Use low-power modes when
possible.

3. Memory Management: Ensure your code doesn't use excessive memory.


Avoid memory leaks and fragmentation that can lead to crashes or
instability.

4. Data Compression: When sending data over the network, consider


compressing data to reduce transmission time and bandwidth usage.
44 | P a g e
5. Data Averaging: To reduce noise in sensor data, implement data averaging
techniques. This can result in more stable readings.

6. Network Optimization: Optimize network communication by minimizing


the number of requests and reducing the size of data being transmitted.

7. Circuit Optimization: Double-check your circuit connections, soldering,


and component placements. Ensure there are no loose connections or short
circuits.

8. Error Handling: Implement robust error handling mechanisms to


gracefully handle unexpected situations, preventing crashes and data
corruption.

9. Firmware Updates: Design your system to support firmware updates so you


can fix bugs, add features, and improve security over time.

10. Documentation: Maintain clear documentation for your code, system


architecture, and setup instructions. This will help you and others
understand and troubleshoot the system.

Remember that testing and optimization are ongoing processes. As your


system evolves and is deployed in different environments, continue to test,
monitor, and optimize to ensure the best possible performance and user
experience.

45 | P a g e
11. USER INTERFACE:

User interaction is a crucial aspect of your smart electricity billing system, as


it allows users to interact with and control the system, monitor their energy
usage, and access billing information. Here's how to implement user
interaction effectively:

1. User Interface Selection:


Decide on the type of user interface you want to provide. This could be a
physical interface using buttons and displays, a web-based interface, a mobile
app, or a combination of these.

2. Physical Interface:
If you're using physical buttons and displays, design the layout and
functionality to provide users with easy access to key features. For example,
buttons could be used to toggle relays or navigate through menu options on a
display.

3. Web-Based Interface:
Create a web-based interface that users can access through their web
browsers. The interface should be user-friendly, responsive, and easy to
navigate.

4. Mobile App:
If you're developing a mobile app, design an intuitive user interface that
provides a seamless experience on mobile devices. Consider both Android
and iOS platforms if you're targeting multiple devices.

46 | P a g e
5. Real-Time Data Display:
Display real-time energy consumption, power usage, and billing
information on the user interface. This helps users monitor their usage and
make informed decisions.

6. Historical Data:
Provide access to historical energy usage data, allowing users to view trends
and patterns over time. Graphs and charts can help visualize this data
effectively.

7. Device Control:
Implement controls that allow users to remotely toggle devices (e.g., lights,
fans) on and off. Ensure that the controls are responsive and provide
feedback when actions are taken.

8. Energy Consumption Details:


Display detailed information about energy consumption, such as usage
breakdown by device, time of day, and day of the week.

9. Billing Information:
Enable users to view their billing information, including current charges,
past billing cycles, and payment history.

10. Alerts and Notifications:


Display alerts and notifications regarding energy consumption exceeding
thresholds, device malfunctions, or system updates.

47 | P a g e
11. Settings and Preferences:
Allow users to customize settings, such as alert thresholds, preferred units
(e.g., kWh or Wh), and time periods for energy consumption analysis.

12. User Authentication:


Implement user authentication and access controls to ensure that only
authorized users can access the system and make changes.

13. Feedback Mechanism:


Provide visual and auditory feedback to confirm user actions and indicate
the status of devices or processes.

14. Error Handling:


Implement clear error messages and guidance for users when they
encounter issues or input invalid data.

15. User Testing:


Involve potential users or testers to provide feedback on the user
interface's usability and functionality. This can help identify areas for
improvement.

16. Responsive Design:


Ensure that the user interface works well on various screen sizes and
orientations. This is particularly important for web-based interfaces and
mobile apps.

48 | P a g e
WORKING PRINCIPLE

➢ When the Energy Meter gets supply from the main (substation
or power station) to the input terminals of the energy meter.

➢ Generally energy meter has two input terminals and two output
terminals .

➢ From the input terminals of the energy meter input is given to ac


converter (220v to 12v) by shorting the both input of energy
meter and input terminals of the ac converter.

➢ This converter converts 230V AC to 12V DC. This 12V DC supply


is output of the converter.

➢ This output is given as input to the voltage regulator. The output


of the regulator is given as input to the Node MCU to Vin.

➢ The output of the energy meter is given to the load (2 terminals).

➢ One of the output terminals is connected to lamp load by


shorting the lamp terminal. And second terminal is connected to
the switches through the current sensor.

49 | P a g e
➢ The current sensor has two terminals. One terminal is grounded
and the another terminal is connected to the analog output
terminal of Node MCU.

➢ When we give supply to the energy meter. It transfer to the load


through the output terminal passing through the current sensor.

➢ This current sensor senses the current that passes through the
wire and gives it to the Node MCU.

➢ By Node MCU we connected to the Blynk app interfaces. It is


IOT platform used to control Arduino, Node MCU.

➢ In Blynk app create a new project file name is IOT based smart
energy meter.

➢ A page is appear hence we create a valued display settings to


display the how much load we consume and a labeled value
display it will display the cost of power consumed by the load in
one month and last finally we insert a notification bar in a Blynk
app for when the load is access then the threshold value it send
notification alert to the Mobile through the Wi- Fi module of
Node MCU.

50 | P a g e
Fig.4 Block Diagram of IOT based
Fig.3 voltage regulator
Smart Energy Meter

Fig. 5 Proposed model

51 | P a g e
RESULTS AND DISCUSSION

➢ Firstly we have to switch on the mains. Current sensor senses


the power utilized by the load.

➢ This gives output in analog form. The output of the sensor is


supplied as input to the analog input part in the Arduino Nano
Board.

➢ Arduino board has inbuilt analog to digital convertor which


converts analog input of power to digital output.

➢ This digital output is displayed on LCD display in form of Watts


.There is a set point value; when the power utilized by the load
exceeds the set point value LCD displays “Theft detected” .

➢ The Node MCU is used to connect internet with the monitoring


hardware system.

➢ The power utilized by the load is displayed in the cloud viz,


Thing Speak cloud in graphical format.

➢ It shows time to time power utilization of the load/loads


connected to the system.

52 | P a g e
➢ Energy Monitoring using IOT is an innovative application of
internet of things developed to control home appliances
remotely over the cloud from anywhere in the world.

➢ In the proposed project current sensor is used to sense the


current and display it on internet using IoT.

➢ The system updates the information in every 1 to 2 seconds on


the internet using public cloud THINGSPEAK.

➢ In the present system, energy load consumption is accessed using


Wi-Fi and it will help consumers to avoid unwanted use of
electricity.

➢ IoT system where a user can monitor energy consumption and


pay the bill Online can be made. Also, a system where a user can
receive SMS, when he/she crosses threshold of electricity usage
slab can be equipped.

➢ We can make a system which can send SMS to the concerned


meter reading man of that area when theft is detected at
consumer end. Also using cloud analytics we can predict future
energy consumptions.

53 | P a g e
REFERENCES

[1]. Himshekhar Das, L.C.Saikia, “GSM Enabled Smart Energy and


Automation of Home Appliances”,PP-978-1- -6503-1,2015 IEEE.

[2]. Ofoegbu Osita Edward, “An Energy Meter Reader with Load
Control Capacity and Secure Switching Using a Password Based
Relay Circuit”, PP-978-1-4799-8311-7, 'Annual Global Online
Conference on Information and Computer Technology', IEEE
2014.

[3]. Yingying Cheng, Huaxiao Yang, Ji Xiao, Xingzhe Hou, “Running


State Evaluation Of Electric Energy Meter”, PP978-1-4799-
4565-8, 'Workshop on Electronics, Computer and Applications',
IEEE2014.

[4]. Sahana M N, Anjana S, Ankith S,K Natarajan, K R Shobha,


“Home energy management leveraging open IoT protocol stack
“, PP- 978-1- 4673-6670-0, 'Recent Advances in Intelligent
Computational Systems (RAICS)',IEEE2015.

[5]. Luigi Martirano,Matteo Manganelli,Danilo Sbordone,''Design


and classification of smart metering systems for the energy
diagnosis of buildings'' IEEE2015.

54 | P a g e
[6]. J. Widmer, Landis,” Billing metering using sampled values
according lEe 61850-9-2 for substations”,IEEE2014.

[7]. G. Joga Rao, K. Siva Shankar " Smart Solar Charging Meter",
International Journal of Scientific Research in Science,
Engineering and Technology(IJSRSET), Print ISSN : 2395-1990,
Online ISSN : 2394-4099, Volume 4 Issue 4, pp.701-704, March-
April 2018. DOI : 10.32628/IJSRSET1844257

[8]. Dr.G.joga Rao,G.S.N.M Venkatesh Simulation of an Automatic


Meter Reading System for Smart Metering by using ASK/OOK
Modulation in Rural Smart Micro-grids, International Journal of
Engineering & Technology (IJET) Vol
9 No 3 Jun-Jul 2017 PP1511-1523 DOI:
10.21817/ijet/2017/v9i3/170903501

[9]. Cheng Pang,Valierry Vyatkin,Yinbai Deng, Majidi Sorouri,


“Virtual smart metering in automation and simulation of energy
efficient lightning system” IEEE2013.

[10]. Amit Bhimte, Rohit K.Mathew, Kumaravel S, “Development of


smart energy meter in labview for power distribution systems”,
“IEEE INDICON 2015 1570186881”,2015.

55 | P a g e

You might also like