In many adverse or dangerous application environments, parameters in path loss model for wireless channel are unknown, and neighbor nodes are unable to range using RSSI. Forcing on this kind of environment, a localization algorithm based on Particle Swarm Optimization and the mobile anchor in sensor networks is proposed in this paper. Localization process is converted into non-linear constraint optimization solved by PSO with the help of the mobile anchor. Because of only a few parameters adjusted, this algorithm is simple and easy to implement. Performance evaluations show that, comparing with the typical algorithm; location accuracy is improved obviously and is robust to the interference of environment noise.