Smart Energy Monitoring System Using ESP32 And SCT-013 Sensor

An open-source, modular smart energy monitoring system is created and put into use in this project. An Internet of Things network based on Wi-Fi has been developed that allows us to track our daily energy usage in our homes using smartphones. The current sensor SCT-013 (up to 100A) linked to the ESP32 development board has been used to monitor the current and voltage values in the Internet of Things network. Phase angle, measured voltage, and current may all be used to compute power factors, real power, and perceived power.

The ESP32 development board has received these measured and computed values via software serial communication. The cloud server-based user interface that the ESP32 offers allows us to view these computations and the real data. It connects to a Wi-Fi access point. Using TCP/IP protocols, the user interface is seen on mobile applications and online browsers. Empirical research indicates that this technology may find utility in a variety of general-purpose applications, including Internet of Things energy monitoring systems and smart home automation systems.

One of the most crucial aspects of our everyday lives that drives technological advancement is the need for power. Grid loading is designed for both residential and business users. Operators must therefore distribute loads while considering the two categories of customers. This is why energy usage is minimised in smart home design. These days, smart grids include smart houses as a major component. For this reason, we must manage such homes’ energy usage. The automotive sector, logistics, healthcare, smart grids, urban regions, and smart homes are just a few of the industries that have been impacted by the Internet of Things (IoT) in recent years.

The Internet of Things (IoT) may be divided into two groups: the Internet of Consumer Things (CIoT) and the Internet of Industrial Things (IIoT). A brief discussion on CIoT systems has been included in this project. Using the Internet of Things (IoT) to manage appliances such as air conditioners, dishwashers, water geysers, and other devices, we could quickly track how much energy we use in our house. It is well-recognised that traditional measurement techniques are labour-intensive and difficult to use in real-world situations. These issues are resolved with a single click when CIoT solutions are used with Wi-Fi-capable devices. In today’s technologically advanced world, most houses have laptops, cell phones, and Wi-Fi networks. Thus, it is now also simpler.

Principle Behind Smart Energy Monitoring System

In this project, the single-phase current is measured using the SCT-013 current (CT) sensor, and the voltage’s RMS value is measured using a 9V AC step-down transformer. The ESP32 board is attached to these two sensors. The observed current, RMS voltage values, and phase angle may be used to determine the power factor, real power, and apparent power values in the Arduino IDE software.

Using the Arduino IDE software, the measured and computed data were transferred to the ESP32 development board. The Wi-Fi access point in the planned CIoT network allows the ESP32, cloud server, and smartphone device to connect using the TCP/IP protocol.

Project

Circuit Schematic

Components

  • ESP32 Development Board
  • SCT-012 Current Sensor
  • ZMPT101B Voltage Sensor
  • 10uF/25V Capacitor
  • 10KΩ Resistor (x2)
  • 100Ω Resistor
  • 5 Volt Power Supply
  • Connecting Wires

About Parts

ESP32 Development Board

This microcontroller-based low-cost, low-power device has built-in Bluetooth and Wi-Fi capabilities. TSMC uses their 40nm chip technology to make ESP32, which was designed and developed by the Chinese business Espressif Systems, which has its headquarters in Shanghai. The ESP8266 NodeMCU may be used in this project, although it only comes with one analogue pin. The ESP32 has a large number of analogue pins. As a result, despite the ESP8266 NodeMCU, we selected the ESP32 based on our demands (Voltage and Current).

Current Sensor (SCT-013)

The accuracy of the current measurement was determined using this non-invasive current sensor. The split-core clamp-on current sensor is called SCT-013. This characteristic has caused the CT to be clamped onto the wire’s single phase. An AC voltage is applied in the output section in direct proportion to the single-phase change in AC.

Voltage Sensor

This voltage sensor is made using a 9V AC step-down transformer. However, for precise sensing, we might utilise the ZMPT101B One-Phase Voltage Sensor. It gets rid of unkempt wiring connections. However, this is the approach we use to cut costs. Insulation between high and low AC voltage is provided by the transformer. To reduce this voltage to 0–5V, the voltage divider circuit is linked to the 9V transformer output terminal. As a result, voltage measurement is possible without the need for high-voltage operation.

Circuit Connection

Let me now go over the circuit schematic for the ESP32 IoT board-based CIoT-Based Smart Energy Monitoring System. EasyEDA software has been used in the circuit design process.

The connections are rather basic. The ESP32’s ground pin is linked to the ground pins of both modules. The voltage sensor’s output analogue pin is linked to the ESP32’s GPIO35. In a similar manner, the GPIO34 of the ESP32 is linked to the output Analogue pin of the SCT-013 current sensor. Subsequently, a 10uF/25V electrolytic capacitor, two 10KΩ resistors, and one 100Ω resistor are connected.

This project uses a 16×2 LCD display to give it a more polished appearance. However, as it is an Internet of Things gadget, it is not dependent on an LCD display to function. For convenience of usage, we also employ a 16×2 I2C LCD module here. Attach the D21 and D22 pins of the ESP32 to the SDA and SCL terminals of the I2C module, respectively.

Note: To connect the LCD display, just connect pins 4, 6, 11, 12, 13, and 14 on the LCD panel to pins D13, D12, D14, D27, D26, and D25 on the ESP32 development board. Lastly, attach the LCD display’s pins 1, 5, 16, and 2 to 5V VCC and ground, respectively. To change the contrast, use a 10K variable resistor at pin 3 of the LCD.

In addition, we must measure the actual AC voltage that is linked to the voltage sensor’s input AC connection. Similar to this, the current sensor clip is essentially a phase or neutral wire that is clipped and locked; it has no connections. If you cut either the phase or the neutral wire, the reading will be off.

Cloud Server Creation for Smart Energy Monitoring System

For this project, we utilise a computer dashboard and a smartphone to control any IoT device using the Blynk programme, which operates on both Android and iOS smartphones. It lets you design your own graphical user interface for Internet of Things applications. Blynk does the task of displaying the values of RMS voltage, current, power factor, and watts on our smartphone.

  • Installing Blynk requires first downloading and installing it from the Google Play Store. Users of iOS may get it via the App Store as well. After the procedure is complete, launch the app and register with your email address and password.
  • Next, from the dashboard, create a new project, choose ESP32 from the drop-down menu, and configure it to operate in Wi-Fi mode.
  • Next, assign the variable as per your preference and drag & drop or create four widgets by clicking on the tab in the upper right corner.

For Blynk 2.0 Software

  • All that is required with the new Blynk 2.0 application is to set the device ID, password, and template ID. You may find it under the section on templates. Simply copy and paste it into the appropriate ESP32 programming code area.

Some Library for Compiling the ESP32 Code

EmonLib

The EmonLib library is used to continually monitor voltage, current, and electric energy. Thus, our Smart Energy Monitoring System makes use of this library.

The Blynk Library

The well-liked IoT cloud server Blynk allows you to connect any gear to the cloud. More than 400 hardware types, including Arduino, ESP8266, and ESP32, may be connected to the cloud server using the Blynk Library.

ESP32 Programming

In order to compile the code, the ESP32 board manager is also required. Simply choose File, then Preferences, Paste the URL into Additional Board Manager URLs and then click OK.

The package esp32_index.json may be accessed at https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages.

Click Tools → Boards → Boards Manager →Search ESP32 → Install →OK after that.

//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
//LiquidCrystal lcd(13, 12, 14, 27, 26, 25);
#define BLYNK_PRINT Serial
#include "EmonLib.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
EnergyMonitor emon;
#define vCalibration 83.3
#define currCalibration 0.50
BlynkTimer timer;
char auth[] = "8pLvHwMeurO0_Zojr9hXoxBYw6IGgT7C"; //Your auth token from email
char ssid[] = "Electro Gadget";    //Type your WiFi name
char pass[] = "**********";    //Type your WiFi password
float kWh = 0;
unsigned long lastmillis = millis();
void myTimerEvent()
{
  emon.calcVI(20, 2000);
  kWh = kWh + emon.apparentPower * (millis() - lastmillis) / 3600000000.0;
  yield();
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Vrms:");
  lcd.print(emon.Vrms, 2);
  lcd.print("V");
  lcd.setCursor(0, 1);
  lcd.print("Irms:");
  lcd.print(emon.Irms, 4);
  lcd.print("A");
  delay(2500);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Power:");
  lcd.print(emon.apparentPower, 4);
  lcd.print("W");
  lcd.setCursor(0, 1);
  lcd.print("kWh:");
  lcd.print(kWh, 4);
  lcd.print("W");
  delay(2500);
  lastmillis = millis();
  Blynk.virtualWrite(V0, emon.Vrms);
  Blynk.virtualWrite(V1, emon.Irms);
  Blynk.virtualWrite(V2, emon.apparentPower);
  Blynk.virtualWrite(V3, kWh);
}
void setup()
{
  //lcd.begin(16, 2);
  lcd.init();                      
  lcd.backlight();
  Blynk.begin(auth, ssid, pass);
  emon.voltage(35, vCalibration, 1.7); // Voltage: input pin, calibration, phase_shift
  emon.current(34, currCalibration);   // Current: input pin, calibration.
  timer.setInterval(5000L, myTimerEvent);
  lcd.setCursor(3, 0);
  lcd.print("Smart Energy");
  lcd.setCursor(5, 1);
  lcd.print("Monitor");
  delay(3000);
  lcd.clear();
}
void loop()
{
  Blynk.run();
  timer.run();
}

Leave a Comment