A sensor (30) includes an enclosure (42) having a housing (44) and a lower cassette (46) that cooperate to provide a sealed volume in which an optical sensor assembly (50) is enclosed and protected. The optical sensor assembly (50) includes a circuit board (52) mounted in the housing (44). The circuit board (52) includes a light source (54) and a light detector (56). The sensor assembly (50) further includes a light pipe (60) that guides light from the sensor (30) onto a target and a lens (62) guides reflected light from the target onto the light detector (56). Lower ends of the light pipe and the lens are supported by a recess (102) in the lower cassette (46). Upper ends of the light pipe (60) and the lens (62) are supported by an upper cassette (64). The upper cassette (64) is positively located and mounted to the circuit board (52) and received in an internal receptacle (100) in the lower cassette (46).