Kol
Kol
This chapter used in developing the Smart Energy Management System. It details the integration of sensors,
microcontroller firmware and control logic implemented on the ESP32. The overall goal is to achieve real-
16
INPUT UNIT
The ACS712 current sensor module is a compact, high-precision, Hall-effect–based sensor developed by
Allegro Microsystems. It is designed to accurately measure both alternating current (AC) and direct current
(DC) in a non-intrusive and electrically isolated manner. This makes it particularly suitable for energy
monitoring applications, such as the smart energy management system developed in this project. The sensor
provides a linear analog voltage output that is directly proportional to the current flowing through its
terminals, which can then be read and interpreted by a microcontroller such as the ESP32.
The ACS712 operates on a 5V DC power supply and typically draws around 10 milliamps during use. It
provides an output voltage range between 0 and 5 volts, centered at 2.5 volts when no current is flowing
through the sensor. This mid-point voltage shifts either upward or downward depending on the direction
and magnitude of the current being measured. The sensor internally isolates the high-current input side
from the low-voltage signal output, supporting isolation voltages up to 2100 volts RMS, which enhances
In operation, the ACS712 senses the magnetic field generated by the current flowing through its internal
conductor and converts this magnetic field into a proportional voltage. For the 20A variant used in this
project, the sensor provides a sensitivity of approximately 100 millivolts per ampere. When the output
voltage from the sensor is greater than 2.5 volts, it indicates positive current flow, and when it is less than
2.5 volts, it indicates negative current flow. The analog signal is read by the ESP32’s analog-to-digital
converter (ADC) and processed through a calibrated algorithm to calculate the actual current in amperes.
19
Fig 3.4 - ZMPT101B Voltage Sensor
The ZMPT101B voltage sensor module is a highly precise and compact analog voltage sensing solution,
specifically designed for AC mains voltage monitoring. It is based on the ZMPT101B voltage
transformer, which is engineered to safely step down high-voltage AC signals for analysis and measurement
in low-voltage microcontroller systems. This sensor is especially valuable in smart metering and
energy monitoring applications, such as the Smart Energy Management System (SEMS) developed in this
The ZMPT101B operates on a 5V DC power supply and delivers an analog voltage output that is
proportional to the input AC voltage. Internally, the sensor features a high-precision, low-phase error
voltage transformer, combined with signal conditioning circuitry that includes a gain-adjustable operational
amplifier, allowing fine-tuning of the output signal for calibration and sensitivity adjustment. It is capable
of measuring standard AC mains voltage levels, such as 110V or 220V RMS, and outputting a scaled
waveform that mirrors the shape of the input AC signal, typically centered around 2.5V. The sensor
supports a maximum input voltage of approximately 250V AC, while maintaining complete electrical
isolation between the high-voltage input and the low-voltage output interface.
In operation, the ZMPT101B detects the alternating voltage waveform using its internal transformer. This
waveform is stepped down and conditioned before being output as an analog signal. The waveform can
then be read by the analog-to-digital converter (ADC) of a microcontroller like the ESP32, which
processes the signal to extract voltage parameters. These include peak voltage, RMS voltage, and waveform
characteristics, which are critical for computing real-time power (P=V×IP = V \times IP=V×I)
21
system, ensuring that decisions related to automation, alerting, and energy optimization are based on
The ZMPT101B voltage sensor thus plays an indispensable role in transforming the SEMS into a truly
intelligent and data-driven system. By delivering continuous, accurate, and safe voltage measurement, it
supports advanced features such as true power computation, smart threshold detection, and appliance- level
analytics—all of which are crucial for achieving meaningful energy efficiency and user empowerment in
OUTPUT UNIT
The relay module serves as the principal output control mechanism within the Smart Energy
Management System (SEMS). It is responsible for executing the system’s automated and user-defined
commands by physically switching electrical appliances on or off. While sensors and microcontrollers
collect and process data, the relay module translates these decisions into real-world actions—making it a
A relay functions as an electrically operated switch that uses an internal electromagnetic coil to open or
close a contact within an external circuit. In this application, the relay allows the low-voltage logic
signals from the ESP32 microcontroller to safely control high-voltage alternating current (AC)
appliances. The module operates on a standard 5V DC input and can reliably switch AC loads up to
250V at 10A. For enhanced safety, the relay module incorporates an opto-isolator, which provides
complete electrical isolation between the low-voltage control side and the high-voltage switching side.
23
high-voltage circuits. Its integration supports not onlyfunctionality but also system integrity and user safety.
Display unit
The Liquid Crystal Display (LCD) is one of the most widely used visual output devices in embedded
systems. LCDs offer a simple and efficient way to present real-time information to users, including
sensor readings, system status, and alerts. They are lightweight, low-power, and easy to interface with
microcontrollers, making them highly suitable for energy monitoring, home automation, and IoT
applications.
In embedded development, the most commonly used LCD is the 16x2 alphanumeric display, which can
show two rows of sixteen characters. This module is based on the Hitachi HD44780 controller or its
equivalents and communicates with microcontrollers using either parallel (4-bit or 8-bit) or serial (I2C)
communication protocols. In this project, an I2C-based 16x2 LCD is used to minimize wiring complexity
The LCD receives character data and control instructions from the microcontroller. With the help of
libraries such as LiquidCrystal_I2C.h in the Arduino IDE, developers can easily initialize the display,
send strings or numeric values, and control cursor behavior. This abstraction simplifies implementation
LCD modules are particularly useful in projects that require local, on-site feedback, independent
of internet connectivity.
25
This ensures that users or technicians present at the device location can quickly view essential
system data without relying on mobile or cloud interfaces. It also acts as a fallback information
Functionality:
The LCD module functions as a real-time data output interface. It displays critical values obtained from
sensors and system status messages to the user. This includes numeric readings from the current and voltage
sensors, appliance states, or alerts . Its presence enhances usability by offering visual confirmation
Significance:
The inclusion of an LCD module in this project enhances user interaction and system transparency. It allows
for offline, local data visibility, which is crucial during testing, maintenance, or situations where cloud
services are temporarily unreachable. Moreover, because it requires minimal power and can be controlled
with only two microcontroller pins via I2C, it integrates efficiently with the ESP32 without significant
hardware overhead. The LCD complements the Blynk mobile interface by providing real-time, always-on
26
Fig 3.7 Ardunio Development Environment
The firmware layer of the project is developed using the Arduino Integrated Development Environment
(IDE), a widely adopted platform that simplifies the process of programming microcontrollers, including
the ESP32. The ESP32. The chosen for its built-in Wi-Fi and high- performance capabilities, integrates
seamlessly with the Arduino ecosystem through board support packages available via the Arduino Boards
Manager
Once the ESP32 board configuration is installed, the microcontroller can be programmed directly over
USB using a micro-USB cable. The Arduino IDE provides essential tools such as the Serial Monitor, which
allows for real-time debugging, sensor data inspection, and firmware behavior tracking. This built- in
interface is particularly useful during sensor calibration, control testing, and system optimization.
Firmware is written in C++, with full support for standard C/C++ syntax, while also benefiting from
standard structure beginning with the setup() function, where pin modes, communication protocols (e.g.,
I2C, UART, SPI), and wireless connections are initialized. The loop() function contains the main logic,
which runs continuously—handling sensor data acquisition from devices such as the ACS712 current
sensor and the ZMPT101B voltage sensor, evaluating conditions for automation, controlling relays, and
27
managing communication with cloud platforms.
The Arduino IDE supports a wide array of external libraries that significantly reduce development time.
establish wireless connectivity, communicate with remote databases or interfaces and simplify
integration with mobile apps or web dashboards. These libraries encapsulate low-level networking and
User Interface
Blynk is a widely adopted Internet of Things (IoT) platform designed to enable developers, engineers,
and hobbyists to create mobile and web interfaces for connected devices with minimal effort. Originally
released in 2015 by the company Blynk Inc., the platform has grown into a versatile solution for real-
time device monitoring and control across a wide range of embedded and IoT applications. It supports
development for Arduino, ESP32, ESP8266, Raspberry Pi, and other microcontroller platforms.
From a technical perspective, Blynk comprises three core components: the Blynk Mobile App, the Blynk
Cloud Server, and the Blynk Device Library. The mobile app, available on both Android and iOS, serves
as the graphical user interface (GUI) where users interact with connected devices. The cloud server
manages communication between the app and the physical hardware, while the device library, integrated
28