With the rapid development of renewable energy, the scale of China’s power grid with renewable energy has become much bigger than ever; as a result, we are facing severe challenges in the inspection and maintenance work of power grids that use renewable energy. Focusing on the shortcomings of the traditional manual inspection methods, this paper studies and proposes an optimization algorithm of automatic inspection of Unmanned Aerial Vehicles (UAVs) to improve the efficiency and cost of the inspection and maintenance work of renewable energy power grids. Firstly, the communication network of the swarm intelligence system has been established to transmit the local information sensed by each UAV in real time. Secondly, according to the sensing ability of UAVs, the segmentation model of UAVs overlapping sensing areas is established, which effectively reduces the probability of overlapping UAVs sensing areas. Thirdly, according to the difference between the coverage value and the effective coverage index of each point in the sensing area, the optimization function of the coverage index is given, which makes the UAV give priority to the inspection area with the lower coverage value. Finally, when a UAV completes a local coverage task, the traction speed is introduced to prevent the UAV from stopping, which ensures that the inspection task of the whole area can be completed in a limited time. The numerical simulation results show that the algorithm can effectively control the UAVs to complete the inspection task in the specified area, and compared with the single UAV inspection method, this algorithm can greatly improve the inspection efficiency and reduce the inspection cost.