Bragg's law states that $$n\lambda = 2d \sin(\theta),$$ where $d$ is the lattice distance, and $q = 4\pi\sin(\theta)/\lambda$ is the momentum transfer, $2\theta$ is the scattering angle and $\lambda$ is the wavelength of the incoming X-ray beam.

$n$ can be any integer, but set $n = 1$ to get the characteristic distance: $$d = \frac{2\pi}{q_\mathrm{first\ peak}}$$ If there is only one characteristic distance (Bragg reflection), then the same distance is obtained by setting $n=2$ and using the second peak: $$d = \frac{4\pi}{q_\mathrm{second\ peak}}$$