Compliance with security requirements in Wireless Sensor Networks (WSNs) is known as an important phenomenon in conserving energy consumption due to its dynamic topology. Energy consumption management in WSN can be achieved through secure routing protocols. Authentication, firewall and intrusion detection, and trust management are common ways to provide security on the WSNs. Meanwhile, trust management provides better performance due to ensuring distributed security through collaboration. In this paper, a Trust-Aware Dynamic Routing algorithm based on Extended AODV protocol for secure communications in the WSN (TADR-EAODV) is proposed. TADR-EAODV considers factors such as direct trust, recommended trust, connectivity strength, energy rate and worthiness score to measure the distributed safety level of nodes in routing. We use the AODV protocol for routing work, which is extended through a multi-route routing approach. In addition, a centralized ensemble clustering for node grouping is included in TADR-EAODV, which enables clustering-based routing to enhance WSN performance. Extensive experiments have been performed in the presence of denial-of-service attacks to verify our claims. The experimental results prove that high-performance TADR-EAODV has been able to identify attackers by detecting their anomalous behavior. Besides, TADR-EAODV has improved the average packet transfer rate by 6% to 17% compared to existing state-of-the-art algorithms such as LEACH-TM, TAAO-SDTIM and TAOSC-MHR.