IoT-Based K-Nearest Neighbor Classification of Beverage Sugar Levels for Early Diabetes Prevention - Nurul Safira; Rizka Azizah; Sri Hayyu Fajhalika; Achmad Ridwan (Politeknik Pertanian Negeri Samarinda, 2026)
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.