An optical mechatronic magnetic microsensor with temperature compensation based on fiber Bragg grating (FBG) and microelectromechanical system (MEMS) technologies is demonstrated. Parallel nickel-electroplated cantilever beams are fabricated as an attractive bending mechanism for pushing the optical fiber. Related stress induced cantilever bend caused by magnetic force driving reflective wavelength shift that exactly corresponds with photo-elastic coupling effect to characterize microsensors. Two different cycles of gratings in the same fiber have fabricated to perform the function of magnetic sensing and temperature compensation for reducing temperature-induced bias in magnetic measurement automatically. The sensitivity of 2.238 T/nm with null temperature response has obtained which excited by Nd-Fe-B magnets with residual magnetic strength up to 1.26 Tesla.