Distance sensor for calculating a processed distance (d) of a target object without contact, including: ∘ A contactless measuring circuit for emitting an output signal proportional to a distance (d) of said target object for a plurality of time intervals, so as to obtain a plurality of measurements of the distance of said target object without contact; ∘ A first processor circuit for processing said output signals coming from said measuring circuit, so as to calculate a first average distance from said target object based on the average of N distance measurements in output coming from said measuring circuit, said N measurements being consecutive in time and including the last distance measurement emitted by said measuring circuit; characterised in that it further includes: ∘ a second processor circuit for processing said output signals coming from said measuring circuit, so as to calculate a second average distance from said target object based on the average of M distance measurements in output coming from said measuring circuit, said M distance measurements being a subset with M < N of said N distance measurements, consecutive in time and including the last distance measurement emitted by said measuring circuit; ∘ a first comparator circuit for calculating a first differencebetween a function value of said first average distance and a function value of said second average distance; ∘ a third processor circuit for comparing said first difference with a first threshold and for emitting in output a processed distance value, said processed distance value being equal to a value function of said first average distance if said first difference is less than or equal to said first threshold, or being equal to a value function of said last distance measurement emitted by said measuring circuit otherwise. ∘ A contactless measuring circuit for emitting an output signal proportional to a distance (d) of said target object for a plurality of time intervals, so as to obtain a plurality of measurements of the distance of said target object without contact; ∘ A first processor circuit for processing said output signals coming from said measuring circuit, so as to calculate a first average distance from said target object based on the average of N distance measurements in output coming from said measuring circuit, said N measurements being consecutive in time and including the last distance measurement emitted by said measuring circuit; ∘ a second processor circuit for processing said output signals coming from said measuring circuit, so as to calculate a second average distance from said target object based on the average of M distance measurements in output coming from said measuring circuit, said M distance measurements being a subset with M < N of said N distance measurements, consecutive in time and including the last distance measurement emitted by said measuring circuit; ∘ a first comparator circuit for calculating a first differencebetween a function value of said first average distance and a function value of said second average distance; ∘ a third processor circuit for comparing said first difference with a first threshold and for emitting in output a processed distance value, said processed distance value being equal to a value function of said first average distance if said first difference is less than or equal to said first threshold, or being equal to a value function of said last distance measurement emitted by said measuring circuit otherwise.