This study aims to develop and optimize an automatic waste sorting system based on the Internet of Things (IoT) with a 5 kg capacity. The Convolutional Neural Network (CNN) algorithm is used for waste type classification, while optimization is performed using Particle Swarm Optimization (PSO). The system is designed to recognize and sort four main types of waste: plastic, paper, metal, and glass. System performance is evaluated based on three main parameters: sorting accuracy, processing time, and energy consumption. The results show that algorithm optimization successfully increased the average sorting accuracy from 82.5% to 94.8%. Additionally, the waste processing time significantly decreased from 3.2 seconds to 1.8 seconds after optimization, indicating improved operational efficiency of the system. In terms of energy consumption, there was a reduction from 15.6 Joules to 9.4 Joules per sorting cycle, making the system more energy-efficient and environmentally friendly. The conclusion of this research indicates that the CNN algorithm optimized with PSO can enhance the accuracy, efficiency, and energy consumption of the IoT-based automatic waste sorting system. The implementation of this system is suitable for application in small-scale industrial or household sectors to effectively support waste recycling programs. Further research could focus on testing larger capacities and more complex environmental conditions.