A sensor includes a light emitting element, a photodetector element for receiving light emitted by the light emitting element, and a circuit board having the light emitting element and the photodetector element mounted thereon. A light emitting surface of the light emitting element is facing the circuit board which is provided with a light-transmitting portion for transmitting the light emitted by the light emitting element.