On-Device Federated Learning for Energy-Efficient Smart Irrigation
Abstract
1. Introduction
- Development of a fully functional on-device FL framework designed for microcontroller-class devices, enabling collaborative learning across heterogeneous, non-IID datasets under stringent hardware constraints.
- Comprehensive evaluation of trade-offs between model accuracy, latency, and energy efficiency by comparing constrained devices with standard computing platforms under identical FL configurations.
- In-depth discussion of key system-level aspects—including energy management, communication efficiency, and data privacy—that influence the deployment of FL in energy-limited smart-agriculture environments.
2. State of the Art
3. System Design and Methodology
3.1. Overview of FL Framework
- Central Server: The central server coordinates the training process by broadcasting the global model to all clients at the start of each communication round. It collects the locally trained model updates from clients and aggregates them to form a new global model.
- Client Devices: The STM32F722ZE MCUs act as the client devices in our setup. Each client trains the global model locally on its respective soil type-specific dataset for 50 epochs. The model updates, rather than raw data, are sent back to the server for aggregation. Although only 7 clients were used, each corresponds to a distinct soil type in the dataset. Since soil heterogeneity is the key source of non-IID distribution in SA, this setup captures the critical challenge of FL in this domain. The focus of this work is on proving feasibility under realistic constraints, while scalability to larger client populations will be addressed in future deployments.
- Federated Averaging (FedAvg): The model aggregation method used in this framework is FedAvg. In each communication round, after the clients complete their local training, the server aggregates the model updates using FedAvg. The aggregation process computes a weighted average of the local models based on the amount of data processed by each client, resulting in an updated global model that is broadcast to all clients for the next round of training [28].
- Communication Protocol: The communication between the server and clients is handled via the MQTT protocol. MQTT was chosen due to its lightweight, bandwidth-efficient nature, which is ideal for resource-constrained environments, ensuring minimal data transfer and efficient model updates [29].
- Training Procedure: The training process is carried out in synchronous rounds, with each round involving the distribution of the current global model from the server to the clients, followed by local model training on the clients’ respective datasets. The updated models are sent back to the server, where they are aggregated to form the new global model. This process is repeated for 3 communication rounds, ensuring iterative improvements to the global model.
3.2. Model Architecture and Training Configuration
- Feature set: each client receives input vectors consisting of 3 normalized continuous features (moisture index (MOI), temperature, and humidity) together with categorical variables (soil type, seedling stage, crop type) represented using one-hot encoding. If the number of soil types is denoted as S, seedling stages as G, and crop types as C, the total input dimensionality is defined as:where the term 3 corresponds to the continuous features (MOI, temperature, humidity).
- Network architecture: the MLP structure used in the experiments is as follows:
- –
- Input:
- –
- Dense (64 units, ReLU)
- –
- Dense (32 units, ReLU)
- –
- Output (1 unit, Sigmoid; binary classification: irrigation required/not required)
The total number of parameters can be expressed as:For a typical case with soil types, the model requires approximately 3.6 k parameters, corresponding to ≈14.6 KB in FP32 precision. Peak SRAM usage during training (weights, activations, gradients, and batch buffers) remains below 50 KB, ensuring feasibility on the STM32F722ZE, which provides 256 KB SRAM. - Training configuration: each client trains locally for 50 epochs per round using stochastic gradient descent (SGD) with momentum 0.9, a learning rate of 0.01 (step decay after epoch 35), binary cross-entropy loss, and a batch size of 32 (fallback to 16 if memory-constrained). Dropout with rate 0.1 is applied in both hidden layers during training. Gradient clipping is applied with a maximum norm of 1.0 to improve stability under constrained precision.
- Federated setup: the FL experiment involves 7 clients (soil types) participating in 3 synchronous rounds. Updates are aggregated on the server using the FedAvg algorithm, weighted by the number of samples per client. Model updates consist of ∼14–16 KB of weights per client per round, transmitted via MQTT.
- Embedded considerations: the model was compiled using GCC with -O3 and -ffast-math, and optimized using CMSIS-DSP for efficient FP32 operations. Activations are implemented with branchless functions (ReLU clamp, fast sigmoid approximation). Training buffers are stored in SRAM, while model weights are placed in Flash. GPIO toggling was used to measure inference latency with an oscilloscope.Figure 1 illustrates the proposed MLP model architecture, highlighting the flow from input features through hidden layers to the binary irrigation decision.
3.3. Hardware
3.4. Dataset Overview and Preprocessing
- crop ID: Unique identifier for each crop (categorical).
- crop type: Category of the crop (e.g., Rice, Maize, Wheat).
- soil type: Type of soil (e.g., Black Soil, Red Soil).
- seedling stage: Growth phase of the crop (e.g., Germination).
- MOI (Moisture Index): Soil moisture level (integer).
- temp (Temperature): Ambient temperature in °C (integer).
- humidity: Relative humidity percentage (float).
- result: Target variable for irrigation need (binary in our study: 0 = no irrigation, 1 = irrigation required).
- normalization: Continuous features (temperature, humidity, and MOI) were normalized to ensure uniform scale and enhance model performance.
- one-hot Encoding: Categorical variables (soil type and seedling stage) were transformed using one-hot encoding to make them suitable for training.
- Data remained non-overlapping across rounds,
- Each client trained on soil- and crop-specific local data, and
- The global FL model integrated knowledge from diverse and heterogeneous conditions.
3.5. Networking and Communication Setup
- Connectivity: each STM32F722ZE board was connected via UART to an ESP8266 Wi-Fi module.
- TCP/IP stack: the ESP8266 handled the full TCP/IP stack and Wi-Fi communication, while the STM32 exchanged data with it using AT commands.
- MQTT protocol: communication was established using the MQTT protocol over TCP/IP.
- Broker: a public MQTT broker (broker.hivemq.com, accessed on 18 March 2025, port 1883) was used for message exchange.
- Security: the chosen setup relied on an unencrypted and unauthenticated channel, meaning confidentiality and integrity of model updates were not ensured.
- Energy accounting: communication energy consumption was not included in the reported measurements.
3.6. MQTT Communication Setup
3.6.1. MQTT Configuration
- Broker: the MQTT broker chosen for this setup is broker.hivemq.com, a public MQTT broker that supports lightweight, scalable communication. It was used to enable message exchange between the server and clients.MQTT_BROKER = ‘‘broker.hivemq.com’’
- Port: the default MQTT port 1883 was used for unencrypted communication.MQTT_PORT = 1883
- Topics: MQTT topics were used to organize the messages exchanged between the server and clients:
- –
- fl/clients: a topic where the clients publish model updates to be collected by the server.
- –
- fl/server: a topic used by the server to broadcast the global model to all clients for local training.
MQTT_TOPIC_CLIENTS = ‘‘fl/clients’’MQTT_TOPIC_SERVER = ‘‘fl/server’’
3.6.2. Client-Server Communication Flow
- Global Model Distribution: the central server publishes the global model to the fl/server topic at the beginning of each round. All STM32F722ZE clients subscribe to this topic to download the updated model for local training.
- Local Model Updates: after completing local training, each client publishes its model update to the fl/clients topic. The server collects these updates from all clients for aggregation.
- Model Aggregation and Next Round: the server aggregates the model updates using the FedAvg algorithm and broadcasts the updated global model back to the clients for the next round of local training.
4. Federated Training Implementation
| Algorithm 1 FL Process on STM32F722ZE MCUs |
|
5. Evaluation Methodology
Energy Latency Accuracy Index (ELAI)
- Functional form: We model efficiency as (benefit per unit cost) by placing accuracy in the numerator and a weighted sum of normalized energy and latency in the denominator:This ratio has a direct interpretation: ELAI increases when accuracy rises or when costs fall, and the relative influence of energy versus latency is controlled by the weights and . For robustness, we also verified that the device ranking remains qualitatively the same when using alternative formulations such as a weighted geometric index or a weighted additive score.
- Weighting and sensitivity: In energy-limited deployments such as battery-powered or energy-harvesting smart irrigation systems, we assign higher importance to energy () than to latency (). We additionally varied within and jointly scaled to test sensitivity. In all tested cases, the MCU consistently achieved higher efficiency than the PC, showing that the relative advantage is robust to weight selection.
6. Experimental Results and Discussion
6.1. FL in Smart Irrigation
6.2. Evaluation Across Heterogeneous Soil Types
6.3. Server-Level Performance
6.4. Inference Latency
6.5. Inference and Training Energy
6.6. ELAI Analysis
6.7. Discussion
7. Conclusions and Future Work
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Banbury, C.R.; Reddi, V.J.; Lam, M.; Fu, W.; Fazel, A.; Holleman, J.; Huang, X.; Hurtado, R.; Kanter, D.; Lokhmotov, A.; et al. Benchmarking TinyML Systems: Challenges and Direction. arXiv 2021, arXiv:2003.04821. [Google Scholar] [CrossRef] [Scilit]
- Dakhia, Z.; Russo, M.; Merenda, M. AI-Enabled IoT for Food Computing: Challenges, Opportunities, and Future Directions. Sensors 2025, 25, 2147. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Sakr, F.; Bellotti, F.; Berta, R.; De Gloria, A. Machine Learning on Mainstream Microcontrollers. Sensors 2020, 20, 2638. [Google Scholar] [CrossRef] [Scilit]
- Ravaglia, L.; Rusci, M.; Nadalini, D.; Capotondi, A.; Conti, F.; Benini, L. A TinyML Platform for On-Device Continual Learning with Quantized Latent Replays. IEEE J. Emerg. Sel. Top. Circuits Syst. 2021, 11, 789–802. [Google Scholar] [CrossRef] [Scilit]
- Merenda, M.; Astrologo, M.; Laurendi, D.; Romeo, V.; Della Corte, F.G. A novel fitness tracker using edge machine learning. In Proceedings of the 2020 IEEE 20th Mediterranean Electrotechnical Conference (MELECON), Palermo, Italy, 16–18 June 2020; pp. 212–215. [Google Scholar]
- Ren, H.; Anicic, D.; Runkler, T. TinyOL: TinyML with Online-Learning on Microcontrollers. arXiv 2021, arXiv:2103.08295. [Google Scholar]
- Yang, Q.; Liu, Y.; Chen, T.; Tong, Y. Federated Machine Learning: Concept and Applications. ACM Trans. Intell. Syst. Technol. 2019, 10, 1–19. [Google Scholar] [CrossRef] [Scilit]
- Brisimi, T.S.; Chen, R.; Mela, T.; Olshevsky, A.; Paschalidis, I.C.; Shi, W. Federated learning of predictive models from federated electronic health records. Int. J. Med. Inform. 2018, 112, 59–67. [Google Scholar] [CrossRef] [Scilit]
- Awosika, T.; Shukla, R.M.; Pranggono, B. Transparency and privacy: The role of explainable AI and federated learning in financial fraud detection. IEEE Access 2024, 12, 64551–64560. [Google Scholar] [CrossRef] [Scilit]
- Hard, A.; Rao, K.; Mathews, R.; Ramaswamy, S.; Beaufays, F.; Augenstein, S.; Eichner, H.; Kiddon, C.; Ramage, D. Federated learning for mobile keyboard prediction. arXiv 2018, arXiv:1811.03604. [Google Scholar]
- Mwawado, R.; Zennaro, M.; Nsenga, J.; Hanyurwimfura, D. Optimizing Soil-Based Crop Recommendations with Federated Learning on Raspberry Pi Edge Computing Nodes. In Proceedings of the 2024 11th International Conference on Internet of Things: Systems, Management and Security (IOTSMS), Malmö, Sweden, 2–5 September 2024; IEEE: Piscataway, NJ, USA, 2024; pp. 82–89. [Google Scholar]
- Dakhia, Z.; Merenda, M. Client Selection in Federated Learning on Resource-Constrained Devices: A Game Theory Approach. Appl. Sci. 2025, 15, 7556. [Google Scholar] [CrossRef] [Scilit]
- Merenda, M.; Cimino, G.; Carotenuto, R.; Corte, F.G.D.; Iero, D. Edge machine learning techniques applied to RFID for device-free hand gesture recognition. IEEE J. Radio Freq. Identif. 2022, 6, 564–572. [Google Scholar] [CrossRef] [Scilit]
- Martinez, F.; Romaine, J.B.; Johnson, P.; Cardona, A.; Millan, P. Novel Fusion Technique for High-Performance Automated Crop Edge Detection in Smart Agriculture. IEEE Access 2025, 13, 22429–22445. [Google Scholar] [CrossRef] [Scilit]
- Desikan, J.; Singh, S.K.; Jayanthiladevi, A.; Singh, S.; Yoon, B. Dempster Shafer-Empowered Machine Learning-Based Scheme for Reducing Fire Risks in IoT-Enabled Industrial Environments. IEEE Access 2015, 13, 46546–46567. [Google Scholar] [CrossRef] [Scilit]
- Dritsas, E.; Trigka, M. Federated Learning for IoT: A Survey of Techniques, Challenges, and Applications. J. Sens. Actuator Netw. 2025, 14, 9. [Google Scholar] [CrossRef] [Scilit]
- Li, T.; Sahu, A.K.; Talwalkar, A.; Smith, V. Federated learning: Challenges, methods, and future directions. IEEE Signal Process. Mag. 2020, 37, 50–60. [Google Scholar] [CrossRef] [Scilit]
- Bonawitz, K.; Eichner, H.; Grieskamp, W.; Huba, D.; Ingerman, A.; Ivanov, V.; Kiddon, C.; Konečný, J.; Mazzocchi, S.; McMahan, B.; et al. Towards federated learning at scale: System design. In Proceedings of the 2nd SysML Conference, Palo Alto, CA, USA, 2–4 April 2019. [Google Scholar]
- Sikiru, I.A.; Kora, A.D.; Ezin, E.C.; Imoize, A.L.; Li, C.-T. Hybridization of learning techniques and quantum mechanism for IIoT security: Applications, challenges, and prospects. Electronics 2024, 13, 4153. [Google Scholar] [CrossRef] [Scilit]
- Wu, J.; Drew, S.; Zhou, J. FedLE: Federated Learning Client Selection with Lifespan Extension for Edge IoT Networks. In Proceedings of the IEEE International Conference on Communications, Rome, Italy, 28 May–1 June 2023. [Google Scholar]
- Valente da Silva, R.; López, O.L.A.; Souza, R.D. Federated Learning–Distillation Alternation for Resource-Constrained IoT. arXiv 2025, arXiv:2505.20456. [Google Scholar]
- Fedorov, I.; Adams, R.P.; Mattina, M.; Whatmough, P. SpArSe: Sparse Architecture Search for CNNs on Resource-Constrained Microcontrollers. arXiv 2019, 4978–4990. [Google Scholar]
- Disabato, S.; Roveri, M. Incremental On-Device Tiny Machine Learning. In Proceedings of the 18th ACM Conference on Embedded Networked Sensor Systems, Virtual, 16–19 November 2020; pp. 7–13. [Google Scholar]
- Kopparapu, K.; Lin, E. TinyFedTL: Federated Transfer Learning on Tiny Devices. arXiv 2021, arXiv:2110.01107. [Google Scholar]
- Mathur, A.; Beutel, D.J.; de Gusmão, P.P.B.; Fernandez-Marques, J.; Topal, T.; Qiu, X.; Parcollet, T.; Gao, Y.; Lane, N.D. On-device Federated Learning with Flower. arXiv 2021, arXiv:2104.03042. [Google Scholar] [CrossRef] [Scilit]
- Deng, Z.; Sun, R.; Xue, M.; Wen, S.; Camtepe, S.; Nepal, S.; Xiang, Y. Leakage-Resilient and Carbon-Neutral Aggregation Featuring the Federated AI-Enabled Critical Infrastructure. arXiv 2024. [Google Scholar] [CrossRef] [Scilit]
- STMicroelectronics, “STM32F722ZE Microcontroller.” [Online]. Available online: https://www.st.com/en/microcontrollers-microprocessors/stm32f722ze.html (accessed on 17 September 2025).
- McMahan, B.; Moore, E.; Ramage, D.; Hampson, S.; Arcas, B.A.Y. Communication-Efficient Learning of Deep Networks from Decentralized Data. In Proceedings of the 20thInternational Conference Artificial Intelligence and Statistics (AISTATS), Lauderdale, FL, USA, 20–22 April 2017; pp. 1273–1282. [Google Scholar]
- Guo, H., Jr.; Lin, T.; Hsia, K.-H. Web-based IoT and Robot SCADA using MQTT protocol. J. Robot. Netw. Artif. Life 2022, 9, 202–208. [Google Scholar]
- Gopidesi, C. Smart Agriculture Dataset, Kaggle, 2021. Available online: https://www.kaggle.com/datasets/chaitanyagopidesi/smart-agriculture-dataset (accessed on 16 January 2025).
- Ap, H.; Kulothungan, K. Secure-MQTT: An efficient fuzzy logic-based approach to detect DoS attack in MQTT protocol for Internet of Things. EURASIP J. Wirel. Commun. Netw. 2019, 2019, 90. [Google Scholar]






| Study | Device Type | Training Strategy | Evaluation Method | Key Limitations |
|---|---|---|---|---|
| Bonawitz et al. [18] | Smartphones (Android) | On-device FL | Simulated tests | Stable power and memory; unsuitable for constrained MCUs |
| Mwawado et al. [11] | Raspberry Pi 3 | On-device FL | Real-world field tests | Devices more powerful than typical MCUs |
| Sikiru et al. [19] | Simulated IoT nodes | Simulated FL | Simulation only | No deployment on real MCUs |
| Wu et al. [20] | IoT edge devices | Energy-aware FL client selection | Simulation-based evaluation | No deployment on constrained MCUs; partial energy model only |
| Valente da Silva et al. [21] | IoT edge devices | Federated distillation alternation | Simulation tests | No full on-device training; assumes high-end IoT boards |
| Disabato & Roveri [23] | STM32F7, Raspberry Pi | Incremental learning with transfer learning | Benchmark datasets | Relies on pre-trained models; partial training only |
| Kopparapu et al. [24] | Arduino Nano 33 BLE Sense | Federated Transfer Learning | Simulation + latency evaluation | Only final layers trained; no full model training |
| Mathur et al. [25] | Raspberry Pi, Jetson Nano | Full on-device FL | Flower framework experiments | High-end edge devices; not representative of constrained MCUs |
| Deng et al. [26] | Critical infrastructure | Privacy- and energy-aware aggregation | Simulated and analytic | Designed for large-scale systems; not embedded environments |
| This work | STM32F722ZE MCU | Full on-device FL | Real-world deployment with MQTT | Small-scale (7 clients, 3 rounds) feasibility study; realistic embedded setup. |
| Specification | Details |
|---|---|
| Core | ARM Cortex-M7 32-bit RISC processor |
| Clock Speed | Up to 216 MHz |
| Flash Memory | 512 KB |
| SRAM | 256 KB |
| Floating Point Unit (FPU) | Single-precision |
| Operating Voltage | 1.7 V to 3.6 V |
| Power Consumption (RUN mode) | ≈90 mA at 3.3 V |
| Communication Interfaces | SPI, UART, I2C, USB OTG, MQTT |
| GPIO | Used for timing measurements |
| Parameter | Description/Value |
|---|---|
| Optimizer | Adam |
| Learning rate () | 0.001 |
| Batch size | 8 (limited by 276 KB RAM) |
| Local epochs per round | 50 |
| Number of FL rounds | 3 |
| Wall-clock time per round | On the order of a few minutes (including local training and aggregation) |
| Weight representation | Fixed-point (quantized) to reduce memory usage |
| MQTT payload size | 512 bytes |
| Retry policy | Reliability handled through MQTT QoS 1 acknowledgment mechanism |
| Broker QoS level | 1 (at-least-once delivery) |
| Client (Soil Type) | PC Accuracy (%) | MCU Accuracy (%) |
|---|---|---|
| 1 | 82.40 | 70.98 |
| 2 | 82.02 | 81.22 |
| 3 | 80.10 | 74.87 |
| 4 | 84.07 | 80.34 |
| 5 | 83.46 | 80.43 |
| 6 | 84.89 | 82.30 |
| 7 | 82.45 | 80.43 |
| Round | PC Setup (%) | MCU Setup (%) |
|---|---|---|
| 1 | 59 | 57 |
| 2 | 87 | 83 |
| 3 | 92 | 90 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Dakhia, Z.; Lazzaro, A.; Sebti, M.R.; Russo, M.; Merenda, M. On-Device Federated Learning for Energy-Efficient Smart Irrigation. Electronics 2025, 14, 4311. https://doi.org/10.3390/electronics14214311
Dakhia Z, Lazzaro A, Sebti MR, Russo M, Merenda M. On-Device Federated Learning for Energy-Efficient Smart Irrigation. Electronics. 2025; 14(21):4311. https://doi.org/10.3390/electronics14214311
Chicago/Turabian StyleDakhia, Zohra, Alessia Lazzaro, Mohamed Riad Sebti, Mariateresa Russo, and Massimo Merenda. 2025. "On-Device Federated Learning for Energy-Efficient Smart Irrigation" Electronics 14, no. 21: 4311. https://doi.org/10.3390/electronics14214311
APA StyleDakhia, Z., Lazzaro, A., Sebti, M. R., Russo, M., & Merenda, M. (2025). On-Device Federated Learning for Energy-Efficient Smart Irrigation. Electronics, 14(21), 4311. https://doi.org/10.3390/electronics14214311

