Go Down

Topic: How do I wire three i2c inerface devices together? (With separate power sources) (Read 793 times) previous topic - next topic

john09121

I'm new to I2c, and I have a sort of weird setup. Not sure how to wire these together:

I have 1 master arduino mega with its own power source, 1 slave arduino uno with its own power source, and a barometric pressure sensor. I want the uno and the pressure sensor to communicate with the mega through I2c.

How do I wire this together? When I connect all of the SCL and SDA wires together, the pressure sensor stops working.

The Mega and the Uno share a common ground. Is it a problem that they have separate power supplies?

Thanks in advance!

septillion

Connect all GND's together, connect all SCL's together and connect all SDA's together => Done!

Be sure to use the Uno as a slave with a different address. And don't use long cables...
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Coding Badly


john09121

Connect all GND's together, connect all SCL's together and connect all SDA's together => Done!

Be sure to use the Uno as a slave with a different address. And don't use long cables...
I have that exact setup, and it doesn't work :( The pressure sensor just won't work unless it's the only thing plugged into SDA and SCL.

How long is a "long" cable, and why would that affect things?

john09121


alnath

did you put pull-up resistors on SDA and SCL ?
if not, you should give it a try  (4k7 between +5v and SDA and 4k7 between +5V and SCL )

Did you try an i2c scanner to make sure the Uno and the sensor actually have different adresses and are both recognized ?

septillion

Long cables are 20cm+. I2C is not designed for rang. Although a lot of people use it with a couple of meters without a problem, to exclude this as the error only use short wires.

And as far as I can tell the module has all the level shifting on it so should work fine with 5V.

So, define does not work. How did you try to use it? Which sketches (multiple, both the Mega and Uno!).
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

john09121

did you put pull-up resistors on SDA and SCL ?
if not, you should give it a try  (4k7 between +5v and SDA and 4k7 between +5V and SCL )

Did you try an i2c scanner to make sure the Uno and the sensor actually have different adresses and are both recognized ?
I have two 5v power sources (one for each Arduino). Does it matter which one I connect the pull-up resistors to?


raschemmel

are you using unique Addresses for the devices ?
It won't work if you have duplicate addreses.

Do you  realize how absurb it would be to make an I2C sensor that will only work on a bus system if it is the only device on the bus ?

Go Up