## 1 Introduction
While cloud and mobile solutions feature high frequency (GHz), high memory capacity (GBs), and high storage (G/T/PBs), they also have high power consumption (W/kW) and a significant impact on the environment [3]. On the other side, there are tiny, resource-restricted devices with small ML models (e.g., TinyML [4; 5]) featuring much lower operating frequencies (MHz), memory capacity (KBs) [6], storage (MBs), and power consumption (mW), being more environmental-friendly. Additionally, such a small power consumption enables battery-powered tiny devices to foster the long-term viability of such a solution. In our case, the appropriate ML algorithm would enable retrofitting devices to detect numbers displayed on the dial metering devices. Numbers and digit recognition are well-known problems in computer science usually solved by neural networks. Digit recognition tasks feature lower complexity than number recognition. Recurrent neural networks (RNNs) are often used for image-based sequence recognition tasks. However, since the RNNs are computationally more expensive in both training and inference, compared to convolutional neural networks (CNNs), their application in resource-constrained systems is limited [7]. As there are many different types of TMs, with various colors, sizes, and fonts, it would be worth having a specifically trained model for each distinct device. In order not to overwhelm the server, it would be beneficial to have CNN model training on the device itself. As devices used in embedded environments are resource-constrained, CNN models, trained and executed on them, should be minimal. Finally, to spread the \"knowledge\" across all devices and increase their accuracy in digit detection, we utilize federated learning (FL). FL is a novel ML concept particularly suitable for applications in massive IoT employing low-capability nodes [8]. The power of FL emerges from the massive engagement of nodes. Nodes are required to share a local model update on the cloud. Their models are fusioned at the central cloud location and distributed back to all nodes. Depending on the methods used, the performance of individual nodes could be enhanced (Figure 3). Recently, there has been a lot of research conducted on the intersection of the IoT and FL, as reported in several systematic reviews [9; 10; 11; 12]. In metering scenarios, FL is primarily used for consumption forecasting [13]. In our study, we employed an averaging methodology grounded in the principle of weight averaging across models. Furthermore, we adhered to the recommendations outlined in [14; 15], which suggest that the batch normalization layer in CNN models should remain unchanged during the averaging process of the other layers for each device. Figure 3: Distribution of ML models on edge devices, which provides the basis for FL. The main contributions of this work are the following. We present the design, implementation, and analysis of  
* a new SM design for the retrofitting of TMs (a fabricated prototype);
* the custom CNN optimized for the usage with resource-constrained hardware;
* CNN model training on the edge device;
* a custom pre-processing of input images to reduce complexity;
* integration of FL in the proposed solution, which enhances the generalization of our digit recognition models, thus improving overall accuracy;
* detailed energy consumption of the proposed system. The organization of this paper is structured as follows: Section 2 provides a comprehensive analysis of the related work in this field. In Section 3, we present a detailed description of the system architecture, including the design of the edge device, the overall digit recognition scheme, and our experimental setup. Section 4 covers the methodology used--digit image preprocessing, the proposed model architecture, and our approach to FL. Section 5 analyzes the results from the two evaluated test cases and compares our solution with the existing approaches.