Parts: Analog distance sensors (Sharp GP2D12/2Y0A02)

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. @hunt: oh snap!

    K, so these things are great, but for those who want something digital, might I recomend these guys:

    http://www.hvwtech.com/products_view.asp?ProductID=665

    They basically took the same sharp sensor and added their own really small pic microcontroller, and gave the things I2C out, or if you search around on their site they also have serial ones. Cool stuff, handy for more complicated projects.

  3. 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”

  4. 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.

  5. @DarkAxi0m
    you’ll probably have to go with sonic or laser range finders for that kind of distance (re: golf range finders are typically laser).

  6. 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.

  7. 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?

  8. @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.

  9. 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!

  10. Dear Sales ,

    Oompany is distribute Electronic parts in Iran market .
    If it’s possible for you please send me your price about
    GP2D12 100PCS

    I’m waiting your reply
    Thanks

    Mina
    Tell : +9821 6671 5432
    Fax : +9821 6671 2825

  11. 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s