Wireless sensor networks are limited by the vast majority of goods with limited resources. Power consumption, network longevity, throughput, routing, and network security are only a few of the research issues that have not yet been addressed in sensor networks based on the Internet of Things. Prior to becoming widely deployed, sensor networks built on the Internet of Things must overcome a variety of technological obstacles as well as general and specific hazards. In order to address the aforementioned problems, this research sought to improve rogue node detection, reduce packet latency/packet loss, increase throughput, and lengthen network lifetime. Wireless energy harvesting is suggested in the proposed three-layer cluster-based wireless sensor network routing protocol to extend the energy lifespan of the network. For the purpose of recognising and blacklisting risky sensor node behaviour, a three-tier clustering architecture with an integrated security mechanism is suggested. This clustering approach is cost-based, and the sink node selects the cluster and grid heads based on the cost function’s value. With its seemingly endless potential across a wide range of industries, including intelligent transportation, the Internet of Things (IoT) has gained prominence recently. To analyse the nodes and clustering strategies in IoT, the suggested method PSO is applied. A plethora of new services, programmes, electrical devices with integrated sensors, and protocols have been produced as a result of the Internet of Things’ explosive growth in popularity.