Highly Accurate driver for the Sharp 2D120X proximity sensor

I’ve spent the past 5hrs or so writing a driver for the sensor, as the output is not linear but a voltage curve it was rather difficult. I managed to come up with a 3rd order polynomial function that is accurate to within a few millimetres on my sensor.

My driver supports filtering, averaging outputs and moving averages to smooth the output. In addition i created a wiki page with some usage notes and further information.

You can find the driver and more about the sensor on the wiki:
(link removed)

It is now the first sensor in a suite i plan on creating.

Thank you! ;D

Let me know how you go with it, i have only got 1 sensor to test with.

I have of these. I’ll test it later today.

Thanks for the good work!

Nice work ;D

200 points, thanks

Thanks guys, lots of work but i think it paid off :slight_smile:

It does. If it does what I expect, this is awesome :o

I have one of these sensors, too. I’ll try it as soon as time permits.

Wait till Greg sees this. He’s been obsessing over his rangefinders for a while now!

Nice work Mark,

I tried my hand at creating a driver for that sensor, but t sounds like mine is not as accurate as yours. Mine was about ±2cm

Thanks for your contribution.

Hi Mark,

You haven’t assigned your project to a category yet - not sure if you did this intentionally.
Makes it very hard to find - I had to use the link you provided in this post.

Ah thanks RJ i forgot about that. I’m used to ScrewTurn wiki which is .net based and is a whole lot easier… oh well.

Please let me know how your sensors go guys. I’m measuring from the front edge of the sensor to the target.

Mark, you like ScrewTurn Wiki then? After I get the storefront of my site tweaked in I was wanting to add a Wiki as a way letting customers show off there projects and have a better way to share information (stealing GHI idea for Wiki use :wink: ). Since all of my site is ASP.NET it seemed that ScrewTurn would be the way to go.

Yep screwturn is great, i’ve used in in a number of internal projects and it’s working brilliant. We use it for our developer documentation at work - you know what icon is stored where on the server (incase you need the original), how to fix some errors on the slaves/masters, general documentation of process… the sort of stuff the clients and mining engineers don’t need access to. Much easier to get going with a page than mediawiki. Mediawiki is ok, but it was created for wikipedia so change is slow and innovation is lacking.

Good work Mark.

I just posted a thread about this and turned around I see this. I 'll play with my sensor tonight and see.



Could you add support for this sensor as well: GP2Y0A21YK

What you have is probably the right/organized way to setup a project, but just for sake of simplicity for dummies like me, a single-file driver for each device would be wonderful thing, see if you could simplify that a bit. Yes. having the entire project there still a very neccessary.

Thanks for the work.

I bought one from sparkfun which should get here next week. I have no use for it, but i wanted to finish my set.


That is awsome!!! I have 2 of these sensors and a GP2D12. I know I will use them on every freakin things I do as far as robotics…like building an air plane, a drone, a cruise missile, etc. ;)all of that cool mind blowing stuffs.


well give me a week and we’ll see how i go with it