Soil moisture sensor affected when pump+valve relays ON

Hello everybody!

I am trying to build an irrigation system but I am not very good in electronics.

I have an Arduino Nano powered by an external power supply through the 5V pin.
I have a soil moisture sensor and a temperature sensor connected.
I have a pump and a valve that are controlled using two relays. The pump and valve are 12V devices and take the power from an external 12V power supply. The relays are powered by the same 5V that powered the arduino.

So, when the relays are off the soil moisture sensor reads ok. When the relays are on the reading is lower. For instance, having the sensor at open air the reading passes from 0% to -10%.

I believe I have to change the power supply connections, but I have no idea what would be the right way to avoid this issue.

At the end, the idea is to connected 5 soil moisture sensors, 1 temperature sensor, 5 valves and a pump.

Thanks in advance for the help!

You need to power the relays separately. Any change in the supply voltage to the Arduino will change the analog input reference voltage, by default.

I suggest to use 5V step-down regulators so that everything is powered by the 12V supply.

Connect all the grounds, and make sure that you have an inductive kick diode on the pump.

Thank you for the reply!

jremington:
You need to power the relays separately. Any change in the supply voltage to the Arduino will change the analog input reference voltage, by default.
I suggest to use 5V step-down regulators so that everything is powered by the 12V supply.

Isn't it the same that I have already done? From the image that I uploaded, you may see that I supply the breadboard by a 12V, the 12V is regulated to 5V and 3.3V. The arduino and relays get the power from the 5V.
I understand that I need to power the relays separately, but I do not get how to power arduino and relays from the 5V step-down regulator.

jremington:
Connect all the grounds, and make sure that you have an inductive kick diode on the pump.

Is this used to protect against the reverse current of the pump?

From the image that I uploaded

The images are incomprehensible. Please post a hand drawn wiring diagram or schematic.

The diagram below shows how the essential inductive kick diode is wired, using a MOSFET to control the pump power.

What pump are you using? I can't read the specs on it.

I'm in the middle of a nearly identical project.

-jim lee

jremington:
The images are incomprehensible. Please post a hand drawn wiring diagram or schematic.

Could this fritzing diagram help? It is a simpler version (less sensors and actuators) but this is how it is wired.

jimLee:
What pump are you using? I can't read the specs on it.

Looks great!!

I am using this pump: https://it.aliexpress.com/item/32960386654.html?spm=a2g0s.9042311.0.0.27424c4dSqbz2t

From the looks of the specs. You could just use this : Adafruit motor driver This is what I did. I have them all running for weeks now with no issues. Mine also uses this as the 5V supply : RC power supply.

I take the 12V & Gnd. to both 5V supply and the motor driver.
5V & Gnd from the supply to the µprocssor. Then only the ONE digital line from the processor to the motor driver. Ground out the other driver data line. Hook up motor, done.

Easy peasy. No relays and stuff to make life complicated.

-jim lee

Could this fritzing diagram help?

No, Fritzing diagrams are almost always misleading, if they aren't simply useless.

jimLee:
I take the 12V & Gnd. to both 5V supply and the motor driver.
5V & Gnd from the supply to the µprocssor. Then only the ONE digital line from the processor to the motor driver. Ground out the other driver data line. Hook up motor, done.

This sounds very clear! I will try setting up the power lines as you did but keeping the relays. If still won't work, I'll buy the motor drivers.
Thank you very much!