What PSU do I need for 3 MEGAs and a Raspberry pi 2 in this config?

I am working on a project that involves a ton (>100) of switches. A program running on a raspberry pi 2B must be able to detect the state of each switch. The way I want to solve this is by connecting 3 MEGA 2560's to it, and using their pins in INPUT_PULLUP mode.

Note that a large amount of switches may be switched on at the same time (even all of them). Not sure if this affects the current draw of the arduino, since I don't fully understand the electronic side of the INPUT_PULLUP mode.

So my question is, is it okay to have the PI power all three arduinos through usb, or should I use a beefier power supply that can power both the arduinos and the pi? If so, what specs should I be looking for?

I have an other question regarding this project. Is there any reason why I shouldn't just connect all three arduinos to the pi with usb? Should I rather use some other method like I2C, or maybe chain the arduinos and use a single usb port?

EDIT:
I have since realized that some sort of multiplexing chip would have been a MUCH better solution for handling all the inputs, but I already have the three MEGAs so I'm gonna stick to this method for now.

Let's start with the basics. What type of switches and what are they switching and do they stay in the switched position or are they spring loaded so they return to the first position?

Paul

I'm using small SPDT switches that control two completely independent things: On one side they are used to add components (resistors, capacitors, coils, etc..) into a RCI circuit, and the other side is used to generate a live schematic and diagrams on the pi. This is why I need the arduinos, so the pi knows what schematic to draw. (this whole thing is intended for interactive physics teaching in schools; not my idea, i'm just realizing it for someone). When they're switched on, they stay on until i switch them off.

SparkyTD:
I'm using small SPDT switches that control two completely independent things: On one side they are used to add components (resistors, capacitors, coils, etc..) into a RCI circuit, and the other side is used to generate a live schematic and diagrams on the pi. This is why I need the arduinos, so the pi knows what schematic to draw. (this whole thing is intended for interactive physics teaching in schools; not my idea, i'm just realizing it for someone). When they're switched on, they stay on until i switch them off.

The reality is there will be a short time while the switch internal components are moving that there will be NO connection to either side of the switch and your Arduino will most like detect that condition. So, how are you wiring a switch so the Arduino will be able to detect the final resting place?

Paul

Paul_KD7HB:
The reality is there will be a short time while the switch internal components are moving that there will be NO connection to either side of the switch and your Arduino will most like detect that condition. So, how are you wiring a switch so the Arduino will be able to detect the final resting place?

Paul

I made a mistake, I meant DPDT not SPDT. The logic side and the actual RCI circuit are completely separate. On the arduino’s side I am only concerned about one of the two ‘throws’ since I only need to detect whether it’s on or not. As far as the wiring goes, I’m gonna connect the middle pin of the switch to GND and one of the other two pins (corresponding to the ‘on’ position) to an input pin on the mega. The third pin will not be connected to anything.

Something like this:

_
//
__

| DPDT | (this is supposed to be the switch, it looked better in the editor :/)

| | | ← not connected
| | ← GND
| ← An input pin on the mega

Ok, with debounce, that will work. You are dealing with "signals", not powering anything, so current usage does not change.

But, someone is going to come along and tell you with a few proper ICs, you can do the whole thing on the PI.

Paul

Yep, I’ve just found out that multiplexing is a thing. Thanks for the help. :smiley:

Paul_KD7HB:
But, someone is going to come along and tell you with a few proper ICs, you can do the whole thing on the PI.

Yeah, these!

Eight of them services 128 I/O pins connected to two I2C bus pins.
Not only cheaper and more compact than Mega2560s, but immensely easier to program! :sunglasses:

Debounce is performed eight bits at a time.