How to connect 7 Arduino slaves to 1 Rpi master via I2C

Like the title says, I would like help connecting multiple slaves to an Rpi. I have got the basics down, but the actual circuitry is confusing me. I understand that they operate at different voltages, but what should I do to fix that? And what resistors do I use, and where do I put them? What is a level shifter and how do I use it? TY for any help.

Resistors cannot be used to level shift I2C. You a need specific I2C bi-directional level shifters, common stuff from Adafruit/Sparkfun/China.

The most important question is how far apart are all these devices? The fact that they’re all separate modules leads me to believe you’re already in well over your head with this design. How about a few more facts about what you’re trying to achieve?

Luckily they will all be very close to one another, I'm predicting within 3 feet. And I would like to use the Rpi as a single wireless Access Point rather than 8+ AP's. That's about it, I would like to send commands and receive commands. I appreciate the help, but I just want to learn about I2C. I do not want to redesign everything.

I smell an XY problem.

Tell us why you think you need that many Arduinos.
There might be another/better solution.
Leo..

3 feet is a lot for I2C.

Three feet is not a problem for I2C, but 7*3 feet could be a problem.
Leo..

I'd rather not share why I need that many connected, I would rather learn how to connect it. Everything I need to do is done with 7 arduinos(this is the last part of the build), the only problem is there is no way to communicate to a computer wirelessly. I understand that you're trying to help, but I would love to focus on the original question. How to connect 1 Rpi to 7 arduino slaves.

Why would 7 arduinos on a 3 foot connection be a problem? Would the problem be different if it was 1 foot connection?

What matters is the total wire length on the I2C bus.

Don't know if the 3.3volt I2C bus of the Pi can handle seven sets of 5volt pull ups (assuming you're using 5volt Arduinos). Guess there's only one way to find out.

An alernative could be an 8-channel I2C muxer with buildin level shifters.
Leo..

Ok, so I am confused on the pullup resistors you mentioned.

I have tested one arduino with a direct connection shown here Raspberry Pi and Arduino Connected Using I2C - Oscar Liang

where would I put a resistor? or is there one built into the Pi?
What is the typical way to connect a couple arduinos to an RPi

On some Arduinos wire.h pulls the pin up to 5volt, on other Arduinos physical pull up resistors to 5volt are used.
If you don't want to share details, then you have to work that out for yourself.

Never used a Pi.
Maybe someone else here knows how the Pi pulls up the I2C lines.
Leo..

I'm wondering if what I am currently looking at might make your answer a lot simpler. RS-485 module for Arduino (MAX485 )

If you put one of these on each Arduino and one on the RPi it might allow the communication you want without you needing to work out complicated circuitry.

CodeCruncher:
I'm wondering if what I am currently looking at might make your answer a lot simpler. RS-485 module for Arduino (MAX485 )

If you put one of these on each Arduino and one on the RPi it might allow the communication you want without you needing to work out complicated circuitry.

Thank you, that sounds great. It states that the working voltage is 5v which might be the same problem that i2c has with the rpi. But I'm hoping someone will clear that up.

In the case of your code on each of the Arduinos, you may need to do a bit of back peddling to make it work. You need to have all of the hardware talking to each other first before you can send anything down the line. If your code is not written in a way that works with the underlying structure it may never work. i.e. the Master (RPi) polls the Slave for information, and if your Arduinos are trying to push information down the Master's throat it might just ignore the communication.

So you need to get a simple program working where the Master and Slaves are talking to one another first. Then overlay whatever program / functionality you have the Arduinos doing next.

tisbeme:
Thank you, that sounds great. It states that the working voltage is 5v which might be the same problem that i2c has with the rpi. But I'm hoping someone will clear that up.

If you have all of the devices within a few feet of each other you could potentially power all of them off one external larger 5v PSU. Not that I would expect them to use much power (sorry the system is making me wait 5 minutes to post this).

avr_fred:
Resistors cannot be used to level shift I2C. You a need specific I2C bi-directional level shifters, common stuff from Adafruit/Sparkfun/China.

The most important question is how far apart are all these devices? The fact that they’re all separate modules leads me to believe you’re already in well over your head with this design. How about a few more facts about what you’re trying to achieve?

I just bought one, thank you for the suggestion. I will update this post letting everyone know if it works for what I want.

CodeCruncher:
If you have all of the devices within a few feet of each other you could potentially power all of them off one external larger 5v PSU. Not that I would expect them to use much power (sorry the system is making me wait 5 minutes to post this).

Hopefully my code works well the master only requests "status updates" every once in a while(to which the slaves respond), and will send commands when it needs to. And the address is determined by the code, so hopefully everything is good. Thank you for the speedy update, and the psu idea is solid. I'm scared I will wire it up wrong and regulate the power with one arduino. But I will try it out. Thank you for the speedy responses, I am running into the 5 min delay too :).

Don't regulate the power with one Arduino (regulate means you're going to use a higher than 5volt supply).
Use a 5volt power supply, and connect it to the 5volt pin of all Arduinos.
If we only knew which Arduino's you are using...
Some have quirky things, like a Nano powered through USB.
Leo..

I'm using 7 arduino unos. And I was hoping to power it with the power jack/barrel? I was gonna use 9v? But there's an internal regulator I am worried about frying. But that isn't the point of this thread. I'm sure the wiring is somewhere

Is there a reason not to use a mains powered PSU? Can't see a battery lasting long power 7 devices.

CodeCruncher:
Is there a reason not to use a mains powered PSU? Can't see a battery lasting long power 7 devices.

There are 9V wall warts. Possibly other 9V supplies as well, did not look. Nobody mentioned batteries (yet) :wink: