Electronic – arduino – Where to put the Flyback Diode in a Relay Module

arduinodiodesrelay

I'm working with a relay module to switch a solenoid with an Arduino, Im having problems because the arduino get some noise in an LCD but I'm not sure where to put the diode, there is 3 pins, In, Vcc and GND. I think there should be a diode between In and VCC/GND but looking at the internet there is a diode between VCC and GND, shouldnt it be in the In because there is a direct connection with the Arduino?
Relay 5v
Edit1 (sorry for my bad drawing)

I add my diagram, this the connection with the problem, and it only get noise when the valve is connected with the 12v source
enter image description here

Best Answer

There is undoubtedly already a catch diode in that module, so adding one won't help one bit.

You should get a module with opto-isolation and supply the relay coil power from a separate power source with no connection to the Arduino power.

Also keep the wires to the contacts well away from the wires to the LCD module.


You should, however, connect a diode across the solenoid (assuming it is a DC type!) so that it is reverse biased.

If it is an AC type then there is not much that can be done. An RC snubber will help a bit, as will a MOV or TVS but they are not greatly effective in reducing this kind of electrical noise and things will only get worse as the contacts wear.