Digital lock-in amplifier using square wave reference is much easier to be implemented compared to digital lock-in amplifier using sinusoidal wave reference. However, because of the odd harmonics containing in the square wave reference, the interferences at the odd harmonics of the reference cannot be removed with conventional algorithm. A new square wave digital lock-in algorithm is presented in this paper. It cannot only be capable of removing the interferences of the odd harmonics in the signal, but also can detect the amplitudes and the phases of the interferences. The real and imaginary parts of the frequency component of interest and those of the odd harmonic interferences are calculated simultaneously. The results of simulation experiments show the feasibility of the proposed algorithm. The algorithm is computationally efficient and thus suitable for weak signal detection implemented in the general microprocessor.