The invention discloses a sensor with an error detection function. The sensor comprises a top plate, a body, a connecting plate, a jacket plate, a sliding chute, an extension rod, a first screw rod, arotary rod, a clamping rod, a protective shell, a display screen, a buzzer, a fixing block, a second screw rod, a nut, a limiting plate, a transverse rod and a spring. The sensor is simple in structure, and can be used for detecting object movement. Moreover, an error generated by the object movement is displayed through the display screen, so that the accurate position of each object movement can be known immediately. Through the design of the jacket plate, connection of the sensor is facilitated, and limiting of the sensor is facilitated. In addition, through the design of the protective shell, the sensor is protected when not in use, and the influence of dust piling on the service life of the display screen is avoided. Through the design of the limiting plate, fixing of the top plate is facilitated; mounting of the sensor is facilitated; fixing of the sensor is facilitated; the operation convenience is improved; and the operation difficulty is lowered.