Abstract:To build a stable and effective internet of things system of pig breeding, coverage rate and connectivity of wireless sensor network are two key problems for node deployment. Obstacles have some effects on the wireless communication. The pig farm was used as an example for modeling and the piggery wall was considered as the obstacle. The sensor node’s communication radius was decreased with the logdistance path loss model when obstacle was blocking the wireless signal. To improve the coverage rate in situation of obstacles with particle swarm optimization (PSO) algorithm combined with virtual force was the aim. Besides, PSO algorithm can find the best positions in the network to add extra nodes for improving connectivity until all nodes get together. Matlab was used to do simulation experiments; the results showed that the virtual forcedirected PSO algorithm has good performance on global optimization and convergence rate. In situation of obstacles and communication radius decreasing, the coverage rate was improved about 15% with only adding 10 nodes, which make the whole network connective.