Sharp Distance Sensors with I2C


For my own rover, Data Bus, I've been working on a board that converts Sharp range sensors to I2C.

I ran out of analog ports and had to prototype an I2C solution for my obstacle detection. I have this problem on all my robots. Pokey has too few analog ports. And I want to run a few of these on my RPi tele-rover.

They'll work with any Sharp ranger. For that matter, with any analog sensor (ideally at 3.3V or 5V). I plan to test a Maxbotix Sonar module soon.

Up to 27 of these on an I2C bus without re-programming the base address.

The firmware's oversampling, decimation and low pass filtering increases resolution and lowers noise floor. The analog anti-alias filter helps too. Performance is really good. Here's a pseudo-theremin demo:

They're running ATtiny44As. 6-pin AVRISP header doubles as I2C interface -- SPI and Serial on the newer revision is possible; I break out an ~SS pin. I also break out 2 GPIOs for the heck of it. I'm testing out SOIC and QFN versions.

If there's anyone who's building a project using analog rangers (Sonar, Sharp, other) and wants to try these let me know.

I have example code for Arduino, mbed, Raspberry Pi, and Propeller so far.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Well thank you either way! If you have a chance to check in the hardware design and firmware, let me know :)

  • Hm, this is an old thread :)  I decided to put these on the back burner for awhile. Some of the example client code is here:  I don't seem to have checked in the hardware design or firmware. :(

  • I have example code for Arduino, mbed, Raspberry Pi, and Propeller so far.

    Is this available anywhere?

  • I have been looking all over for a module that takes the output from a Sharp IR sensor and converts it to a linear 0-5 volt output. I have a data logger system for a race car that has open analog channels to connect various sensors to. The only inputs it accepts for example is 0 volts = 60 inches 5 volts = 8 inches so the voltage input has to be linear. I found a company (Autonobot) in Ontario Canada that makes such a module however the phone does not accept incoming calls & E-mail has had no results. In scanning through this thread it sounds as though someone here may of developed something similar. Any help from anyone or point me to a source? I've looked for days to try to find another one and have come up empty. Regards, Mike

  • Just to follow up with some of the possibilities I mentioned -- I was on an iPhone so hard to type all this...

    The current version uses card edge type pads and so it should plug into a 5x2 card edge connector (ribbon or board) so you could easily daisy chain these with ribbon cable for easy connection.

    Or create a backplane with card edge connectors and add loads of these, with all the exposed pins broken out, for a highly parallel robot controller, or whatever else.

    Or use pin headers soldered onto the pads and wire up with female .1" sockets (what I'm doing). 

    Since you can have 27 per bus, you could have a butler robot with lots of IR sensors for very robust obstacle avoidance. I'm probably going to add a feature where the base address is configurable so you could have 127 per I2C bus.

    I'm contemplating putting several on a rotating assembly as a sort of radar. Their update rate is slow so you need a bunch to support a reasonable update rate of your radar display.

    On diyrovers email list we've talked about small embedded MCU boards for dedicated tasks on our scratch built robots, like controlling ESC and Steering servo over I2C.

    Or reading wheel encoder counts.

    Doable as long as the anti-alias filter doesn't get in the way ;)

    I am sure there are lots of other possible uses.

    Also, I keep talking about using lots of these. I'm trying to keep costs as low as possible, definitely well under $10 and almost certainly under $8 at least with the current design. I'm hoping for even less if possible.

  • Yup they did. The SolarBotics product was my inspiration.

    Were you able to find versions for the 150cm and 550cm models? Or for any other analog sensors? I never did.

    What if you want SPI or Serial?

    Is it open source? Programmable? Hackable? Adaptable?

    How does it perform? I tried using discrete I2C ADCs in my early versions and was very unsatisfied.

    The MCU approach with some signal processing has worked so much better. I wished i had done that early on.

    And it opens the door for many different applications. You just have to see the possibilities.
  • Solarbotics did the same thing, but the PCB is inside the sharp sensor!


    I2C-It Sharp IR Distance Sensor (10 to 80cm range) :: Solarbotics
    We've turned this excellent standard-range Sharp IR sensor into something faster, and I<sup>2</sup>C compatible!
  • Admin


    When I say tuning, I am referring to the angle at which the sensors are mounted on the front of the vehicle. You need to experiment with the elevation angle of the sensor in relation to the plane of the chassis. Also, a horizontal sun shield helps sometimes.

    Processing refers to how the sensor distance signal is interpreted. Tridge has incorporated a trigger distance debounce parameter and a target trigger distance into the ArduRover2 code.


    TCIII ArduRover2 Developer

  • @Tom -- what sort of tuning/signal processing are you doing? I can probably implement it on the board if the existing processing doesn't cover it.

  • As far as I know, they work outdoors.

    I was using one of the 150cm ones as a curb detector a couple years ago and it seemed to work fine.

    I believe Tom is using two rangers on his champion rover.

    @Gary -- if you want to help me further the development, go to and click "contact me" and send me your address.

    @Randy -- thanks!

This reply was deleted.