Measuring height

How do I measure height of an object between 5 to 10 cm away that ranges from 0 to 20 cm. I need 2 or 3 mm accuracy
I was thinking of a ir array usually used as a line sensor, or would you use a lidar, if so then which type.
Or would I use sonar, then I would need angle as well.
Please advise

Distance sensors usually have a minimum sense distance and they often measure over an area. You didn’t mention if you can place sensors either side of the object to measure.

The way I’ve done it in the past is to use a LASER diode and an optical sensor on the far side. I moved the LASER and the diode up to until the sensor see’s the LASER light.

1 Like