In the Internet of Things (IoT) ecosystem, localization is critical for tracking and monitoring targets via nodes. The distance vector-hop (DV-Hop) technique is a good choice for localizing neighborhood in IoT networks. The conventional DV-Hop algorithm is a distributed localization approach that does not consider the distribution of the nodes into full deliberation when calculating the hop count from the source to destined nodes. The transfer distance and node positions thus do not attain higher efficiency while ascertaining the distance between sources and destined nodes. The study aims to resolve the pitfalls in the traditional algorithm by making enhancements in controlling the original DV-Hop algorithm’s hop count and transfer distance method by utilizing the particle swarm to estimate the node positions. Error rate in the distance between beacon nodes and unseen nodes is effectively reduced with the proposed technique that calculate error factors with corrections in a reversed fashion to revise hop counts. An escape factor is introduced to take control of updating particles’ velocity in the system, and the inertia weight is defined by a piecewise function to enlarge search space. This mechanism increases the diversity of the particle populations and mitigates the tendency of estimations on node positions to be trapped into local optima under stationary state. Also, the improved DV-Hop algorithm described in the paper has a better convergence speed due to the presence of random inertia weight logarithmic method. Finally, the problem of premature convergence is also tackled as a variation factor is adopted in collaboration with a fitness function that affects the particles’ movement range and assists in global convergence. The overall performance of improved DV-Hop is evaluated by statistical metrics and also compared with the traditional DV-Hop algorithm under simulated environment with the data collected from real-world scenarios. Industry 4.0 is fully dependent upon IoT and the count of hops is very important for deciding the routing from the source to destination for speedy transmission of data. The improved DV-hop algorithm can achieve better results and has reduced error rate by more than 30%. The DV-Hop algorithm plays an important role in IoT-enabled environment especially in Industry 4.0.