Wireless sensor networks (WSNs) are widely applied in smart manufacturing because their installation does not need fixed infrastructure and can be used where cabling and power supply are difficult. Given the limited energy supply and computing capability of a WSN, an efficient routing algorithm for data transmission is essential for its performance. Ant colony optimization is used in WSNs to identify shortest paths, and thus reduce the energy consumption of the network. However, ant colony optimization is prone to falling into local optima and convergences slowly. We hence propose an improved ant colony algorithm that can be used to construct the sensor node transfer function and pheromone update rule, and adaptively choose a data route by adopting the advantages of the dynamic state of the network. The simulation results show that the proposed method can further reduce energy consumption, time delay, and data packet losses. Thus, the quality of service of the WSN is improved by its use.