[Introduction] The goaf under transmission line is easy to cause surface subsidence and threaten the operation safety of power facilities. The electromagnetic environment of goaf under transmission line is complex. The traditional detection methods which have the characteristics of single transmission frequency, poor anti-interference ability and heavy power detection instruments, are difficult to apply to detect goaf under transmission line. [Method] Based on the spread spectrum coding technology in the field of communication, the transmitted signal frequency is widened and the spread spectrum correlation algorithm is combined. Using the designed spread spectrum code electrical detection system, the anti-interference experiment of flume and the detection experiment of underground cavity in outfield under strong interference environment are carried out. [Result] The results show that the spread spectrum code electrical detection method has strong anti-jamming ability, and it can obtain better detection effect and improve the detection accuracy in the case of strong interference. [Conclusion] This study verifies the effectiveness of the spread spectrum coding detection method in removing interference. It can provide an effective method for electrical detection in complex electromagnetic environment and provide references for goaf detection under transmission lines.