Let's Make Robots!

USB-I2C whit sharp 10-80cm


does anyone know how to write a simple python code to read the sensor from the usb?

I've been reading this http://www.robot-electronics.co.uk/htm/usb_i2c_tech.htm

and the instruction manual from the sensor: https://content.solarbotics.com/products/documentation/35080-35086-i2c-it.pdf


I open the port but when it comes to the I2C it gets tricky.

I tried what's written on the manula but it just brought me to error messages. 



Thank you! 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I really hope someone corrects me on this one, but I know of no i2c --> USB "standard" connection. Now, FTDI boards are everywhere and going from a UART serial connection to USB is incredibly straight forward. I don't know of a direct i2c to USB converter.

If this were me, I would not think twice about sticking an Arduino in there. Simply have the Arduino read the sensor via i2c then send the data out via the FTDI chip and USB. From there, your python (or anything else) can deal with the data as it comes in.

Picking up on what Chris said I can only add that I don't know much about I2C or "juggling" protocols, but given his suggestion (and provided it fits your goals) it's pretty easy to have a microcontroller outputting serial messages, and then you just need to "pick them up"....

For python I found the pyserial library http://pyserial.sourceforge.net/ quite handy and simple to use.


It's working. In case someone needs it: I had to use the shifted address since the I2C-IT uses Atmel's TWI type addressing rather than the original Phillips addressing.

So if the I2C-IT is set for 0x20, I actually send the address 0x40. 

Thank you all!