We all know about Electricity energy meters which are installed in everyone’s house or offices to measure the electricity consumption. At last of every month, many of us get worried about the high electricity bill and we have to look at the energy meter once in a while. But what if we can monitor our electricity uses from anywhere in the world and get an SMS/E-mail when your energy consumption reaches to a threshold value. Here we are building an IoT based Project of Energy Meter.
Previously we have built a Energy Meter circuit which sends you SMS about the bill using GSM module. In this project we make a Smart Electricity Energy meter using Arduino and ESP8266 Wi-Fi module which can not only sends you a SMS/Email of your electricity Bill but also you can monitor the energy uses anytime and from anywhere in the world. Here we have used a Current Sensor ACS712 to measure the energy consumption, we will discuss about it shortly.
We will take help of IFTTT platform to link our Wi-Fi to SMS/E-mail notifications. We will also use MQTT Dashboard Android App to monitor our Energy uses. So Lets Get started….
Materials Required:
- Arduino Uno
- ESP12/NodeMCU
- ACS712-30Amp Current sensor
- Any AC Appliance
- Male-Female Wires
Working of ACS712 Current Sensor:
Before we start building the project it is very important for us to understand the working of the ACS712 Current sensor as it is the key component of the project. Measuring current especially AC current is always a tough task due to the noise coupled with it improper isolation problem etc. But, with the help of this ACS712 module which was engineered by Allegro thing have become a lot easier.
This module works on the principle of Hall-effect, which was discovered by Dr. Edwin Hall. According his principle, when a current carrying conductor is placed into a magnetic field, a voltage is generated across its edges perpendicular to the directions of both the current and the magnetic field. Let us not get too deep into the concept but, simply put we use a hall sensor to measure the magnetic field around a current carrying conductor. This measurement will be in terms of millivolts which we called as the hall-voltage. This measured hall-voltage is proportional to the current that was flowing through the conductor.
The major advantage of using ACS712 Current Sensor is that is can measure both AC and DC current and it also provides isolation between the Load (AC/DC load) and Measuring Unit (Microcontroller part). As shown in the picture we have three pins on the module which are Vcc, Vout and Ground respectively.
The 2-pin terminal block is where the current carrying wire should be passed through. The module work on +5V so the Vcc should be powered by 5V and the ground should be connected to Ground of the system. The Vout pin has an offset voltage of 2500mV, meaning when there is no current flowing through the wire then the output voltage will be 2500mV and when current flowing is positive, the voltage will be greater than 2500mV and when the current flowing is negative, the voltage will be less than 2500mV.
We will be using theAnalog pin of Arduinoto read the output voltage (Vout) of the module, which will be 512(2500mV) when there is no current flowing through the wire. This value will reduce as the current flows in negative direction and will increase as the current flows in positive direction. The below table will help you understand how the output voltage and ADC value varies based on the current flowing through the wire.
These values were calculated based on the information given in the Datasheet of ACS712. You can also calculate them using the below formulae:
Vout Voltage(mV) = (ADC Value/ 1023)*5000Current Through the Wire (A) = (Vout(mv)-2500)/185
Now, that we know how the ACS712 Sensor works and what we could expect from it. Let us proceed to the circuit diagram.
We have used this sensor to make Digital Ammeter Circuit using PIC Microcontroller and ACS712.
Circuit diagram:
Circuit diagram for IoT based Energy Meter using Arduino and NodeMCU is given above, connect ESP12 as below:
Connect Rx of ESP12 -> Tx of Arduino.
Connect Tx of ESP12 -> Rx of Arduino.
There is one analog pin available in NodeMCU (ESP12), we could use that pin but ESP series can take upto 3.3 volts on their pins. As we are using current sensor which can give upto 5 Volts so, it can damage our Wi-Fi module that’s why we are not using standalone NodeMCU.
To make output of current sensor 3.3V instead of 5V, we cannot use voltage divider circuit between Current sensor and analog pin of NodeMCU because as we discussed above about the current sensor that at 2.5Volts output, current is 0Amp.
So, Arduino will read the current sensor value through analog pin and send it to the Wi-Fi module ESP12 using Serial communication. Use voltage divider circuit at receiver pin of NodeMCU so that receiver pin can get upto 3.3 Voltage level.
To monitor our energy uses over the internet, we have to use MQTT broker. We will use MQTT broker as AdaFruit IO platform and follow the below process to make this IoT Energy Meter
- Setting up an AdaFruit account for storing Electricity meter readings.
- Create Applet in IFTTT for Triggering SMS/Email for Energy Meter
- Codes for Arduino and ESP12Wi-Fi module.
Setting up an AdaFruit account for communication:
First, we will make a feed inAdaFruit IO. Feed stores the data sent by IFTTT. To make feed follow these steps:
Step 1:- Login to Adafruit IO with your credentials or Sign up if you don’t have an account.
Step 2:-Click on My account -> Dashboard
Step 3:-Click on Actions and Create a New Dashboard.
Step 4: Give name and description to your feed and click on Create.
Step 5: Click onKeybutton and note down the AIO Keys, we will use this key in our code.
Step 6: Click on ‘+’ button to create a new block and click on Gauge to display Energy uses level. You can also use simple text box to display energy.
Step 7: Now, Enter Name of Feed and click on Create. Then Select the feed and click on Next step.
Step 8:In block settings, fill the min. and max values as 0 and 100 respectively or you can modify as you want.
Step 9:Your Power feed is successfully created. Now, create feed to display Bill by clicking on “+” sign.
Now, we have to link AdaFruit IO to SMS/E-mail using IFTTT.
Create Applet in IFTTT for Triggering SMS/Email for Energy Meter:
Step 1: Login toIFTTTwith your credentials.
Step 2: On My Applets, Click onNew Applet
Step 3: Click on +this
Step 4: Search AdaFruit and click on it.
Step 5: Click on Monitor a feed on AdaFruit IO.
Step 6: Choose Feed as bill, Relationship as ‘equal to’ and the threshold value at which you want an E-mail. Click on Create action. I have used 4 as my threshold trigger value.
Step 7: Click on +that. Search for G-mail and click on it and Login with your g-mail credentials.
Step 8: Click on send yourself an email.
Step 9: Write your subject and body as shown and click to create.
Step 10: Your ‘recipe’ is ready. Review it and click on finish.
Now, we are done with web integration. Let’s move on coding part..
Code and Explanation:
We are using serial communication between ESP12 and Arduino. So, we have to write code for both Arduino and NodeMCU for transmitting and receiving.
Code for Transmitter Part i.e. for Arduino Uno:
Complete Arduino code is given at the end of this tutorial. We will use library for Current sensor which can be downloaded from this Link.
This library has inbuilt function to calculate current. You can write your code to calculate current but this library has accurate current measuring algorithms.
First, include library for current sensor as:
#include "ACS712.h"
Make an array to store power for sending it to NodeMCU.
char watt[5];
Create an instance to use ACS712-30Amp at PIN A0. Change First argument if you are using 20Amp or 5 Amp variant.
ACS712 sensor(ACS712_30A, A0);
In setup function, define baud rate of 115200 to communicate with NodeMCU. Call sensor.calibrate() function for calibrating current sensor to get accurate readings.
void setup() { Serial.begin(115200); sensor.calibrate();}
In loop function, we will call sensor.getCurrentAC(); function to get the current value and store in the float variable I. After getting current, calculate power using P=V*I formula. We use 230V because it is the common standard in European countries, Change to your local, if necessary
void loop() { float V= 230; float I = sensor.getCurrentAC(); float P = V * I;
These lines convert power into Wh.
last_time = current_time; current_time = millis(); Wh = Wh+ P *(( current_time -last_time) /3600000.0) ;
Now, we have to convert this Wh into character form to send it to NodeMCU, for this dtostrf(); will convert a float to a char array so it can then be printed easily:
dtostrf(Wh, 4, 2, watt);
The format is:
dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);
Write this character array to serial buffer using Serial.write(); function. This will send Wh value to NodeMCU.
Serial.write(watt); delay(10000);}
Code for Receiver Part NodeMCU ESP12:
For this we need AdaFruit MQTT library which can be downloaded from this link.
Now, open Arduino IDE. Go to examples -> AdaFruit MQTT library -> mqtt_esp8266
We will edit this code according to our AIO keys and Wi-Fi credentials and incoming serial data from the Arduino.
First, we included all the libraries for ESP12Wi-Fi Module and AdaFruit MQTT.
#include <ESP8266WiFi.h>#include "Adafruit_MQTT.h"#include "Adafruit_MQTT_Client.h"
We define the SSID and Password for your Wi-Fi, from which you want to connect your ESp-12e.
#define WLAN_SSID "xxxxxxxx"#define WLAN_PASS "xxxxxxxxxxx"
This section defines the AdaFruit server and server port which is fixed as “io.adafruit.com” and “1883” respectively.
#define AIO_SERVER "io.adafruit.com"#define AIO_SERVERPORT 1883
Replace these fields with your username and AIO keys which you have copied from AdaFruit site while making the Feed.
#define AIO_USERNAME "********"#define AIO_KEY "******************************"
Then we have created an ESP12WiFiClient class to connect to the MQTT server.
WiFiClient client;
Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
Setup a feed called 'Power' and ‘bill’ for publishing to changes.
Adafruit_MQTT_Publish Power = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Power");Adafruit_MQTT_Publish bill = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/bill");
In setup function, we connect Wi-Fi module to Wi-fi access point.
void setup() { Serial.begin(115200); delay(10); Serial.println(F("Adafruit MQTT demo")); // Connect to WiFi access point. Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(WLAN_SSID); WiFi.begin(WLAN_SSID, WLAN_PASS);….….…}
In loop function, we will check for incoming data from the Arduino and publish this data to AdaFruit IO.
void loop() { // Ensure the connection to the MQTT server is alive (this will make the first // connection and automatically reconnect when disconnected). See the MQTT_connect // function definition further below. MQTT_connect(); int i=0; float watt1;
This function check for the incoming data from the Arduino and store this data into watt[] array using serial.read() function.
if(Serial.available() > 0 ){ delay(100); //allows all serial sent to be received together while(Serial.available() && i<5) { watt[i++] = Serial.read(); } watt[i++]='\0'; }
atof() function convert the characters to float values and we will store this float value in another float variable watt1 .
watt1 = atof(watt);
Calculate bill amount by multiplying power (in Wh) with energy tariff and divide it by 1000 to make power in KWh.
bill_amount = watt1 * (energyTariff/1000); // 1unit = 1kwH
Now we can publish stuff!
Serial.print(F("\nSending Power val ")); Serial.println(watt1); Serial.print("...");
This piece of code is publishing power values to the Power feed
if (! Power.publish(watt1)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); }
This will publish electricity bill to the bill feed.
if (! bill.publish(bill_amount)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!"));}
Our bill amount may change fast but IFTTT takes time to trigger the applet so these lines will give time for triggering so that we can receive threshold email.
Change the bill_amount value on which you want to get email. Also, change in the IFTTT AdaFruit IO setup.
if (bill_amount==4){for (int i =0; i<=2; i++){ bill.publish(bill_amount);delay(5000);}bill_amount =6;}
Complete Code for Arduino and NodeMCU ESP12are given at the end of this tutorial.
Now, upload the codes to both the boards. Connect your hardware as shown in the Circuit diagram and Open io.adafruit.com. Open the dashboard you just created. You will see the Power consumption and electricity Bill is updating.
When your bill reached to INR 4 then you will get an email like this.
Android App for Monitoring Electricity Consumption:
You can use Android App for monitoring the values. For this download the MQTT Dashboard android app from the Play store or from this Link.
To setup connection with the io.adafruit.com follow these steps:
Step 1: Open the App and click on “+” sign. Fill Client Id anything you want. Server and port remain same as shown in the screenshot. You will get Username and password (Active key) from the AdaFruit IO dashboard as shown below.
Active Key is your password.
Step 2: Select Electricity Meter and select Subscribe. In subscription, give friendly name and topic. Topic format is ‘yourusername’/feeds/’feedname’ and click on create.
Step 3: In the same way, make subscription for bill feed.
Step 4: As your appliances consuming energy, updated values will be displayed under the Power and Bill.
This is how you can create a Smart Electricity Energy Meter, which can be not only monitored from anywhere in the world but also trigger Email when you have high Electricity consumption.
Also check our all the IoT Projects.
FAQs
What is IoT based energy meter? ›
To solve this problem, a smart energy meter is proposed based on Internet of Things (loT). The proposed smart energy meter controls and calculates the energy consumption using ESP 8266 12E, a Wi-Fi module and uploads it to the cloud from where the consumer or producer can view the reading.
How can I make my smart energy meter? ›In this new. Video. We will learn how to make our own iit based electricity energy meter using esp32
What is IoT smart meter? ›Smart metering is the monitoring of resource consumption, such as energy, water, gas, etc., through modern metering devices connected to the Internet via IoT technology. These metering devices are typically referred to as smart meters.
How does a smart electric meter work? ›A smart meter is an electronic device that records information such as consumption of electric energy, voltage levels, current, and power factor. Smart meters communicate the information to the consumer for greater clarity of consumption behavior, and electricity suppliers for system monitoring and customer billing.
How does Arduino measure power consumption? ›You can refer the Arduino dB meter in which I have used a similar method. Finally, once we have calculated the value of actual voltage and actual current through the load, we can calculate the Power using the formulae (P=V*I). Then we display all the three values on the LCD display using the code below.
How can I make a simple energy meter? ›DIY Arduino power/energy meter - YouTube
How do I connect a CT sensor to Arduino? ›To connect a CT sensor to an Arduino, the output signal from the CT sensor needs to be conditioned so it meets the input requirements of the Arduino analog inputs, i.e. a positive voltage between 0V and the ADC reference voltage.
What makes a smart meter? ›Like a traditional meter, smart meters have a number that counts up to show how much energy you've used. The main difference is that the numbers are on a screen, instead of an analogue dial. You can still read them like your old meter if you want to, but your readings will be sent to us automatically.
What is smart meter project? ›The introduction of smart meters makes it possible to understand the amount of current by analyzing the electricity usage amount over a 30-minute period for each meter. Therefore, it is possible to calculate the expected load current with a higher accuracy than the current system.
What is GSM based Smart energy meter? ›technology is using a Global System for Mobile. Communication (GSM) based system. This system replace the. Bluetooth technology and the data sent using Short Message. Service (SMS) to the customer and the energy board [1].
What are the different types of smart meters? ›
There are two types of smart meter at present – known as SMETS 1 and SMETS 2, they represent the first and second generations of the technology (SMETS stands for 'Smart Metering Equipment Technical Specifications').
What is IoT technology? ›What is the Internet of Things (IoT)? The term IoT, or Internet of Things, refers to the collective network of connected devices and the technology that facilitates communication between devices and the cloud, as well as between the devices themselves.
What are the different applications of smart meter in a smart grid? ›This allows the utility center for better monitoring and control. The data communication in real time basis allows the utilities with advantages like real time pricing, outage detection, identification of power theft, avoids meter data tampering and provides better service.
What is the difference between energy meter and smart meter? ›Energy monitors just tell you about energy usage (total consumption or consumption at the sub-circuit level). Smart energy monitors not only reveal wasteful energy habits and increase savings, but can smarten your home and provide helpful insights for you and your family.
How do smart meters send readings? ›"Smart metering works by the gas sending a reading to the electricity meter and then the electricity meter sends both reads to the IHD, and from there they get sent to us. Occasionally, due to the location of the gas meter, the signal between the meters is not strong enough for the gas meter to communicate.
How does Arduino measure voltage and current? ›All you have to do is connect vcc of the module to 5v of the Arduino GND to ground of the Arduino and vout to analogue pin 0 of the Arduino. Once all the connections are made you just need to upload the code to the Arduino and open the serial monitor and the voltage will be displayed.
How does Arduino measure DC current? ›Arduino has the ability to measure current using analog input pin. For Arduino UNO, there are 6 analog input pins (A0-A5) where you can use one of the pins to measure DC current. Arduino NANO has 8 pins while Arduino MEGA has 16 input pins.
How does Arduino calculate battery usage? ›Arduino Project to Product Part 2: How to Calculate Battery Life - YouTube
How do I convert watts to meters? ›How to Build an Arduino Wattmeter Project - YouTube
What is a CT sensor? ›Current sensors, also commonly referred to as current transformers or CTs, are devices that measure the current running through a wire by using the magnetic field to detect the current and generate a proportional output. They are used with both AC and DC current.
How do you make an energy monitor circuit? ›
DIY Home Energy Monitor & CT sensors explained - YouTube
How is ESP32 used to measure current? ›#386 How to measure low Currents for ESP/Arduino? Power Profiler, Otii ...
What is the use of current sensor? ›A current sensor is a device that detects and converts current to an easily measurable output voltage, which is proportional to the current through the measured path. There are a wide variety of sensors, and each sensor is suitable for a specific current range and environmental condition.
How is ESP32 power consumption measured? ›- In this opportunity we will measure the (current draw of the module in the following modes: ...
- Test Setup #2.
- Current to Voltage converter board based on the INA169 chip. ...
- Results with DAQ Device: ...
- With Module transmitting Wi-Fi packages, measurement using the DAQ system.
Measure current with Arduino Split Core Current Transformer, CT ...
How do you use a non-invasive current sensor with Arduino? ›First, download the Emon library and install it for Arduino ide. Create a new project, include the EmonLib header file, and create an instance. In the setup function, I started the serial monitor at 9600 bps.
Does a smart meter need wifi? ›All smart meters use a national wireless communication network to send information to your energy supplier. So, even if you do not have an internet connection in your home, a smart meter will still work.
Who invented the smart meter? ›Mr. Paraskevakos was awarded a U.S. patent for this technology in 1974. Three years later, he launched Metretek, Inc., the company that produced the first fully automated, commercially available remote meter reading and load management system.
How much energy does a smart meter use? ›The smart meter itself doesn't cost you anything because it doesn't use your energy supply. Your In-Home Display – the small touchscreen device that shows your home energy usage – is powered by your electricity supply.
What protocol do smart meters use? ›TCP/IP. Transmission Control Protocol/Internet Protocol is the most popular protocol for sending data over the Internet, becoming a more popular communication solution for smart meters, as it leaves room for manufacturers to use multiple communication systems and change modules and standards as needed.
What are the disadvantages of a smart meter? ›
- My smart meter has turned dumb. ...
- Switching energy suppliers becomes difficult. ...
- Poor signal prevents the smart meter from working. ...
- Smart meter stops sending readings. ...
- Understanding your smart meter monitor. ...
- Smart meters pose a risk to security. ...
- Existing meters are hard to access.
- Standard meters.
- Dial meters.
- Digital meters.
- Variable-rate meters.
- Prepayment meters.
- Smart meters.
GSM (Global System for Mobile communication) is a digital mobile network that is widely used by mobile phone users in Europe and other parts of the world.
Which electricity meter is best? ›...
Energy Meters - Price Range.
Energy Meters | Min Price | Max Price |
---|---|---|
RC Bentex Energy Meters | ₹365 | ₹1469 |
HPL Energy Meters | ₹819 | ₹22986 |
Schneider Energy Meters | ₹2130 | ₹10668 |
L&T Energy Meters | ₹890 | ₹115779 |
Smart Meters enable a utility to provide customers with detailed information about their energy usage at different times of the day, which in turn enables customers to manage their energy use more proactively.
Why do energy companies want smart meters? ›Smart meters improve your awareness of energy consumption. By changing behavioural habits and informing decisions to buy more energy efficient appliances there is less pressure on the electricity grid. Smart Energy GB estimate a 24% decrease in emissions from homes and businesses by 2030.
What is IoT give 5 examples? ›In short, the Internet of Things refers to the rapidly growing network of connected objects that are able to collect and exchange data in real time using embedded sensors. Thermostats, cars, lights, refrigerators, and more appliances can all be connected to the IoT.
What are IoT sensors? ›Sensors for IoT
Sensors enable the Internet of Things (IoT) by collecting the data for smarter decisions. Learn how TE Connectivity (TE) sensors are used in applications including consumer devices, Industry 4.0, and medical applications including remote patient monitoring.
IoT-based home automation project aims to automate the functioning of household appliances and objects over the Internet. All the household objects that are connected over the IoT network can be controlled and operated through your smartphone.
What are the five challenges of smart grid? ›- Growing amount of renewable energy sources. ...
- Electricity transmission losses. ...
- Frequent power outages. ...
- Electromobility. ...
- Grid modernization. ...
- Threat of cyber attacks.
What are the applications of energy meter? ›
Major applications
The vast application of energy meters can be categorized into four major parts of the power system network: Generation, transmission, distribution, and utilization.
With a smart meter, energy consumers can now begin to improve energy efficiency at home. By better understanding their usage patterns, you can make small changes to reduce their energy usage or optimize their usage based on local demand load for electricity.
What is IoT technology? ›What is the Internet of Things (IoT)? The term IoT, or Internet of Things, refers to the collective network of connected devices and the technology that facilitates communication between devices and the cloud, as well as between the devices themselves.
What is the real example of a smart grid devices in IoT Mcq? ›The real example of a smart grid device is a smart meter.
What is IoT give 5 examples? ›In short, the Internet of Things refers to the rapidly growing network of connected objects that are able to collect and exchange data in real time using embedded sensors. Thermostats, cars, lights, refrigerators, and more appliances can all be connected to the IoT.
What are IoT sensors? ›Sensors for IoT
Sensors enable the Internet of Things (IoT) by collecting the data for smarter decisions. Learn how TE Connectivity (TE) sensors are used in applications including consumer devices, Industry 4.0, and medical applications including remote patient monitoring.
IoT-based home automation project aims to automate the functioning of household appliances and objects over the Internet. All the household objects that are connected over the IoT network can be controlled and operated through your smartphone.
How much energy does a smart meter use? ›The smart meter itself doesn't cost you anything because it doesn't use your energy supply. Your In-Home Display – the small touchscreen device that shows your home energy usage – is powered by your electricity supply.
What are the advantages and disadvantages of a smart meter? ›Advantages | Disadvantages |
---|---|
No need to manually submit readings | If you have SMETS 1, it may lose smart functionality after you switch |
Easy to monitor your energy usage and spending using in-home display | In-Home Display may be inaccurate |
Smart meters come with a display device to track how much energy is being used more accurately. It sends readings automatically to suppliers, meaning customers are less likely to underpay or overpay for gas and electricity.
What is IOT Gecko? ›
IOT Gecko is a free IOT systems development platform for students, researchers and developers. Opening doors to physical devices controlled over the internet, IOT Gecko provides you the tools and support to design your IOT based systems with ease. Get sensor/device data and use it over the internet.
What is an example of smart grid device in IoT? ›The technologies that make today's IoT-enabled energy grid “smart” include wireless devices such as sensors, radio modules, gateways and routers.
Which protocol is used by IoT devices? ›HyperText Transfer Protocol is the best example of IoT network protocol. This protocol has formed the foundation of data communication over the web. It is the most common protocol that is used for IoT devices when there is a lot of data to be published.
Which is the future application of IoT? ›Which is the future application of IoT? Role of green IoT system is the future application of IoT. Green IoT represents the issue of reducing energy consumption of IoT devices which achieves a sustainable environment for IoT systems.