Optoelectronic sensor (10) for measuring the distance of an object (18) in a detection area (16) using a time-of-flight method, wherein the sensor (10) comprises a light
transmitter (12) for emitting a
light signal (14) into the detection area (16), a light
receiver (22) with a first plurality of avalanche photodiodes (24) in Geiger mode for detecting received light (20) from the detection area (16), a second plurality of time-of-flight measuring units (28) for determining individual light times between the emission of a
light signal (14) and the triggering of a detection event in an
avalanche photodiode (24), and a control and evaluation unit (32) configured to collect individual light times in a
histogram, to locate a useful
light signal (44) in the
histogram using a threshold (38), and to determine a distance value to the object (18) from the useful light
signal (44).wherein the control and evaluation unit (32) is further configured to first estimate an ambient
light level from the
histogram and then, based on the ambient
light level, to set the threshold (38) such that it lies above an expected exponentially decreasing number of
noise and ambient light events with a
safety margin, characterized in that the control and evaluation unit (32) maintains a first
lookup table which assigns an ambient
light level to a summed number of detection events and that the first
lookup table is trained prior to the
distance measurement by repeatedly exposing the light
receiver (22) to a defined ambient light level with the light
transmitter (12) inactive and determining the respective sum of the first bins of a histogram generated thereby.