Wireless Sensor Networks is consist of thousands of small and low-cost devices, which communicate over wireless medium. Due to locating in harsh environment and having limited resources, WSN is prone to various attacks. One of the most dangerous attacks threatening WSN is the sinkhole attack. In this paper, sinkhole attack is modelled on a cluster-based WSN, and a centralized detection algorithm based on the remaining energies of the nodes is proposed. The simulations were run for different values of energy thresholds and various numbers of nodes. The performance of the system was investigated over total energy consumption in the system, the number of packets arrived at base station and true detection rate of the sinkhole node(s). The results showed that the proposed method is energy-efficient and detects the malicious nodes with a 100% accuracy for all number of nodes.