Wide applications of Wireless Sensor Networks also make them more interesting to adversaries. WSNs' protocols are designed without security in mind so they are susceptible to many types of attacks. Some preventive mechanisms are deployed to protect WSNs but they are not enough. Thus, WSNs need an Intrusion Detection System (IDS) to detect intrusion of adversaries to response and diminish the damage. In this paper, we propose an algorithm for detecting a series of attacks in WSNs by applying Cumulative Sum (CuSum) algorithm to detect anomalies. We also show that our algorithm is very light-weight so it fits the demands and restrictions of WSNs.