PurposeSecurity is the major issue that motivates multiple scholars to discover security solutions apart from the advantages of wireless sensor networks (WSN) such as strong compatibility, flexible communication and low cost. However, there exist a few challenges, such as the complexity of choosing the expected cluster, communication overhead, routing selection and the energy level that affects the entire communication. The ultimate aim of the research is to secure data communication in WSN using prairie indica optimization.Design/methodology/approachInitially, the network simulator sets up clusters of sensor nodes. The simulator then selects the Cluster Head and optimizes routing using an advanced Prairie Indica Optimization algorithm to find the most efficient communication paths. Sensor nodes collect data, which is securely transmitted to the base station. By applying prairie indica optimization to WSNs, optimize key aspects of data communication, including secure routing and encryption, to protect sensitive information from potential threats.FindingsThe Prairie Indica Optimization, as proposed, achieves impressive results for networks comprising 50 nodes, with delay, energy and throughput values of 77.39 ms, 21.68 J and 22.59 bps. In the case of 100-node networks, the achieved values are 80.95 ms, 27.74 J and 22.03 bps, significantly surpassing the performance of current techniques. These outcomes underscore the substantial improvements brought about by the Prairie Indica Optimization in enhancing WSN data communication.Originality/valueIn this research, the Prairie Indica Optimization is designed to enhance the security of data communication within WSN.