Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150cm (POLOLU-1137)

This is a placeholder topic for “Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150cm” comments.

The GP2Y0A02 is the longest-range optical distance sensor Pololu carry, featuring a detection range of 8″ to 60″ (20 cm to 150 cm). The high maximum detection distance makes this sensor a viable alternative to sonar in some applications. The distance is indicated by an analog voltage, making this sensor very easy to use.

Read more

I am trying to build a device that will count glass tubes rolling down an incline plane. Will this sensor be able to count each tube as they pass?

I can see it used for distance measuring but I think it would work as each time a tube rolls pass the sensor it will trigger which I can hopefully translate into a count. For further context, I would use this count to control a servo on the ramp so it automatically dispenses a fixed amount of tubes. Hope this makes sense. Thanks for any and all help!

1 Like

Hi Michael,

The only problem I can forsee is that light-based sensors like this one often have trouble with glass, as in some angle/lighting conditions, the surface behind emits the reflection that the sensor circuitry chooses. You might be able to get around that with an ultrasonic sensor instead.

Also, how fast are these tubes moving, and how much gap is in between them? You want to make sure whatever sensor you pick can sample fast enough to catch the tubes and the gaps in between them.

1 Like

Hi Michael188653, James
If these objects are indeed glass “tubes” they will have to be sensed from above or below. Looking into the end won’t be much good as being a tube you will be looking into a “hole”, that is there is nothing to see.

James has a good point regarding glass but if a reflective sensor is used a gap may not be required. The only valid reflection will be when the tube is directly under the sensor and the time when the tube surface is at right angles to it. At all other times the beam will be deflected off at an angle. Another alternative (assuming a reflective sensor can be used) would be to fit a small screen in front of the sensor with a slit in it to prevent any reflections except those at right angles from getting to the receiver.

Some commercial reflective sensors use fibre optics. The transmitting fibre (s) are in the centre, either 1 or 3 arranged in a tight triangle. The receiving fibres are arranged in a tight circle around the transmitting ones, sort of a co-axial arrangement. They work well, We have used this type to detect unwanted sideways movement of circular wire down to something like 1mm diameter. On coil winding machines to detect mis-winds.
Cheers Bob


Hi Michael
A few documents to provide some light reading for you on the subject of object detection.
KEYENCE is a company that came to mind. It was one of their products we used on that wire mis-wind detection described above.
fs.pdf (1.9 MB)
lv_guide2.pdf (712.9 KB)
01-Photoelectrics.pdf (4.9 MB)

That last one contains a lot of detail. Something to get you thinking.
Cheers Bob


Hi Bob,

Thanks for linking those PDFs you certainly weren’t kidding about containing a lot of detail.
Good to see what options industry gravitate towards when scoping out a sensor as they are often the ones who have put the most time and money into considering the options, thanks for the extra insight.


Hi Trent
Yes there is sometimes more to it than shining some sort of beam across a driveway.
Even the wire misalignment detection system above was not a long term solution at the end of the day. While it did work very well there was one thing we did not foresee. The wire is lubricated very slightly just prior to actual winding. The coil mandrel spinning at high speed was throwing up a very fine mist (almost invisible) and coating the sensor ends with oil and gunk and was not a feasible operation to try and keep it clean so I think this idea was eventually abandoned in favour of a better mechanical set up procedure devised by the maintenance fitter.

I think that when trying to get a reflection off a cylindrical surface the “co-axial” approach would work best as you could get better alignment between the TX and RX devices.
Cheers Bob


Hey Bob,

The Cylindrical shape as well as the material do make it a bit difficult with a sensor like this, I can imagine a more “Mechanical” variant for something like this use case would be to allow the cylinders to roll down a slight decline and using a micro switch it could count the amount of times the switch is closed to replicate a count that would do without any light based sensors and the inherent issues that come with them.

It would likely be a more accurate and less complex way of going about counting rods of a transparent material.


Hi Blayden, Michael, Trent
Yes this would be a better approach. Would depend a lot on how heavy the cylinders are. The commonly available microswitches have a snap style action and require some force to actuate. HOWEVER there are switches available with a very light actuation force such as those used in some diaphragm type pressure differential sensors as used to measure the pressure differential across air filters etc. This might only amount to a few inches of water which is not much so they are quite sensitive.

“Over-the-coumter” commonly available switches might not but better quality name brand ones do publish the actuating force for different switch types but you would have to go to a manufacturers web site or Element 14 etc to find this. But it is there.
Cheers Bob
PS: For instance there is no mention of the actuating force for that linked switch


Hi All.
A sample data sheet from element 14 showing switch with actuating force down to 15 grams. Plus a whole lot more.

Cheers Bob

Hey everyone
I wouldn’t discount using an optical sensor too readily. With appropriate thresholds on the signal you ought to be able to detect even glass tubes since the glass will refract the light.
Mechanical sensing would be viable too, but might be less reliable or require a lot of mechanical tuning due to reasons mentioned earlier.

@James made a good point about reflections on the surface behind the tubes. In most processes I’ve seen, the sensor points out into free air to avoid this.

The dispensing machine problem is a really interesting one! There’s plenty of resources on youtube of people who have homebrewed and open-sourced their own deisngs. I’d start there for inspiration.
Best of luck @Michael188653, looking forward to seeing what you come up with :smiley:


Hi Michael

True, but only that part of the beam striking the glass at an angle which would reflect away anyway. That bart of the beam striking the glass straight on (at right angle), which is of interest as it will be reflected straight back, will not be subject to refraction and will pass straight through without bending. I did suggest above some sort of screen with a narrow slit might prevent any “scatter” reflections from masking the wanted ones.

The ramp would have to be made of some non reflective type of material or any optical system will reflect off that whether glass cylinders are there or not which will make accurate TOF comparisons necessary. This could be difficult with small diameter tubes and adds to the complexity of the system. I think most simpler systems operate on a “it’s there” or “not there” (go or no go) principle like my wire detection system above.
Cheers Bob

1 Like

Wow this is amazing, thanks so much everyone for all the detailed insights!

There is a lot more to the light based sensors then I realised so this is interesting rabbit hole to explore. I really like the suggestion of a mechanical counter and wonder if I can incorporate the count sensor into the dispenser rather then having a seperate module. I will check out some of these open source models @Michael mentioned and if I can’t make this work I will dive into these in-depth resources @Robert93820 has kindly shared and attempt a light based sensor. Really appreciate everyones contribution!

Some additional context is the tubes vary in diameter from 7mm to 22mm and weigh between 40-100g each. As this will be automated, it doesn’t have to be super fast and I would be happy with a dispenser that managed 20 tubes per minute.