We've turned this excellent standard-range Sharp IR sensor into something faster, and I2C compatible!
The Sharp GP2Y0A21YK0F is an excellent, well proven sensor, designed for giving you an analog voltage output for you to read into your microcontroller as an analog value. But it isn't a linear value, so there's some funky math or complex lookup-tables to generate to make this data useful. And being analog, it will eat up an analog channel of your microcontroller.
The I2C-It uses this great sensor mated to a smart add-on board that does the math and gives it back to you on an I2C interface! Simply ask the sensor for a distance reading in raw, inches, or centimeters, and it will pop the answer back immediately. No additional coding, and you can chain up to 8 of the same sensors together to your I2C bus (the bus supports up to 127 devices total). Being an open-source project, you can leverage our several man-days of testing multiple sensors and make your I2C-It behave any way you wish!
Check the resources tab for code examples on how to use the I2C-It with your microcontroller.
|Operating Voltage||Vcc||4.5 to 5.5||V|
|Operating Temperature||Topr||-10 to +40||C|
|Maximum Cable Length||CLmax||35/14||cm/in|
|I2C Clock Frequency||SCL||100||kHz|
|Bus pull-up Resistance||Rline||1.2k to 10k||ohms|
|Required Current||Icc||35 to 55||mA|
Some popular Microcontrollers that support I2C in hardware ("bit-bang" emulation is possible) include:
Now, it's a simple set of I2C commands to send or receive data to your desired sensor. By default, the sensor's address is DEC 32 (0x20). Each sensor supports four basic commands. To receive the distance reading from the specified sensor, you need to send 1, 2 or 3 (DEC code) to the spec address. The sensor will respond with distance in inches, cm or RAW code accordingly. Also you can change the default address to any address from: 32 (0x20), 34 (0x22), 36 (0x24), 38 (0x24), 40 (0x28), 42 (0x2A), 44 (0x2C) or 46 (0x2E) by sending 5 (DEC code) + new address (2 bytes) to the target sensor.
I.e. Using Arduino, to change the address from decimal address 32 to 42, your sketch would use:
Wire.beginTransmission(32); //Starting address
Wire.write(byte(42)); //Address is changed to this
Note: After changing the address please remove power from the sensor and power it back up for the address change to take effect, you may also have to reset your microcontroller in order to communicate via I2C again.
The I2C-It is configured to only read a single distance sample and return that result to you - it is not spending time watching multiple samples to average out the distance to the object. It is generally a good idea to request multiple samples from the I2C-It to make sure you're seeing what you think you're seeing, but we figured we'd leave that up to you to decide. We designed the I2C-It to give you back a single measurement, as quick as it can!
Please Note: With our latest update, you no longer have to select your address via solder-jumpers on the back of the device. Jumper 3 being soldered will actually now keep the ATtiny45 chips in a constant reset state if soldered so the sensor will not work as long as this jumper is soldered. As an added bonus for this update, the ATtiny45 on-board now has the ability to be ISP re-programmed if one were to want to change the firmware.