In practical applications of electromagnetic measurement while drilling (EM-MWD) in the underground coal mine, the signal-to-noise ratio (SNR) of a receiver cannot always meet the requirements of reliable communication conditions due to the earth attenuation, interfering signal from the well site, and so on. Aimed to solve these problems, this paper presents a low error rate Bose-Chaudhuri-Hocquenghem (BCH)-based encoder-decoder technology for EM-MWD. First, this paper studies the relationship among the BCH encoding error performance and the decoding method, the source length, and other factors through simulation; then, we obtain an optimal length of BCH code for EM-MWD through analyzing the bit error performance of hard-decision decoding and soft-decision decoding with different lengths of BCH code. Finally, we compare the proposed algorithm with the conventional binary phase-shift keying (BPSK) approach in the actual environment. The results show that the proposed algorithm can reduce the bit error rate by about ten times at a lower SNR, achieving a reliable communication condition when the SNR of a received signal is reduced. It demonstrates the effectiveness of the proposed BCH encoder and the decoder algorithm based on BPSK for EM-MWD. INDEX TERMS EM-MWD system, BPSK, BCH coding, optimized coding techniques.