The surface plasmon resonance sensor was used to detect and measure low concentrations of sugar. A polypyrrole–chitosan–BaFe2O4 nanocomposite layer was prepared to improve the surface of the gold layer for the detection of glucose, fructose, and sucrose using the surface plasmon resonance technique. The polypyrrole–chitosan–BaFe2O4 was synthesized using the electrodeposition method in di erent thicknesses. The functional group, crystal structure, and morphology of the layer were investigated with Fourier transform infrared spectroscopy, X-ray di raction technique, and field emission electron microscopy. Consequently, the BaFe2O4 was scattered on the surface of the polymer, and the anity of polypyrrole–chitosan–BaFe2O4 to bond with glucose is higher than that for the other sugars. The sensor limit was 0.005 ppm.