Recent years have seen a rise in the popularity of the Internet of Things (IoT) and its applications, due to its adaptability, usability, varied application potential, and ease of deployment. On the other hand, security threats get more attention. Where wireless sensor networks (WSN), which is the core of IoT, are vulnerable to the jammer's attack due to the fact that they are shared and have open access to a wireless channel. Moreover, the difficult conditions in which nodes are distributed, such as underwater, fires, volcanoes, animal habitats, or battlefields, node localization is a significant challenge for the majority of WSN applications. Additionally, the lack of accuracy in traditional localization algorithms has prompted researchers to propose optimization techniques capable of improving localization accuracies, such as genetic algorithms, gravitational search algorithms, neural networks, and deep learning; however, these techniques require additional hardware to perform their complex calculations. On the other side, uncomplicated algorithms like Virtual Force Iteration Localization (VFIL), Weighted Centroid Localization (WCL), and Centroid Localization (CL) are less accurate. To bridge that gap, this work proposes a lightweight algorithm for accurately locating the jammer's coordinates. Our algorithm consists of three phases firstly, a simple way to detect a jamming attack. Second novel designed technique to draw the jammed region using the mapping protocol. Moreover, a range-free technique is proposed to locate the jammer based on geometric calculations. Finally, A set of simulation experiments was undertaken to assess the suggested algorithm's performance. Experiments reveal that the suggested method is capable of precisely locating the jammer. Additionally, the presented method demonstrates superior efficiency in comparison to existing methods.