Abstract:The node location of the agricultural IoT node is of great significance for reducing power consumption. However, the existing literature rarely considers the loss in the signal transmission process in the node location problem, especially the diffraction loss caused by the terrain factor. A method of node location based on K-means and PSO algorithm was proposed. Firstly, the K-means algorithm was used to determine the approximate location of each route and the terminal which were responsible for docking according to the distance of the straight line. Then, considering the electromagnetic wave free space loss and diffraction loss, combined with the modeling of the nodal topography, using the Fresnel integral and free space loss formula, a fitness function was constructed. A variable inertia coefficient PSO algorithm was used to solve this function. This method increased the inertia weight factor to improve the particle search ability when the global optimal point was updated. Anyway, the inertia to accelerate the convergence of the algorithm was reduced. The improved PSO algorithm was used to optimize the location of routers and gateways. The simulation found that the routing position was optimized through the PSO algorithm, which can reduce the maximum transmission loss by up to 27.82%. Field inspection showed that the optimal communication quality selected by this algorithm was significantly higher than that of the nearby points, and the RSSI was improved by as much as 12% to 20%. In addition, the model gave the maximum electromagnetic wave loss data, which can be used to determine the maximum transmission power of the node and estimate the energy loss of the node, so as to make a more rational estimate of the overall energy consumption of the node, and effectively reduced the subjectivity and arbitrariness of nodes planning.