While wireless sensor networks are proving to be a versatile tool, many of the applications in which they are implemented have sensitive data. In other words, security is crucial in many of these applications. Once a sensor node has been compromised, the security of the network degrades quickly if there are not measures taken to deal with this event. There have been many approaches researched to tackle the issue. In this paper, we look into an anomaly-based intrusion detection system to detect compromised nodes in wireless sensor networks. An algorithm to detect the compromised sensor nodes has been developed. Simulations are conducted to verify the design. Key words – Sensor networks, detection, intrusion, compromise, algorithm