Smart Electricity Billing
Smart Electricity Billing
Session : 2020-23
A REPORT ON
Submitted By:-
SWATI KUMARI ( 1281520002 )
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.
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
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
5|Page
LISTS OF FIGURES
Fig.2:Node MCU(ESP8266) 13
Fig.3:Voltage Regulator 51
6|Page
INTRODUCTION
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.
➢ 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.
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.
➢ 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.
➢ These are all the features to be taken into account for designing
an efficient energy billing system.
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.
➢ 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 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:
➢ One thousand watts make one kilowatt. If one uses one kilowatt
in one-hour duration, one unit of energy gets consumed.
12 | P a g e
NODE-MCU (ESP8266):
13 | P a g e
CURRENT SENSOR:
VOLTAGE REGULATOR:
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:
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:
16 | P a g e
Calibrating the ACS712 Current Sensor:
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
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
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
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:
```cpp
#include <ESP8266WiFi.h>
```
```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.
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:
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
```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.
```cpp
display.clear();
display.drawString(0, 0, "Power: " + String(powerWatts) + " W");
display.drawString(0, 20, "Energy: " + String(energyWh) + " Wh");
display.display();
```
```cpp
#include <ESP8266HTTPClient.h>
23 | P a g e
http.end();
}
```
```cpp
void loop() {
// Read sensor data, calculate, and store/transmit
// ...
5. BILLING CALCULATIONS:
24 | P a g e
sensor readings over a specific period of time.
```cpp
float energyKWh = energyWh / 1000; // Convert to kilowatt-hours
float costPerKWh = 0.15; // Example electricity rate ($0.15 per kWh)
float billingAmount = energyKWh * costPerKWh;
```
25 | P a g e
```cpp
display.drawString(0, 40, "Billing: $" + String(billingAmount, 2)); //
Display with 2 decimal places
display.display();
```
```cpp
#include <ESP8266HTTPClient.h>
```cpp
26 | P a g e
// Reset energyWh to start measuring for the next billing cycle
energyWh = 0;
```
27 | P a g e
6. REMOTE CONTROL:
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.
```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);
}
- **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.
29 | P a g e
NodeMCU over WiFi. The app can send commands to turn the relays on or
off.
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");
});
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.
31 | P a g e
7. DISPLAY AND INTERFACE:
```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();
}
```
```cpp
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
```
```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>
```
```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
}
```
```cpp
void setup() {
// ... Other setup code ...
35 | P a g e
server.begin();
}
```
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.
36 | P a g e
about energy conservation.
```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>
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.
9. SECURE COMMUNICATION:
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>
```
```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.
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.
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.
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.
Optimization:
45 | P a g e
11. USER INTERFACE:
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.
9. Billing Information:
Enable users to view their billing information, including current charges,
past billing cycles, and payment history.
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.
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 .
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.
➢ This current sensor senses the current that passes through the
wire and gives it to the Node MCU.
➢ In Blynk app create a new project file name is IOT based smart
energy meter.
50 | P a g e
Fig.4 Block Diagram of IOT based
Fig.3 voltage regulator
Smart Energy Meter
51 | P a g e
RESULTS AND DISCUSSION
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.
53 | P a g e
REFERENCES
[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.
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
55 | P a g e