TEPIAN
Vol. 7 No. 2 (2026): June 2026

IoT-Based K-Nearest Neighbor Classification of Beverage Sugar Levels for Early Diabetes Prevention

Nurul Safira (Informatics Engineering, Universitas Prima Indonesia)
Rizka Azizah (Informatics Engineering, Universitas Prima Indonesia)
Sri Hayyu Fajhalika (Informatics Engineering, Universitas Prima Indonesia)
Achmad Ridwan (Informatics Engineering, Universitas Prima Indonesia)



Article Info

Publish Date
01 Jun 2026

Abstract

This study is motivated by the increasing consumption of sugar-sweetened beverages, which significantly contributes to the risk of diabetes mellitus. Therefore, a practical, accurate, and efficient system is required to detect sugar levels in beverages. This study aims to design and implement an Internet of Things (IoT)-based system for classifying sugar levels using the K-Nearest Neighbor (KNN) algorithm. The system is developed using an ESP32 microcontroller integrated with an ultrasonic sensor, a photodiode, and an infrared light source to capture the physical and optical characteristics of liquids. The research focuses on several commonly consumed beverages, namely sweet tea, coffee, milk, syrup, and lemon water, with varying sugar levels ranging from 10 to 60 grams. The collected data are processed through normalization using the StandardScaler method and classified based on Euclidean distance with a k value of 5. The classification results are grouped into three categories: low, medium, and high sugar levels. Experimental results show that the system achieves an accuracy of 85% under testing conditions. These results indicate that the proposed system can perform reliable classification in practical scenarios. In addition, the system provides a low-cost and real-time solution, making it suitable for practical applications in monitoring daily sugar intake and supporting the early prevention of diabetes mellitus.

Copyrights © 2026






Journal Info

Abbrev

tepian

Publisher

Subject

Computer Science & IT

Description

The purpose of TEPIAN is to publish original research studies directly relevant to computer science. TEPIAN encompasses the full spectrum of information technology and computer science, including information system, hardware technology, intelligent system, and multimedia applications. TEPIAN ...