High energy consumption in classrooms is a significant concern, often resulting from inefficient lighting and air conditioning systems. Specifically, the problem lies in the lack of automated control mechanisms that adjust energy use based on real-time occupancy data. This study aims to develop and evaluate a system that employs a camera integrated with the YOLOv8 algorithm to detect human presence and optimize energy usage by controlling lights and air conditioning. The system's performance was assessed in three different classroom environments: two large and one small. The system's accuracy for occupancy detection varied from 13.64% to 100%, depending on lighting conditions and room size. Light control accuracy was highest in the classrooms with consistent lighting, reaching 99.77%. Air conditioning control achieved perfect accuracy of 100% in the classroom with a SHARP brand AC, with a maximum remote-control range of 7 meters. These findings indicate that the system's performance is influenced by lighting conditions and room size, with smaller rooms showing better results. The system demonstrates promising potential for reducing energy consumption in classroom settings, thereby contributing to more sustainable energy practices.