SummaryThe demand for the Internet of Things (IoT) has significantly increased in the current scenario; specific sectors that require IoT include industrial automation, home control, health care applications, military and surveillance applications, habitat monitoring, and nanoscopic sensor applications. The use of optimal wireless sensor networks (WSNs) in transmission techniques has resulted in their involvement. A WSN is made up of thousands of randomly distributed sensor nodes that sense and transmit environmental data such as temperature, pressure, humidity, light, and sound. One of the most important requirements when using these sensor nodes is energy. As a result, it has become a major area of research in recent years; additionally, several design techniques and protocols have been presented in the last decade, particularly for IoT‐based applications. As a result, the systemization of an energy‐optimized WSN in dynamic functional conditions with automatic self‐configuration of sensor nodes is a critical goal. This paper proposed an opportunistic energy‐efficient dynamic self‐configuration routing (OEDSR) algorithm for IoT‐based applications. Initially, the optimal route to the base station (BS) is calculated by using the residual energy and mobility factor of the sensor nodes obtained through a routing tree model based on graph theory. To reduce the number of connections, an optimal path is determined based on dynamic cluster generation through a hierarchical tree architecture. Finally, the network‐related parameters, such as throughput, delay and packet delivery ratio (PDR), are compared with the peer existing routing protocols to depict the efficiency of the OEDSR protocol.