The occupancy monitoring system is one of the substantial aspects of building management. Through monitoring the occupancy in the area in a building, the obtained information can be used for building management purposes such as controlling indoor area air quality and improving building security. Some technologies such as video surveillance cameras, Radio Frequency Identification (RFID), and motion sensors have been used in the occupancy monitoring system. However, those technologies pose several disadvantages including privacy concerns and limited information generated. A classroom occupancy monitoring system using an Internet of Things (IoT) device and the k-Nearest Neighbors (k-NN) algorithm was built to monitor classroom occupancy by classifying the number of occupants based on classroom environmental data into occupancy levels by using the k-NN classifier model. By utilizing IoT devices, CO2, temperature, and humidity data in a naturally ventilated classroom were recorded using the MQ-135 and BME280 sensors, as well as WiFi-based NodeMCU, was used to distribute data to the cloud. The collected data were trained and tested by the k-NN algorithm to produce a k-NN classifier model. From the tests conducted, the performance of the k-NN classifier model in classifying the number of occupants into occupancy levels resulted in an accuracy of 88%. In addition, the proposed system also produces a web-based classroom occupancy monitoring application that has been integrated with the k-NN classifier model so the classification can be done for real-time data and monitored directly.