Powering Arduino other than USB?

I have more I/Os I want to control than my Raspberry Pi 4B can handle. So, I'm using Arduino Mega 2560 as an extension to my RPi IO controls. The two are connected via USB. I don't want RPi to power the Arduino. In fact, RPi refuses to power up if Arduino is connected. Once, the RPi boots up, I can connect the USB and work with Arduino.

I read some threads indicating that if I apply power to VIN or PWRIN, then Arduino would not draw power from USB. However, I'm experiencing just the opposite.

I have an external power supply that would display the current drawn, and it is powering the Arduino via PWRIN at 5VDC. Arduino draws 50mA from the external power supply when the USB is not connected. When I connect the USB, the external power supply current goes to zero.

So, is there was to prevent Arduino from drawing most of its power from USB?

Regards,
Tim

Interesting, it looks not very difficult to accomplish. I do not do well with word problems but schematics are great. Why not post an annotated schematic showing all connections including ground, power, and power supplies.

It's not that complicated.

RPi==== usb not connects ===== | Arduino USB
Ext Power ==== ( 50 mA ) ======| PwerIN

When USB is connected
RPi =======================| Arduino USB
Ext Power ==== ( 0 mA ) ======| PwerIN

What I like to see is
RPi =======================|Arduino USB
Ext Power ==== (50 mA) ======| PwerIN

How to get Arduino to use an external power supply when USB is connected? I don't want Arduino to depend on USB power.

Regards,
Tim

Most of us would be using port expanders, not a second processor.

What do you mean with that.
The V-in pin needs 6volt minimum, the DC socket needs 6.7volt minimum.
5volt power is only ok on the USB socket and the 5volt pin.
Leo..

Thank you Wawa!!

It looked like if I applied over 7VDC did the trick. I will use 12V.

Regards,
Tim

With 12volt on V-in you can't draw more than about 100mA total from the pins of a Mega.
Otherwise the 5volt regulator will overheat and you will get constant restarts.
So what have you connected to it.
Leo..

For clarity.
The current you can draw from the 5V regulator on the Arduino is inversely proportional to the voltage provided to the regulator. By that we mean, if you supply the Arduino via VIN with 7V, you can draw much more current than if you supply VIN with 12V. This is because the regulator is dropping that extra voltage at the current you are drawing, but there is a fixed upper limit on the power it can dissipate, so Vdrop*Iload is a fixed value; if Vdrop decreases, Iload can increase. This appears to be too complicated a scenario for the Arduino designers to document for beginners, otherwise it would probably have been described in the documentation for each Arduino.

But there are serious limits. Do the math on your loads, come up with a max current required value. (for example, 50 LEDs at 10 mA is 500 mA, probably well beyond what the Arduino will tolerate, even with a 7V source on VIN).

To get past this, you may supply the 5V connection of the Arduino with an external 5V supply, and/or supply your loads directly with 5V. The latter is the preferred route.

Why not tell what the max wattage the regulator can dissipate for each board and what the board load is. Then multiplying the voltage drop across the regulator time the current will give them the number that must be below what you determine is the max. Also consider ambient temperature. For those week in math there are online calculators that will carry the load for them.

Likely considered to be beyond the pale for newbies, but I agree that's what should be done. The Intro material (about as far as most read, well beyond what some venture into) is so superficial as to be ridiculous. But then, that just reflects the marketting target. "anyone can do it".
Not a complaint, by the way, it's a business choice, I've seen far worse. But it isn't helpful once the user goes beyond adding a resistor and a LED.

Thank you all for your input!

I'm driving 12V into PWRIN, not VIN. According to the Arduino document, VIN has 160mA limit, but PWRIN has 750mA limit. However, I'm not sure what to believe, because using a multimeter, VIN and PWRIN are shorted.

I'm using Arduino to drive some relays

I don't know how much current the optocouplers will draw, but I'm going to do some tests to find out.

Thanks!
Tim

checking the schematic,
Mega Schematic
The PWRIN pin connects to VIN via a diode, and nothing else. So I'd say there's only one current limit.
The 140 mA would likely be an attempt to describe what the board can power in addition to itself, though I'm just guessing. The 750 mA is likely what the Arduino draws from the external supply, probably including the 140 mA for peripherals.
Bear in mind, though that we know nothing about the conditions which would support 140 additional mA - it may only be capable of that between 7 and 9V PWRIN, for example. There's just not enough information.
Hope that helps, somehow.
Maybe, if you point us at the "Arduino document" you're looking at, we can help further.

The DC socket of a Mega has a reverse protection diode in series, with a 1Amp current limit.
The other side of the diode connects to V-in.
So in theory you could send 1A from DC socket to V-in.

V-in connects to the 5volt regulator that powers the Mega (and whatever you connect to it).
That 5volt regulator has an 800mA current limit.
It also has thermal limits, which are usually reached before it's current limit.
Max current for thermal limit (rebooting or smoke) is input voltage dependent.
With 7volt on the DC socket it's about 700mA. with 12volt about 200mA.
Less in a hot environment (enclosure).
The Mega uses 70mA of that for itself, so only <130mA could be left for sensors etc.

Common 8-channel relay board with opto couplers:
2mA signal current (sink) and 75mA coil current per relay.
Means you can control the module with a Mega, but you must power it from a different 5volt source.
If you remove the jumper and you don't share grounds, then you have opto isolation.
JD-VCC is relay coil power, VCC is opto LED power from the Arduino.
Leo..

Wow!! Thank you Leo and Camsys!!

Great info!
Tim

Thanks, Wawa, for detailing and cleaning up my generalizations.