  Solid-state spin defects, especially nuclear spins with potentially
achievable long coherence times, are compelling candidates for quantum memories
and sensors. However, their current performances are still limited by the
decoherence due to the variation of their intrinsic quadrupole and hyperfine
interactions. We propose an \textit{unbalanced echo} to overcome this challenge
by using a second spin to refocus the variation of these interactions, which
preserves the quantum information stored in the free evolution. The unbalanced
echo can be used to probe the temperature and strain distribution in materials.
Experimentally, we demonstrate a 20-fold $T_2^*$ coherence time increase in an
ensemble of $\sim10^{10}$ nuclear spins in diamond. Theoretically, we develop
first-principles methods to predict these interaction variations and reveal
their correlation in large temperature and strain ranges. We numerically show
that our method can refocus stronger noise variations than our current
experiments and achieves a 400-fold coherence improvement for a 25~K
temperature inhomogeneity.
