The fourth industrial revolution has brought about automation and a shift from wireless sensor networks (WSN) to the industrial Internet of Things (IIoT), resulting in data-oriented decision-making. However, processing large amounts of data and relying on batteries can lead to communication failure, process disruptions, and even catastrophic disasters. To address this, energy-aware smart communication protocols are critical that prolong the lifespan of devices. This paper proposes a novel energy-cost-based routing protocol called RDEC: routing decisions through energy-cost estimation, which utilizes softwaredefined networks (SDNs) to centralize routing path decision-making. The RDEC algorithm considers the energy required to transmit data and the average battery consumption of intermediate nodes, resulting in a significant reduction in battery consumption by up to six times compared to existing solutions. Furthermore, the proposed approach reduces transmission time by over 50% and doubles the throughput over previous routing methods. Overall, the proposed RDEC algorithm increases the communication lifespan of batteryconstrained devices while ensuring connectivity. In summary, the proposed RDEC algorithm provides an effective solution to address the challenges of energy consumption and communication failures in small battery-dependent devices, making it a significant contribution to the field of Industry 4.0.