Issues using 12V pump through relay module

Hi guys
I’m trying to control a 12V pump (YC DC12V 385) through a relay module while also using a flow sensor (YF-S401). The issue I’m having is if I turn on the relay (and thus the pump), the arduino stops working: the serial monitor stops printing the values from the flow sensor; every value from the flow sensor is absurd and unstable (even when there’s nothing going through the sensor); and I can only run another code if I plug off and on the usb to the board. The board is being fed by another external power source (not the same source as the 12V pump) and also USB to the pc. Also, if I turn on the relay without turning on the pump’s power source, there are no problems with the flow sensor and the board. And if I turn on the pump without going through the relay, also no issues occurring. These problems only occur when the pump is turned on through the relay.
I have tried using a flyback diode across the pump’s terminals and it relieved the issue but not completely. The board would still stop responding after a while (but it lasted longer with the diode there) and the values from the flow sensor were less absurd (but still far from satisfiable). What’s going on here and what can I do to solve this?

Few things I forgot to mention: I am currently feeding the relay with the same power source used to feed the arduino board, so the only cable connecting the relay to the rest of the circuit is the signal pin. Also, I have tried placing the diode between the arduino pin and the relay signal, but the issue still persisted. Last thing, even when the arduino stops giving me the flow sensor values, the code inside is still running. I made a code that turns on/off the relay every 20 seconds and it was still doing exactly that.

I have had similar problems switching on pumps and actuators

  1. are the relays opto-isolated from the microcontroller
  2. are the grounds of the various power supplies, laptop, etc common?
  3. use screened cables from relays to pumps

upload a schematic of the system?
give details of the relays?
what is the host microcontroller?

is the USB powering the arduino board or is it a separate power supply?
what happens if you power the relay from a separate supply?

I have approached the diode as close as I can to the pump and it made it so that the arduino won’t stop working and the flow sensors work way better, but it’s still not completely satisfiable. I think I need another solution

The arduino is being powered by the same power supply as the relay and also connected via usb to the pc

Ok I’ll make a schematic of the thing, but for now this is the relay I’m using:


Sorry for the low quality but here it is. If it’s hard to understand I can make a better one.
The power sources I’m using were old computer ones, so the red wires mean 5V and the yellow ones are 12V.

Since your pump power supply is 12V it would have made much more sense to use 12V relay. The Arduino can activate a 12V relay, but the power for the relay's coil would come from the 12V power supply instead of from the Arduino's 5V supply.

It sounds like the Arduino is struggling to power the relay with its 5V pin, which it had to regulate down from 12V. I think the Arduino's regulator is overheating and shutting down or unable to provide 5V to keep the Arduino running.

But rather than changing to a 12V relay, it makes much more sense to use a MOSFET like IRL44Z.

Where do you see that?

Wait, so the Arduino is powered from 5V?

What pin is the 5V power supply #1 connected to?

If the answer is the Vin pin or the barrel socket, those need at least 6.5~7V supply and won't work reliably with only 5V.

My bad, I meant the little colored things inside each power source boxes are meant to represent these wires which provide 5 or 12 volts. The arduino is fed by 12V

But for now I only have this relay module. Some other people here use this model too, but they don’t know what problems I am having. Approaching the diode to the pump is what helped me the most so far

Looking closer at your wiring, I think the relay is wired completely wrong.

It used to be connected normally to the protoboard and fed by the arduino but I connected it to another source to see if it helped. It still turns off and on when I want, so I thought the wiring was fine. What can I change in it?

I don't see anything. I am not in the room with @tiagoyp

You wired the Arduino to the relay contacts and the signal input to the pump. That's completely "backwards"!

Oh my bad I took a screenshot from google and apparently it’s backwards. The IN entry is connected to the arduino pin, DC+ and DC- are on the power source. On the other side, COM is connected to the power source and NO is connected to the pump +.

Your wiring diagram is totally confusing and incorrect.

Please post an accurate schematic. I will help further once you have posted that.

Ok, I’m going to make it when I get home, in about 40 minutes. I’m only gonna be able to actually change stuff on here on Friday, cause that’s when I come back to the lab