As next-generation large-aperture telescopes, synthetic aperture is a promising method for realizing high resolution observations. Co-phasing the misaligned segmented aperture is an important procedure for high-resolution observations with segmented telescopes. In this paper, a piston error detection method is proposed based on two interference patterns. Two interference patterns are generated by using a lens placed across two adjacent pupils in the exit pupil plane at two wavelengths and a method based on phase retrieval technique is proposed to extract the piston error from the two interference patterns. The introduction of dual-wavelength in the scheme overcomes the 2π ambiguities problem and expands the piston error detection range. Meanwhile, the proposed piston error extraction method based on phase retrieval technique allows high precision measurement of the piston error and is robust to offset lens. Various simulations are demonstrated and the feasibility of the proposed piston error detection method is validated.