A wireless sensor network consists of sensors having autonomous wireless communication with the ability to sense their surrounding conditions and an ability to connect to the Internet through a base station. In most cases, sensors are spatially distributed and, hence, must have a low cost; for this reason, they have limited batteries, computational ability, and memory size. Sensors' restrained ability to implement common security measures makes them vulnerable to various types of attacks. Moreover, their applications are sensitive to delay or packets corruption, e.g., forest fire detection, disaster relief operations, and lots of other applications. Therefore, improving security is compulsory. There are various types of attacks targeting different network layers. One type is a wormhole attack that is a harmful and easily deployed attack that targets the routing layer. In this paper, a proposed energy preserving secure measure based on the network connectivity aims to detect the wormhole attack. The proposed measure is applied to the ad-hoc on-demand distance vector routing protocol and the experiment is tested using Network Simulator 3. The results state that the detection accuracy is 100% when the wormhole tunnel is of four hops or more in length. In addition, the method has no additional costs because it is not based on any plugged hardware, e.g., synchronized clocks or geographical positing system, as this makes this method appealing for the wireless sensor network environments.