So, my goal is to start my water pump whenever the soil level drops below 40 % for example.When I try to plug in my 5V Relay so the pump can start and work the problem begin.
The 3.7V battery in the right is only to test if it would work powered by a Li-Ion battery.
The circuit works if I don't use the water pump and the relay.
Any advice would help!
Hi,
I didn't identify where the bomb is in this drawing you posted.
Fritizing might be good for beginners, but using it as a reference to ask for help is pretty bad.
What is happening is that the relay, when turning the pump on or off, generates a lot of electrical noise.
To soften this problem, make use of a snubber connected in parallel with the motor.
I do not read frizzy but from your description you need a better power supply and from what I can see in what you posted you have lots and lots of antennas connecting noise to the Arduino. I would use a Avalanche rated logic level MOSFET as a low side driver for the pump and get rid of the relay. Just be sure to put the pull down resistor on the port pin not on the MOSFET as shown in most drawings. Also posting links to "Technical" information on all of your hardware devices helps a lot.
If the motor is less than one amp you can place a 1N400x diode across the motor where the band on the end is connected to +. If it is more current then the diode should be able to handle the motor current. This may also help a .01 to .1 cap across the motor if you have one. Be sure all the grounds are connected, I cannot see that clearly in the frizzy picture. FYI when varistors adsorbe energy the active material is consumed and eventually they will fail. You might try to do a simple schematic to get the feel. If you want a CAD program there are many available free, I use KiCad it takes me from schematic capture to a PCB layout. It is not a 1 weekend learning experience.