The Internet of Things (IoT) is a platform that manages daily life tasks to establish an interaction between things and humans. One of its applications, the smart office that uses the Internet to monitor electrical appliances and sensor data using an automation system, is presented in this study. Some of the limitations of the existing office automation system are an unfriendly user interface, lack of IoT technology, high cost, or restricted range of wireless transmission. Therefore, this paper presents the design and fabrication of an IoT-based office automation system with a user-friendly smartphone interface. Also, real-time data monitoring is conducted for the predictive maintenance of sensor nodes. This model uses an Arduino Mega 2560 Rev3 microcontroller connected to different appliances and sensors. The data collected from different sensors and appliances are sent to the cloud and accessible to the user on their smartphone despite their location. A sensor fault prediction model based on a machine learning algorithm is proposed in this paper, where the k-nearest neighbors model achieved better performance with 99.63% accuracy, 99.59% F1-score, and 99.67% recall. The performance of both models, i.e., k-nearest neighbors and naive Bayes, was evaluated using different performance metrics such as precision, recall, F1-score, and accuracy. It is a reliable, continuous, and stable automation system that provides safety and convenience to smart office employees and improves their work efficiency while saving resources.