Using Power from two Arduinos

I am working on a big project that uses multiple infrared sensors, motors, solenoids, lights, and pushbuttons. I ultimately wanted to run everything using a 9V DC power supply through my Arduino MEGA. Last night my Arduino got really hot to the point you couldn't even touch the area by the DC power port on the board. I've realized that this is going to be way too much to power with my board. I have an Arduino UNO as well and I was thinking about using that with a 9V power supply as well so only half of the components will be powered by the Mega and the other half by the UNO.

I was having trouble because my infrared sensors for example, have a VCC GND and OUT pin. When I connected the VCC and GND to the UNO and had the Mega read the OUT it was getting a bunch of weird readings that were not correct.

With my motors and the NPN circuits when I used the 5V and ground from the UNO as the power supply and my I/O from the Mega to tell it to be on or off, nothing happened.

I was doing research on I2C and if that would be something that could work for this but it seems like it will overcomplicate a lot of this. I essentially just want to use the UNO as an extra source of power so I'm not pulling so much from the Mega alone. I would ideally want to keep all of my code on the Mega and have the UNO only for the power supply. Any advice on how to make this work? Thanks!

why do you need the second arduino to power it all
just use a high enough current power supply and use a voltage regulator circuit to each of the part that need power then you would be golden

My 9V power supply gives 2000mA, but isn’t the problem that I’m pulling too much current through the 5V rails and the VIN pin?

then dont use that 5V pin, make another 5Vpin using a voltage regulator ic circuit. then you just use the mega to be the brain and not be the supplier....

You cannot supply loads like a solenoid with an arduino at all. The arduino output pins like small currents, not big currents.
Even more than a few LED's is too much.

You need to learn how to use small currents from arduino to control external transistors or relays to supply
power to the other devices. If you have a big enough 9V power supply, you can take current from there direct
to the output side supply of the relay or transistor. That current doesn't go through the arduino at all.

If I cut the wire to a 5V DC power supply and used the power and ground rails on my breadboard to connect the components to it, would I even need a voltage regulator?

heres the thing the onboard regulator can only supply up to 500mA of current at one time b4 it dies. if you have any additional Voltage regulator, basically you are taking the load off the onboard regulator...

If I use the DC power supply to power this stuff should the ground be connected to the Arduino also or only the components I’m using to draw power from the power supply?

yes connect all the ground .... but be weary of ground looping ok
secondly make all the the component draw power form the power supply and the arduino only supply the signal