1. Introduction
With the world population’s rapid growth, the energy demand has reached unprecedented levels [
1]. This exponential increase in energy consumption challenges traditional infrastructures, highlighting the urgent need for smart solutions that can efficiently and sustainably manage this demand. Over the past twenty years, there has been a global increase of more than 40% in energy consumption, and experts predict that the global electricity demand will rise by 25–30% by 2030 [
2].
In this context, a promising solution is offered by smart grids (SG), which are capable of efficiently integrating renewable energy sources, optimizing consumption, and improving the reliability of the energy supply. SG are vital in modernizing electrical infrastructures by incorporating advanced communication and automation technologies to manage the grid dynamically and efficiently. By enabling the seamless integration of renewable sources such as solar and wind energy, SG help to mitigate the impacts of natural fluctuations in energy generation, intelligently adjusting demand in real time [
3].
Identifying and classifying devices through smart meters allows researchers and utilities to map consumption profiles, detect the installation of new equipment or the replacement of existing equipment, and thereby anticipate increases in energy usage. This approach also enables a range of other applications, such as supply optimization, anomaly detection, and support for intelligent energy management.
Furthermore, modernization initiatives for electric grids, such as those implemented in New York and Thailand, clearly demonstrate how automation and the Internet of Things (IoT) technologies can ensure excellent reliability and efficiency within the grid. These advancements are crucial for integrating electric vehicles and supporting a cleaner, more sustainable energy future [
4]. Thus, intelligent grids become essential for developing smart cities, where we maximize energy efficiency and harness natural resources managed sustainably [
5].
An essential component for the success of SG is the accurate and real-time measurement of energy consumption. This is achieved through smart meters (SMs), devices that monitor electricity consumption in real time and transmit this information to energy suppliers. Detailed consumption monitoring is allowed by smart metering, and the implementation of more effective energy management strategies is enabled. According to [
6], integrating SMs into electrical grids allows for greater transparency in energy usage, empowering consumers to monitor their consumption and make informed decisions about their energy use. Additionally, the real-time information provided by SMs facilitates the optimization of energy distribution, reducing losses and improving the operational efficiency of energy companies [
7].
SMs also play a crucial role in adopting renewable energies and responding to demand. As highlighted in [
8], the ability to collect real-time data enables grid operators to integrate renewable energy sources more effectively, promoting a more sustainable energy transition. This interaction between technology and energy efficiency is a fundamental step toward the evolution of SG.
In smart grids, the distinction between edge and extreme edge computing is crucial for real-time data processing. Edge computing involves processing data closer to the source than centralized cloud servers, typically using devices like gateways or edge servers. In contrast, extreme edge computing pushes processing directly onto resource-constrained devices, such as microcontrollers (e.g., ESP32) or single-board computers (e.g., Raspberry Pi), minimizing latency and reducing data transmission to the cloud. This approach is particularly valuable in scenarios where real-time response and efficient energy management are critical. The IoT plays a key role in this context as IoT devices, such as smart meters, enable the collection and transmission of data for real-time analysis and decision-making.
The Artificial Intelligence Architecture in the Internet of Things for Smart Grids (IAIoSGT) is an emerging approach that integrates artificial intelligence with the IoT to optimize the performance of intelligent grids. The IAIoSGT enables the application of machine learning algorithms and artificial intelligence directly at the extreme edge, meaning on peripheral devices within the network, such as smart meters, allowing for the detection and classification of electronic devices connected to the grid.
Although the terms artificial intelligence (AI) and machine learning (ML) are often used synonymously, a distinction must be established. AI is a broad field that encompasses various techniques aimed at enabling systems to perform tasks that typically require human intelligence, such as decision-making, pattern recognition, and problem-solving. ML, in turn, is a subset of AI that focuses on developing algorithms capable of learning from data and improving their performance over time without explicit programming. In this context, ML methods are employed to enhance classification accuracy in SG environments, particularly in extreme edge applications.
Implementations at the extreme edge offer several advantages, including reduced latency and a lower need to transmit large volumes of data to central servers. These implementations are crucial for ensuring the efficiency and reliability of SG applications, especially in scenarios where real-time response is critical.
The feasibility of using machine learning algorithms for detecting and classifying electronic devices has been demonstrated in recent studies in intelligent electrical networks. In [
1], the researchers identified the need to develop specific datasets, such as signals for voltage, current, and power, to improve the accuracy of these identifications. The previous study evaluated different machine learning models and identified the most effective ones for this specific application. Building upon these findings, the current study selected KNN and MLP, considering both their classification performance and the computational cost required for deployment on extreme-edge devices. This approach suggests that integrating IoT devices with intelligent electrical networks can optimize energy consumption while addressing the challenges related to device identification.
Based on these findings, this article proposes advancing this line of research by implementing these models on devices located at the extreme edge, such as ESP32 and Raspberry Pi. The proposal aims to develop practical and scalable solutions for the extreme edge using the IAIoSGT architecture to test and validate these algorithms’ applications in a SG environment. This implementation will significantly contribute to the evolution of measurement and energy management technologies, offering greater efficiency and sustainability.
This work is organized into five sections, each addressing a specific aspect of the research.
Section 2 presents a review of the related works, highlighting the key contributions from the literature in the field of SG. This chapter provides an overview of the state of the art, identifying the gaps this work aims to fill.
Section 3 presents the proposed solution, detailing the implementation of artificial intelligence models for detecting and classifying electronic devices in SG. It describes the system architecture, data acquisition process, and methodology applied to ensure efficient operation in extreme-edge environments.
Section 4 describes the proposed IAIoSGT architecture as a solution to the identified challenges, detailing its structure, components, and functionalities. This chapter also presents the procedures and methodologies for testing and performance evaluations.
Section 5 presents the results achieved in terms of efficiency and performance, along with a discussion stemming from implementing the AI model on a real device in a test bench. Finally,
Section 6 presents the general conclusions from this work, highlighting the critical results obtained and contributions to the field of SG. It also outlines the following steps for continuing this work and expanding potential applications of the proposed architecture.
2. Related Work
Accurate energy measurement and device detection in the network are crucial for the efficiency and reliability of intelligent network architectures, especially in the context of SG and the IoT. With the exponential growth of connected devices, there is a need for advanced solutions that not only monitor and measure energy consumption but also classify and identify devices autonomously and in real time. This scenario drives the application of AI at the extreme edge of the network, where processing occurs close to the data source, reducing latencies and increasing operational efficiency.
Edge computing enables diverse applications in SG, beyond the scope of energy monitoring and device classification. For example, ref. [
9] explores edge-based solutions to enhance SG functionalities, illustrating the technology’s broad potential. However, the present study specifically focuses on deploying machine learning algorithms at the extreme edge to classify electronic devices based on their energy consumption patterns, contributing to efficient energy management in SG.
The detection and classification of electronic devices play a crucial role in SG. Various research studies have addressed different aspects, from data collection to selecting the appropriate resolution for measurements and identifying the most relevant electrical parameters. Furthermore, different data preprocessing and artificial intelligence techniques are explored. The studies in this field date back to the 1980s when George W Hart, at the Massachusetts Institute of Technology (MIT), introduced the term non-intrusive load monitoring (NILM). His pioneering work demonstrated that it is possible to distinguish household appliances based on the measurement of active and reactive power during the moments of turning on and off equipment, taking into account the different complex impedances associated with each device [
10,
11].
Identification methods are addressed in several studies, such as in [
12], where systems are trained to effectively identify low-voltage electrical loads in data centers (DC) and simultaneously detect whether they are in a steady state. The model approach combines two machine learning techniques: unsupervised k-means clustering and supervised K-Nearest Neighbor (KNN) classification techniques [
13], dealing with classification through information retrieved from power load signatures and harmonic characteristics.
Several recent studies demonstrate the effectiveness of artificial intelligence in monitoring and identifying electronic devices using advanced machine learning techniques. For example, residual convolutional neural networks (ResNet), which utilize residual connections to enable efficient learning in deep networks, have been used to enhance device recognition in non-intrusive load identification scenarios, achieving high performance in distinguishing different electrical devices based on their energy consumption patterns [
14]. The residual connections allow the network to learn the difference (or “residue”) between the input and output of a layer, helping the network to avoid the vanishing gradient problem and enabling the training of deeper networks to learn complex energy consumption patterns, even with noisy data.
Furthermore, efficient hybrid models have been developed for the classification of electrical devices, exploiting features extracted from consumption time series. These models combine different learning techniques, such as convolutional neural networks (which capture temporal patterns), with other supervised learning techniques, such as support vector machines or decision trees, to improve accuracy and reduce computational complexity [
15]. The advantage of hybrid models is that they can combine the strengths of different approaches, allowing the system to benefit from various characteristics of the consumption data, thus increasing classification efficiency.
Another relevant approach is the use of siamese neural networks for detecting unidentified devices in non-intrusive load monitoring systems. Siamese networks use two identical networks that share weights and parameters and are trained to compare inputs and measure the similarity between them. This architecture allows the system to identify new devices by comparing energy consumption patterns with those of known devices [
16]. Even without pre-existing examples of unidentified devices, the network can determine if a new device has a consumption behavior similar to that of an already registered appliance. This facilitates the detection of new devices without the need for a large labeled dataset.
These studies demonstrate the potential of AI algorithms in analyzing energy consumption patterns, making them essential tools for the accurate and efficient identification of electrical devices in both domestic and industrial environments.
An emerging area with great promise is the application of AI at the extreme edge of the network, where data processing is performed directly on edge devices for intelligent networks. In [
17], the work’s main objective is to estimate individual devices’ energy consumption using a smart meter and operating with a low sampling rate. A combination of one-dimensional convolutional neural networks (1D-CNNs) and LSTM is employed by the model to extract features capable of recognizing active devices and estimating their energy consumption based on aggregated energy data from the residence. The developed algorithm is executed directly on the ESP32 microcontroller using the TensorFlow library.
Furthermore, the implementation of machine learning algorithms on extreme-edge devices has been successfully explored in other domains. For instance, ref. [
18] analyzes the performance of the ESP32’s Xtensa LX6 processor for neural network applications in the context of TinyML, demonstrating the device’s ability to efficiently execute complex models despite computational constraints. Similarly, ref. [
19] proposes an IoT solution for healthcare monitoring using the ESP32 with machine learning models, highlighting the feasibility of real-time classifications on low-cost hardware. These approaches reinforce the relevance of devices like the ESP32 for IoT applications requiring local processing, as in the SG context proposed in this work.
Some works, such as [
20], develop an intelligent consumption measurement system on the demand side (Demand-Side Management (DSM)). The system aims to optimize energy consumption, allowing efficient demand management and reducing user energy costs. AI implementation is carried out on the Arduino Mega 2560 microcontroller to process data locally, enabling real-time event detection and response, minimizing the need for transmitting large volumes of data to the cloud, and consequently improving system efficiency.
A comprehensive review of AI techniques applied to SG is provided by [
21], emphasizing how AI has been utilized to enhance demand forecasting, optimize energy distribution, and improve fault detection. The authors highlight that the integration of AI into energy systems results in more reliable and efficient operations, aligning with the objectives of the present study, in which machine learning models are applied to optimize the management and security of SG.
In [
22], a machine-learning-based approach for fraud detection in SG is presented, employing time-series classifiers applied to data collected from IEDs. The effectiveness of these techniques in identifying non-technical losses, such as illegal connections and measurement errors, is demonstrated. In general, the field of SG with embedded IoT and AI encompasses a broad research domain, with multiple approaches and solutions addressing specific challenges. Unlike the focus on fraud detection, the proposed work applies machine learning at the extreme edge to classify and identify electronic devices connected to the power grid, considering the computational constraints of embedded devices such as ESP32 and Raspberry Pi. This approach contributes to advancing energy reliability by enabling real-time analysis and monitoring directly on edge devices, eliminating the need for centralized cloud processing.
3. Description of the Proposed Solution
This work is an extension of the study titled “Analysis of Electrical Signals by Machine Learning for Classification of Individualized Electronics on the Internet of Smart Grid Things (IoSGT) Architecture”, by Marques et al. [
1]. This study explores the application of machine learning techniques for identifying and classifying electronic devices connected to an intelligent grid. The importance of creating a dataset that includes fundamental sinusoidal signals, such as voltage, current, and power, is emphasized to enhance the accuracy of device identification. Building upon the preliminary evaluations and validations established in that study, the present work aims to deepen the analysis and classification of electronic devices directly on extreme-edge devices.
3.1. System Architecture
The IAIoSGT (Artificial Intelligence in the IoSGT) architecture was used as the basis for the development of the proposed solution, which integrates machine learning and artificial intelligence in an edge–cloud environment. The architecture features an extreme-edge layer, where devices such as the ESP32-S3 general-purpose development board (Espressif Systems, Shanghai, China) and Raspberry Pi 3 Model B+ (Raspberry Pi Foundation, Cambridge, United Kingdom) perform device classification using machine learning models (MLP and KNN).
The data flow begins with voltage and current signals being captured by the smart meter, which sends the raw data via Message Queuing Telemetry Transport (MQTT) to the cloud. In the cloud, the data undergo preprocessing and are stored, serving as input for training the MLP and KNN models. These trained models are then deployed onto the extreme-edge devices.
MQTT is a communication protocol for the IoT that follows the asynchronous publish/subscribe model, enabling efficient message exchange between connected devices. It has a low overhead, meaning it adds only a minimal amount of extra data to messages for communication control, optimizing bandwidth usage. Designed to be extremely lightweight, MQTT works well for resource-constrained devices and low-bandwidth networks, ensuring efficient and reliable transmission. This characteristic makes MQTT an excellent choice for various applications, including monitoring systems, industrial automation, smart homes, and energy consumption meters.
For the Raspberry Pi 3B+, the classification process leverages the pre-trained MLP and KNN models, reducing the local processing load and ensuring consistency in the use of training data. On the ESP32, the KNN is implemented using the ArduinoKNN library, with weights configured locally at each initialization. However, periodic synchronization with the cloud ensures the retrieval of preprocessed data necessary for classification.
In our experimental setup, the latency for transmitting raw data from the ESP32 to the edge–cloud via MQTT was measured to be approximately 110,164 ms under typical network conditions. However, this latency does not impact the real-time performance of the proposed system as the MLP and KNN models are executed locally on the extreme-edge devices (ESP32 and Raspberry Pi 3B+), enabling device classification independently of the network. Data transmission to the cloud is primarily utilized for asynchronous training and periodic synchronization of preprocessed data, which can be scheduled during low-usage periods (e.g., overnight) to ensure minimal interference with operational efficiency, even in scenarios of high latency. This design enhances the system’s robustness and scalability for SG applications.
Figure 1,
Figure 2 and
Figure 3 illustrate the complete data flow, from the collection at the smart meter to the classification phase on the extreme-edge devices.
The communication between the smart meter and the data acquisition module uses the MQTT protocol, enabling efficient data transmission to the cloud, as illustrated in
Figure 1. This network connectivity is established through a layered architecture where edge devices connect to the cloud infrastructure as detailed in our IAIoSGT architecture.
Figure 3 specifically demonstrates how trained models are deployed to extreme-edge devices, ensuring that the processed data stored in the cloud can be utilized for model training and subsequent deployment while maintaining computational efficiency at the edge.
6. Conclusions and Future Work
When the KNN and MLP algorithms were analyzed on limited hardware, it was found that the normalization process was crucial to achieving high performance when using the MLP, reaching 100% accuracy with an average prediction time of approximately 0.31 milliseconds. However, to use MLP on a device such as the ESP32, it will be necessary to perform data normalization before inserting it into the network, which consumes processing resources. This may be a limitation in applications that require real-time responses.
When analyzing the performance of the KNN algorithm, it showed better performance with non-normalized data, achieving up to 96.23% accuracy for k = 1. This information is relevant because it eliminates the need for data preprocessing, saving execution time and microcontroller processing in a real application. However, KNN requires storing the entire training dataset in memory, in addition to the test data, which may be unfeasible on devices with limited memory, such as the ESP32. In the specific case of this article, it was necessary to reduce the dataset to make the implementation viable.
Thus, we can observe that there is a trade-off between processing and memory when implementing these algorithms. Although additional processing for normalization is required by the MLP, a compact model that occupies less memory resulted, which is more suitable when memory is a critical resource. KNN, on the other hand, by avoiding the cost of normalization, demands more memory to store training and test data, which may not be the best choice in systems with storage constraints.
Based on the experiments, it was possible to verify that KNN obtained better results on the Raspberry Pi, standing out in accuracy and inference time. The MLP, in turn, presented similar accuracy on both hardware platforms (Raspberry Pi and ESP32) but with a slight advantage on the ESP32 when using non-normalized data. However, the main difference observed between the two devices was in the inference time.
Although the Raspberry Pi has more powerful hardware in terms of processing and memory, its inference times are significantly higher than those of the ESP32 due to the operating system overhead. The Raspberry Pi runs a Linux-based system, such as Raspbian, which manages multiple processes simultaneously, consuming resources and introducing latency. In contrast, the ESP32 runs bare-metal firmware, allowing model inference to take top priority without significant resource competition.
Additionally, the choice in programming language directly impacts performance. On the Raspberry Pi, inference runs in Python, an interpreted language that adds execution overhead since it dynamically translates each instruction into machine code. In contrast, the ESP32 operates in C or C++, compiled languages that generate optimized code for direct hardware execution, eliminating interpretation overhead and making inference far more efficient.
Finally, resource management plays a crucial role. The Raspberry Pi runs multiple processes simultaneously, sharing the CPU and memory with other system tasks, which can cause inference delays. On the ESP32, execution is exclusively dedicated to inference, ensuring more predictable and efficient performance. Therefore, despite the Raspberry Pi’s greater processing power, selecting the right platform and execution environment is key to optimizing performance for embedded and IoT applications.
To enable large-scale implementation within an SG, the proposed approach can be integrated into the IAIoSGT architecture, in which AI and SM are combined to optimize the performance of the power grid. In this structure, inference is performed locally by extreme-edge devices, such as the ESP32, and only essential information is sent to network edge or cloud servers, reducing latency and communication load. Additionally, scalability and computational efficiency are improved by adopting a hybrid model, in which lightweight algorithms are used on embedded devices, while more robust models are employed at the network edge. Through this strategy, real-time detection of consumption patterns, identification of connected devices, and optimization of energy distribution are enabled, ensuring a more efficient and resilient operation of the SG, even in scenarios with connectivity and computational capacity constraints.