3
\$\begingroup\$

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

\$\endgroup\$
3
  • 1
    \$\begingroup\$ It should work for short distance cable. Bus capacitance may be addressed by reducing the I2C speed to minimal if possible. \$\endgroup\$
    – User323693
    Jan 12, 2017 at 1:36
  • \$\begingroup\$ @Umar how short of a distance are we talking about here? Haha. I was planning on having it run through about a 6inch to 1 foot cable. \$\endgroup\$
    – Meowlfhelm
    Jan 12, 2017 at 1:49
  • \$\begingroup\$ That should do. \$\endgroup\$
    – User323693
    Jan 12, 2017 at 1:52

2 Answers 2

3
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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! :) \$\endgroup\$
    – Meowlfhelm
    Jan 12, 2017 at 6:09
1
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – Meowlfhelm
    Jan 23, 2017 at 8:44
  • \$\begingroup\$ 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. \$\endgroup\$
    – Jot
    Jan 24, 2017 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.