Smart-Home Sensor Self-Calibration System Based on Robust Regression and Online Anomaly Detection
DOI:
https://doi.org/10.31649/1997-9266-2026-186-3-99-109Keywords:
smart home, sensor self-calibration, robust regression, HuberRegressor, mean absolute error, median absolute deviation, anomaly detection, MQTT, FastAPI, PostgreSQL, Grafana, programming, databaseAbstract
The paper examines a smart-home sensor self-calibration platform implemented as an external Python service for local Internet of Things (IoT) infrastructures. The relevance of the study is determined by the fact that drift and systematic bias of low-cost temperature and humidity sensors directly affect indoor climate monitoring, the correctness of automated heating and ventilation scenarios, and the overall energy efficiency of residential environments. At the software level, the study reconstructs a complete processing pipeline that covers data ingestion through a REST API, MQTT or a built-in simulator, persistence in PostgreSQL, periodic retraining of the calibration model, correction of incoming measurements, online anomaly detection, and subsequent visualization through a web dashboard and Grafana. The methodological novelty of the solution lies in combining time alignment of “raw sensor – reference sensor” pairs, robust affine correction with HuberRegressor, a model acceptance rule based on reducing mean absolute error (MAE) by at least 2%, and anomaly scoring based on median absolute deviation (MAD) with a fallback z-score procedure. The study shows that the algorithm does not merely train a correction model; it can also safely refuse to apply calibration when the model quality is insufficient or when the amount of training data is inadequate. An experiment performed on the built-in simulator, which models four rooms, 20 sensors and 4,800 measurements, demonstrated a strong error reduction for temperature channels: after the initial calibration stage, the average MAE decreased from 1.56 to 0.31 °C. For humidity channels, the effect was more moderate, with the average error decreasing from 1.44 to 1.34 % RH. In the final online window after a series of retraining cycles, the mean MAE reduction across all paired channels reached 30.4 %; specifically, temperature sensors achieved a 42.3% improvement, whereas humidity sensors achieved a 14.5 % improvement. Additional verification on the archived SQLite database bundled with the project confirmed a strong effect for the living-room temperature sensor (1.789 → 0.162) and a moderate effect for the humidity channel (0.611 → 0.588). The practical significance of the proposed approach lies in the fact that it can be integrated into the existing local smart-home infrastructure without modifying the firmware of end devices, thereby improving telemetry reliability, reducing false automation triggers, and creating prerequisites for energy savings in home automation systems. Beyond its technical effect, the proposed solution also has clear applied socio-economic significance, since it makes it possible to improve the performance of low-cost sensors by software means without switching to more expensive hardware. This can substantially simplify everyday use for people relying on affordable smart-home systems, make such systems more accessible to a wider range of consumers, and, in the long term, contribute to reducing their overall cost both at the deployment stage and during further operation.
References
K. Yamamoto, T. Togami, N. Yamaguchi, and S. Ninomiya, “Machine Learning-Based Calibration of Low-Cost Air Temperature Sensors Using Environmental Data,” Sensors, vol. 17, no. 6, article 1290, 2017. https://doi.org/10.3390/s17061290 .
R. Dubey, A. Telles, J. Nikkel, et al., “Low-Cost CO2 NDIR Sensors: Performance Evaluation and Calibration Using Machine Learning Techniques,” Sensors, vol. 24, no. 17, article 5675, 2024. https://doi.org/10.3390/s24175675 .
M. Taştan, “Machine Learning-Based Calibration and Performance Evaluation of Low-Cost Internet of Things Air Quality Sensors,” Sensors, vol. 25, no. 10, article 3183, 2025. https://doi.org/10.3390/s25103183 .
K. DeMedeiros, A. Hendawi, and M. Alvarez, “A Survey of AI-Based Anomaly Detection in IoT and Sensor Networks,” Sensors, vol. 23, no. 3, article 1352, 2023. https://doi.org/10.3390/s23031352 .
C. Leys, C. Ley, O. Klein, P. Bernard, and L. Licata, “Detecting outliers: Do not use standard deviation around the mean, use absolute deviation around the median,” Journal of Experimental Social Psychology, vol. 49, no. 4. pp. 764-766, 2013. https://doi.org/10.1016/j.jesp.2013.03.013 .
OASIS. MQTT Version 5.0. OASIS Standard, 07 March 2019. [Online]. Available: https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html . Accessed: March 17, 2026.
Home Assistant. MQTT integration documentation. [Online]. Available: https://www.home-assistant.io/integrations/mqtt/ . Accessed: February 14, 2026.
Scikit-learn developers. HuberRegressor – official API reference. [Online]. Available: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.HuberRegressor.html. Accessed: February 14, 2026.
FastAPI. Official documentation. [Online]. Available: https://fastapi.tiangolo.com/. Accessed: February 14, 2026.
Grafana Labs. PostgreSQL data source documentation. [Online]. Available: https://grafana.com/docs/grafana/latest/datasources/postgres/ . Accessed: March 17, 2026.
P. J. Huber, “Robust Estimation of a Location Parameter,” The Annals of Mathematical Statistics, vol. 35, no. 1, pp. 73-101, 1964. https://doi.org/10.1214/aoms/1177703732 .
Downloads
-
pdf (Українська)
Downloads: 0
Published
How to Cite
Issue
Section
License

This work is licensed under a Creative Commons Attribution 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).