Optical sensor arrangement comprising an optical barrier placed between a light emitting device and a photodetector, wherein - the light emitting device and the photodetector are arranged on a first plane and are covered by a cover, wherein the projection of both the light emitting device and the photodetector on the first plane defines respective centers; - the photodetector has an active zone; - the optical barrier is a three-dimensional body arranged on the first plane and having a first dimension along a first principal axis (x) parallel to the line connecting the centers of the light emitting device and the photodetector, the first dimension being greater than a dimension of the active zone; - the optical barrier is designed to block light emitted by the light emitting device that otherwise would be reflected by the cover by means of specular reflection and would reach the photodetector; - the dimension of the active zone is the width of the active zone, the width being a dimension of the active zone in a direction within the first plane and perpendicular to the first principal axis (x); wherein - an aperture plane parallel to the first plane has an opening with a polygonal, a rectangular, a D-shaped, an oval, a circular, an elliptical or another shape defined by line- and/or arc-segments the aperture plane being formed as either a) a layer of an opaque material deposited on the cover, or b) a layer arranged at some distance above the photodetector and the light-emitting device, and below the cover, wherein a first slanted component and a second slanted component are mounted on top of the aperture connecting the aperture mechanically to the optical barrier whereby slit openings between the layer of opaque material and the optical barrier are formed; wherein - the optical barrier is arranged to allow for light emitted by the light emitting device and scattered on or above the outer surface of the cover to pass around the optical barrier by passing through slit openings. - the light emitting device and the photodetector are arranged on a first plane and are covered by a cover, wherein the projection of both the light emitting device and the photodetector on the first plane defines respective centers; - the photodetector has an active zone; - the optical barrier is a three-dimensional body arranged on the first plane and having a first dimension along a first principal axis (x) parallel to the line connecting the centers of the light emitting device and the photodetector, the first dimension being greater than a dimension of the active zone; - the optical barrier is designed to block light emitted by the light emitting device that otherwise would be reflected by the cover by means of specular reflection and would reach the photodetector; - the dimension of the active zone is the width of the active zone, the width being a dimension of the active zone in a direction within the first plane and perpendicular to the first principal axis (x); wherein - an aperture plane parallel to the first plane has an opening with a polygonal, a rectangular, a D-shaped, an oval, a circular, an elliptical or another shape defined by line- and/or arc-segments the aperture plane being formed as either a) a layer of an opaque material deposited on the cover, or b) a layer arranged at some distance above the photodetector and the light-emitting device, and below the cover, wherein a first slanted component and a second slanted component are mounted on top of the aperture connecting the aperture mechanically to the optical barrier whereby slit openings between the layer of opaque material and the optical barrier are formed; wherein a) a layer of an opaque material deposited on the cover, or b) a layer arranged at some distance above the photodetector and the light-emitting device, and below the cover, wherein a first slanted component and a second slanted component are mounted on top of the aperture connecting the aperture mechanically to the optical barrier whereby slit openings between the layer of opaque material and the optical barrier are formed; wherein - the optical barrier is arranged to allow for light emitted by the light emitting device and scattered on or above the outer surface of the cover to pass around the optical barrier by passing through slit openings.