Go Down

Topic: Can I I2C wire two Arduinos with USB cables on both? (Read 1 time) previous topic - next topic

mariocarta

Jan 17, 2013, 10:58 pm Last Edit: Jan 28, 2013, 08:43 pm by mariocarta Reason: 1
Hi!

It's my first topic here and I spent the day searching on the web for it: I have 2 Arduinos (Seeduino R3 and Arduino Leonardo) that needs to be connected together via I2C but at the same time both via USB serial to the computer. And I never have seen such a thing.

My questions are:

1. Will it work, since both need to share the 5V and GND and both are with their own power supply (via USB)? I didn't try it just because I think it can harm the boards.

2. I tried to just connect the two cables for SCL and SDA without the 5V and GND and it all went fine when running the wire lib skecthes. Will it work on a long run or with a more complex program? Could this damage my Arduinos in anyway?

Anyone can help me?

Thank you,  ;)

Mario

pylon

Quote
1. Will it work, since both need to share the 5V and GND and both are with their own power supply (via USB)? I didn't try it just because it think it can harm the boards.


The only other connection needed (besides the SDA and SCL lines) is GND. There's no need to connect the 5V.

Quote
2. I tried to just connect the two cables for SCL and SDA without the 5V and GND and it all went fine when running the wire lib skecthes. Will it work on a long run or with a more complex program? Could this damage my Arduinos in anyway?


That probably worked because you're using the same computer for the two Arduinos. That way they already share a common ground (over the USB connection). Just because of this you cannot damage your Arduinos.

mariocarta

#2
Jan 18, 2013, 03:11 pm Last Edit: Jan 18, 2013, 03:20 pm by mariocarta Reason: 1
Quote
The only other connection needed (besides the SDA and SCL lines) is GND. There's no need to connect the 5V.


OK, I will try it! :D

Quote
That probably worked because you're using the same computer for the two Arduinos. That way they already share a common ground (over the USB connection). Just because of this you cannot damage your Arduinos.


Good to know. I usually use my Mac Pro connected to my Leonardo and PowerBook to the other when coding, just to don't have to be switching between ports and boards on the Arduino app. Luckly, this time, I was too lazy to turn on the PowerBook and did all in the Mac Pro. I'll be on the safe side next time and ground both together...

I understand that this works with only 2 devices connected. More than this I'll need pull-up resistors connecting SDA and SCL to the 5V. I'm planning, in this setup, to add a I2C RTC to the Leonardo. So, will I need to make a pull-up from the  Leonardo's 5V, anyone or neither? Or this setup won't work at all?

Would you mind to share your source of information? I want to learn more about I2C from a complete source (I went crazy yesterday seeking for this information).

And how do I +Karma you? I can't see any button here for this...

Thanks a lot!

CrossRoads

Don't forget 4.7K pullup resistors on the SDA/SCL lines on one board (not needed on  both).
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

pylon

Quote
I understand that this works with only 2 devices connected. More than this I'll need pull-up resistors connecting SDA and SCL to the 5V. I'm planning, in this setup, to add a I2C RTC to the Leonardo. So, will I need to make a pull-up from the  Leonardo's 5V, anyone or neither? Or this setup won't work at all?


This works up to over 100 devices connected together (theoretically). You need pull-ups once per bus (again theoretically, for a few devices and a short bus this is correct). Adding the RTC should be no problem, just connect GND, SDA, SCL and Vcc (to power the RTC).

Quote
Would you mind to share your source of information? I want to learn more about I2C from a complete source (I went crazy yesterday seeking for this information).


There wasn't one single source of information, you get some experience if you work with it and read the forum  :).


Go Up