Having trouble with 16-relay board/power supply grounds

Hey all- I'm having some ground issues involving a large 12v power supply and the Sainsmart 12v 16-relay board... In addition to 16 relay control pins, it has 2 5v pins and 2 gnd pins (they are enough to power my ESP board)

Problem 1: If I connect everything as in the bottom drawing and plug in the power supply, all of the relays on my relay board (that are connected to my arduino) turn on for some reason... and they stay on. Nothing in my arduino code can turn them off. It feels really dead shorty.

If I disconnect the power supply from the VIN/GND of my arduino and instead power the arduino with a USB wall wart, aka use TWO power supplies... things work ALMOST okay. The relays on the board all turn on and off fine with the code I'm using, HOWEVER, my CO2 sensor is not giving me any readings (also doesn't seem to be getting enough voltage)!

If I remove the wallwart, unplug the power supply, and plug the arduino directly into my computer, and run a simple is-the-co2-sensor-working sketch, the co2 sensor is working fine.

I'm a little afraid to plug the power supply/relay board in AND connect the arduino to my computer at this point to see if the co2-sensor-working code still works.

I have a feeling there is a ground issue, but I'm not sure where to begin...and I should also add that my sensors are about 10 feet away from the arduino.

Any thoughts/glaring issues in this beautifully sketched diagram?

Image Link

You might want to wade through these posts first to better understand the problems around these 16-channel relay boards.
https://forum.arduino.cc/index.php?topic=365156.0
It might or might not relate to your problems.
Leo..

:o thanks Wawa. I probably have more questions than before, but I'll keep going through that post..... If anyone else has answers in the meantime... Don't be shy :slight_smile:

What CO2 sensor do you have? Gas sensors have heaters that take a lot of current and I suspect that it is too much current for the 5V regulator on your Mega, especially with the other sensors. Do you know what current they take?