I have an Arduino and a bunch of components, among which, a dc motor (actually an aquarium pump) and a heater. These are connected via a relay module, so that the Arduino can switch on the motor or the heating element by tripping the relay. The circuit is laid out as follows:
As you can see, a battery pack supplies 6v to the Vin pin of the Arduino and to all the components.
However, the Arduino became unreliable as soon as the motor was switched on. I understand this has something to do with noise the motor introduces to the circuit. Figuring I could isolate both the motor and the heater completely from the rest of the circuit, I added a second battery pack and connected the heater and the motor to it via the relays:
This works! However, now I need two battery packs (and essentially double the batteries) to make this circuit work. How can I make this work using only a single battery pack that powers both the Arduino and all the components, but without the motor introducing "noise" (or rather, whatever the specific problem in that setup is)?
Edit: a diagram showing what I think is the situation where turning on the motor causes the Arduino to behave unexpectedly, followed by a diagram of the situation in which this doesn't happen but the motor requires a second, isolated power source: