Parts: Analog Distance Sensors (Sharp GP2D12/2Y0A02)

[youtube=http://www.youtube.com/watch?v=iGiRK0vmcUw]

Sharp GP2D12 and 2Y0A02 infrared rangers output a voltage proportionate to the distance of an object from the sensor.  The GPD12 senses objects at a distance of 10-80cm, while the 2Y0A02 has twice the range.

We’ve previously looked at the Sharp GP2Y0D02 digital proximity sensor. It only signals the presence of objects, while the GP2D12 and 2Y0A02 measure distance to them. If you’ve got a GP2YoD02, it might still be possible to tap the analog output. We’ll show you how use these sensors below.

cct

Sharp GP2D12, 10-80cm analog IR ranger (Digikey #425-2046-ND, $12.81). Datasheet (PDF).

Sharp 2Y0A02, 20-150cm analog IR ranger (Digikey #425-2062-ND, $14.38). Datasheet (PDF).

We powered the sensors with a 5volt supply, as shown in the schematic above. We connected the output directly to a multimeter set to measure voltage. The datasheet also recommends a 10uF bypass capacitor between the power and ground pins, but we didn’t use it for this demonstration.

gp2d12

This graph shows the relationship between the output voltage of the GP2D12 and the distance of objects from the sensor (datasheet page 3, figure 6). You can find the distance/voltage curve for the 2Y0A02 in datasheet page 5, figure 2. There’s an equation to determine distance from the output voltage, or you could use a simple lookup table.

The output is unreliable for extremely close objects, seen as the small hump between 5 and 10cm. It’s possible to combat this by using several sensors with overlapping ranges, or by placing sensors so that nothing can come within the minimum range.

For an exhaustive discussion of the various Sharp proximity sensors, check out the Sharp IR ranger information page at Arconame.

Like this post? Check out the parts posts you may have missed. Want to request a part post? Please leave your suggestions in the comments.

23 thoughts on “Parts: Analog Distance Sensors (Sharp GP2D12/2Y0A02)

  1. that’s some brilliant timing, i impulse bought a gp2d12 along with some other stuff last week. saw some on a robot at work and thought it might be cool to play with. my intention is to combine it with a vibration motor on the palm of a glove, so that you can ‘feel’ things with a spooky sixth sense. could also work as a cheapo parking sensor…

  2. well Ethan have a point, well here future hacks:
    “termoresistor multimeter and a match”
    “LDR and flashlight”
    and everyone’s favorite touch activated a “button and a led”

  3. You’re right ethan and therian, this isn’t a hack. I notice that myself right off, when the title started with “Parts:” . . .

    As long as there’s at least one hack per day the site can keep it’s name and it’s nice for them to post these little additions that might spark someones creativity and prompt a future hack.

  4. I used these sensors for a microprocessor project. I attached them to the head of a roboquad and then used them (I fried the original IR sensor since I didnt know what it was).

    So I used them to measure the distance from the head, then controlled the motors in the head to look around and draw a ‘picture’ of the distances in front of it.

  5. I have used these sensors for a project of mine but found their accuracy (even after calibration) to be a bit off. The output even with the capacitor was very noisy. Does anybody know of another (preferable cheap) sensor that can do the same job but be more accurate at distances from 0-80cm?

  6. @SchrodingersCat (don’t know if you’re there or not :-))

    You might look at the Maxbotix ultrasonic rangers which are $30. They’ll use more power though. They almost have to, as infrared is as power-frugal as you’re going to get at that range, as neither capacitive nor inductive sensing will work except in REALLY constrained environments.

  7. I got one of these a few weeks ago, but haven’t played with it yet. I was thinking of replacing the transmit LED with a laser — I need to sense the distance of a small object at a distance, and a more-precise spot might be helpful. Looking for to experimenting with this!

  8. hi.. i would like to ask, is it i directly connect the output signal to the meter like above, then i will get the reading? or i need to change it to dc 1st onie can get the voltage like the video? pls help… thanks alot

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.