This work presents an internet of things (IoT) based building management system (BMS) for monitoring, control, and energy management in buildings to provide an efficient way of energy utilization. Existing systems mainly provide monitoring of different parameters with limited controlling/automation functions. Existing solutions also do not provide automatic decision-making, advanced safety management, and resource tracking. However, the proposed system provides a comprehensive way of monitoring, controlling, and automatic decision making regarding different environmental and electrical parameters in buildings, i.e., temperature, humidity, dust, volt, etc., by using a low-cost wireless sensor network (WSN). The architecture of the proposed system consists of five layers and uses analog sensors which are connected to Arduino Mega 2560 microcontrollers for data collecting, NodeMCUs ESP8266 for wireless communication, Raspberry Pi4 microcomputers for decision making, and nod-RED dashboard which runs locally on a Raspberry Pi 4to provide a friendly end-user interface. The system also uses the Message Queuing Telemetry Transport (MQTT) communication protocol through Wi-Fi and completely relies on the local devices in the architecture and does not need cloud computing services. The proposed system provides two different kinds of automation, i.e., safety automation for the safety of different devices with advanced features, and energy automation. The proposed system is also able to provide humidity control inside a room and to track and count the available resources in any facility. The proposed system is low cost, scalable, and can be used in any building. Simulation results show that the proposed system is highly efficient.