High precision measurements of magnetic fields and synchronization in optomechanical cavities