3

I was wondering if it would be possible to connect an IO extender (MCP23017-E/SP) to an ATMega32u4-AU via an USB cable.

I figured that if you connect up the SCL pin to the Data+ of the USB and the SCA pin to the Data- of USB, ground the 4th pin and power the 1st it should work.

Am I correct with this?

Image example in Kicad schematic:

enter image description here

Meowlfhelm
  • 31
  • 3

2 Answers2

3

There should be no problem. The original Nunchuk for the Nintendo Wii game system connected to the Wii Remote via a 1 to 1.2m (3.5 to 4 feet) long cable, very similar to a USB cable (six pin connector, but only four were used). The Nunchuk contained a a 2-axis joystick, two buttons and a 3 axis ±2g accelerometer and used a I2C interface to communicate with the remote, running at 100 kHz as documented here and here. Sparkfun even sells a little breakout board for hobbyists building their own interfaces.

tcrosley
  • 47,708
  • 5
  • 97
  • 161
  • Perfect! Thank you so much! Ill be using it to run a 5x7 matrix for a keyboard :) should be easy. Might get more complicated if I do LED's in a future batch. But thank you so much! :) – Meowlfhelm Jan 12 '17 at 06:09
1

Where are the pullup resistors for SDA and SCL ?

The problem with I2C is cable capacitance (already mentioned), crosstalk between SDA and SCL, pullup resistors and voltage differences.

Are both running at 5V ? Then that is okay. You can use pullup resistors at the Master of 2k2 for SDA and SCL.

It is only a short cable, so it should be possible. You could try the MultiSpeed I2C Scanner. It it runs at 400kHz, then 100kHz or is very safe to use.

Jot
  • 353
  • 1
  • 9
  • I have updated it. Added pullups resistors just to be safe. It will already be running at 5v. So there shouldn't be any problems at all. – Meowlfhelm Jan 23 '17 at 08:44
  • No guarantees, but it should work. Run that test with 400kHz. As a backup plan, the Wire.setClock can be used to lower the speed to 50kHz. – Jot Jan 24 '17 at 20:10