Relay creates a voltage drop and messes with sensor

Hey everyone, I am building a small automated watering system, where I use a moisture sensor and a relay (to activate a pump to water the plant). Everything works fine, except that the sensor values jump when the relay is turned on. I checked the voltage on the relay and noticed a drop when the relay is active (from 4.9V to ~4.5V).

I have basic knowledge in electronics, but I don't really understand why the voltage is dropping in the first place. I guess Ohms Law doesn't apply here, but is there a way to explain what's happening?
And also shouldn't there be some sort of voltage regulation on the Arduino side to ensure constant 5V?

So obviously the voltage drop messes with the sensor.
I also saw this Video about the flaws of cheap moisture sensors, and of course my sensors doesn't have a voltage regulator on board (as mentioned there as the first problem). So the faulty values make sense, when the input voltage changes.

To solve the problem, I guess one way would be to just use a MOSFET instead of the relay, or to add the missing voltage regulator to the sensor. Or is there another option?

And for completeness, I use:

Does it act funny if the pump is not connected to the relay?

The problem also appears when the pump is not even connected to the relay.

If you have the sensor without the regulator, then you should power it from the 3.3V pin. I'm not sure if you damaged it by connecting it to 5V

I was wondering about that, but didn't have time to test it yet. So the 3.3V should stay constant if the relay is active and powered over the 5V? That's one thing I wasn't sure about, because I don't understand why the 5V voltage is even dropping in the first place.

The image you show for the relay says 12V on it.
Is that the actual relay you have?
If it is 12V that is the problem.

Make sure you have 2 power supplies. One for the relay and one for the UNO. Common the grounds though.

So did you indeed have the wrong relay?

If that were a complete list, the circuit would do nothing, since there is no power.

Did you forget to mention that the circuit is powered from a pc or laptop or an AC PSU with 5V output with a USB cable?

If so perhaps the USB cable is not good quality and it is dropping some voltage when more current is drawn by the relay (according to Ohm's law). Try some other USB cables. Thicker wire may indicate better quality.

The pump will draw even more current than the relay, when it's running, and even more voltage drop. Potentially enough voltage drop to cause the Arduino to reset. Potentially more current than the PC/laptop will allow (normally max 500mA).

While this indicates that you have a power supply problem of some kind, which needs addressing, you should know that you should not be reading the sensor while the relay/pump is on!

It takes time (probably 5 minutes plus) for water to absorb into the soil and for the sensor to reach a new steady reading. So your code needs to run the pump for a short time (like 30 seconds or 1 minute), then wait at least 5 minutes before taking another reading and deciding if it needs to run the pump again.

If you run the pump and read the sensor until the sensor output level reaches some desired reading, you will simply flood the plants.

One more thing: if the pump and the rest of the circuit share a common ground, you must add a flyback diode across the pump connections. Anode to ground, any 1N400x diode will be ok.

sorry, no the picture is not right, i have the right relay for 5V. But otherwise it looks the same.

Are you using a solderless breadboard for connecting the relay and sensor?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.