High-precision magnetic field sensing