Water irrigation system - relay board dead

Hi all

I ordered a water irrigation kit from aliexpress and connected everything like so:

I use a modified 5V / 1A wall power supply with two cables to power everything (see schematics). The relays and water pumps are 5V DC.

The system worked beautifully for about 3 months, when suddenly one pump didn't stop pumping water and I had to shut down everything.

Assuming some loose contact, I checked/measured all connections, without success.
During the process I obviously made things worse, because the relay board LED and relays suddenly just lit up and started the pumps for a fraction of a second when drying capacitive sensors. This happened multiple times, and then the relay board did not lit up any LED's at all anymore.

Any suggestions on how to fix this problem are very welcome!

Thanks in advance for your help!

The following code has been uploaded on the Arduino uno:

int IN1 = 2;
int IN2 = 3;
int IN3 = 4;
int IN4 = 5;
int Pin1 = A0;
int Pin2 = A1;
int Pin3 = A2;
int Pin4 = A3;
float value1 = 0;
float value2 = 0;
float value3 = 0;
float value4 = 0;
void setup() {
Serial.begin(9600);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
- 8 -
pinMode(IN4, OUTPUT);
pinMode(Pin1, INPUT);
pinMode(Pin2, INPUT);
pinMode(Pin3, INPUT);
pinMode(Pin4, INPUT);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
delay(500);
}
void loop() {
Serial.print("MOISTURE LEVEL:");
value1 = analogRead(Pin1);
Serial.println(value1);
if(value1>550)
{
digitalWrite(IN1, LOW);
}
else
{
digitalWrite(IN1, HIGH);
}
Serial.print("MOISTURE LEVEL:");
value2 = analogRead(Pin2);
Serial.println(value2);
if(value2>550)
{
digitalWrite(IN2, LOW);
}
else
{
digitalWrite(IN2, HIGH);
}
Serial.print("MOISTURE LEVEL:");
value3 = analogRead(Pin3);
Serial.println(value3);
if(value3>550)
{
- 9 -
digitalWrite(IN3, LOW);
}
else
{
digitalWrite(IN3, HIGH);
}
Serial.print("MOISTURE LEVEL:");
value4 = analogRead(Pin4);
Serial.println(value4);
if(value4>550)
{
digitalWrite(IN4, LOW);
}
else
{
digitalWrite(IN4, HIGH);
}
Serial.println();
delay(1000);
}

How many amps do the pumps draw ? is 1A enough ?

given the pumps are inductive loads, I would start adding a freewheel diode for each of their power supply line.

perform small tests

  • verify the Arduino digital output works as expected. Use a resistor and a led and test output 2, 3 4 and 5 to see if you can blink the led

  • verify the Arduino analog input: write a small code showing looping and printing the value of Analog(A0) and connect with a wire A0 to GND, 3.3V and 5V. see if the console shows 0, ~680 and 1023. repeat with A1, A2 and A3

  • test the relays individually wire the resistor + led at the output of one relay driven by pin 2 (don't connect anything else) . upload a blink program blinking pin 2. see if the led blinks. repeat for the 3 other relays.

  • test the pumps individually. add the freewheel diode and lightly touch the 5V and GND wires. The pump should trigger

then connect things one by one (like sensor 1, relay 1, pump 1) and test them together.

What does this mean exactly? Water on electronics?

Hi,
Write some code that just cycles the relays, this will make sure you have control and that the UNO and relay module are still able to function.

Tom... :smiley: :+1: :coffee: :australia:

By the way, I had written a small class named AutomaticPump to handle such a simple automatic pump which was making the sketch super easy to write.

Each pump has a name, a relay pin and a sensor pin (and optionally a threshold which defaults to 550). you build an array of such pumps and the only thing you need to do is begin all the pumps in the setup and update all the pumps in the loop.

something like this:

/* ============================================
  code is placed under the MIT license
  Copyright (c) 2024 J-M-L
  For the Arduino Forum : https://forum.arduino.cc/u/j-m-l
  ===============================================
*/

#include "AutomaticPump.h"

AutomaticPump pumps[] = {
  // name, relay, sensor
  {"Green bean", 2, A0},
  {"strawberry", 3, A1},
  {"Old Tomato", 4, A2},
  {"Zucchini",   5, A3}
};

void setup() {
  Serial.begin(115200);
  AutomaticPump::beginAll();
}

void loop() {
  AutomaticPump::updateAll();
  delay(5000);
}

the output would be something like

Configuring the Green bean pump.
Configuring the strawberry pump.
Configuring the Old Tomato pump.
Configuring the Zucchini pump.
--------------------------------
Green bean	1023	ON
strawberry	1023	ON
Old Tomato	456	    OFF
Zucchini	398	    OFF
--------------------------------
Green bean	1023	ON
strawberry	1023	ON
Old Tomato	451	    OFF
Zucchini	452	    OFF
--------------------------------
Green bean	1023	ON
strawberry	1023	ON
Old Tomato	454     OFF
Zucchini	451     OFF
--------------------------------
...
click to see the source files for the class, to add in the same sketch folder

AutomaticPump.h

/* ============================================
  code is placed under the MIT license
  Copyright (c) 2024 J-M-L
  For the Arduino Forum : https://forum.arduino.cc/u/j-m-l

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  ===============================================
*/

#ifndef AUTOMATICPUMP_H
#define AUTOMATICPUMP_H

#include <Arduino.h>

class AutomaticPump {
  public:
    AutomaticPump(const char * name, const byte sensorPin, const byte relayPin, const float moistureThreshold = 550);
    ~AutomaticPump();

    void begin();
    void update();
    static void updateAll();
    static void beginAll();

  private:
    const char * name;
    byte sensorPin;
    byte relayPin;
    float moistureThreshold;
    AutomaticPump* nextPump;
    static AutomaticPump* headPump;
};

#endif

AutomaticPump.cpp

/* ============================================
  code is placed under the MIT license
  Copyright (c) 2024 J-M-L
  For the Arduino Forum : https://forum.arduino.cc/u/j-m-l

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  ===============================================
*/

#include "AutomaticPump.h"

AutomaticPump* AutomaticPump::headPump = nullptr;

AutomaticPump::AutomaticPump(const char * name, const byte sensorPin, const byte relayPin, const float moistureThreshold) :
  name(name), sensorPin(sensorPin), relayPin(relayPin), moistureThreshold(moistureThreshold), nextPump(nullptr)
{
  if (headPump == nullptr) headPump = this;
  else {
    AutomaticPump* current = headPump;
    while (current->nextPump) current = current->nextPump;
    current->nextPump = this;
  }
}

AutomaticPump::~AutomaticPump() {
  if (headPump == this) headPump = nextPump;
  else {
    AutomaticPump* current = headPump;
    while (current->nextPump && current->nextPump != this) current = current->nextPump;
    if (current->nextPump == this) current->nextPump = nextPump;
  }
}

void AutomaticPump::begin() {
  Serial.print(F("Configuring the "));
  Serial.print(name);
  Serial.println(F(" pump."));

  pinMode(sensorPin, INPUT);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
}

void AutomaticPump::update() {
  int v = analogRead(sensorPin);
  v = analogRead(sensorPin);
  if (v <= moistureThreshold - 10) {
    digitalWrite(relayPin, HIGH);
  } else if (v >= moistureThreshold) {
    digitalWrite(relayPin, LOW);
  }

  Serial.print(name); Serial.write('\t'); Serial.print(v);
  Serial.write('\t'); Serial.println(digitalRead(relayPin) == LOW ? F("ON") : F("OFF"));
}

void AutomaticPump::updateAll() {
  AutomaticPump* current = headPump;
  while (current) {
    current->update();
    current = current->nextPump;
  }
  Serial.println(F("--------------------------------"));
}

void AutomaticPump::beginAll() {
  AutomaticPump* current = headPump;
  while (current) {
    current->begin();
    current = current->nextPump;
  }
  Serial.println(F("--------------------------------"));
}

Thank you all for your detailed replies, much appreciated!

I probably should have mentioned that I am an absolute beginner with Arduino projects and as of now only into copy/paste code / changing threshold values rather than understanding any of it.

Therefore, I am interested to learn if there is something wrong with my current setup or can I simply order a new relay board and try again. Cause I really liked it when it worked :slight_smile:

To answer your questions:
How many amps do the pumps draw ? is 1A enough ? The pumps are specified max. 100 mW each.
Water on electronics? No.

As for my power supply setup, do you think that this is ok?

Thanks again!

Post pics of your setup.

Do you have a volt meter? Measure the 5V to assure the power supply is still putting out 5V.

Modify your code to where only 1 pump will run at any given time.

As mentioned before, place a diode across each pump.

Yes, please post links to the technical information for all of the devices in your setup. As for your Uno, I suspect it may be fried—likely due to a transient when the power supply collapsed.

Consider using a larger power supply or a separate one for the electronics to avoid similar issues in the future. What did you use to power this setup? Based on your description, your current solution doesn’t seem reliable, and the fact that it worked for as long as it did is surprising.

Also, double-check the voltage requirements for the Vin pin. Supplying 5V is on the low side and might not be sufficient for stable operation.

Hi all

I took out pumps/sensors of the water and got everything ready to measure the voltages as per your suggestions, when I was greeted with a nice surprise. Upon powering up, the relay board came back to life (was dead all day yesterday), all LED's were steady red and all 4 pumps where running (correct action due to the dry sensors).
Of course, I immediately switched off everything to prevent the pumps from damage.

I am interested in your ideas for a permanent solution.
Do you assume the current power supply to be on the weak side and therefore causing the problems?
I have a lab power supply as well as a 5 V / 2 A power supply similar to the current one available. Shall I use one or two power supplies and with what settings?
My initial idea was to operate everything with one PoSu in order to occupy only one power outlet and reduce the no. of cables.

Sorry for not being able to provide more tech specs than already shared, I could not find info on the components used in this aliexpress kit.

I will insert the diode across each pump as suggested in the next build.

Thanks again for providing help to a beginner, this is very kind of you all and much appreciated.

As per your request, here are some photos of my proto build:





A wall adapter rated 1 A sounds a bit thin yes.

Edit: One PSU will be enough. If one part fails in your system, what good are the rest?

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