5V water pump chrashes arduino or influences inputs

Hi everyone,

some time ago I started to build myself a watering system for my plants, but there is one problem I am not able to solve.

The culprit are these cheap 5V mini pumps (Link to Aliexpress). Everytime a trigger the pump, the input values read from the moisture sensors are forced to zero or the whole arduino crashes. I do not have the problem when I am using the more expensive pumps (Link to better pump on Aliexpress).

At first I was using a TIP120 transistor to switch on the pumps, but than thought that the crashes might be caused by some backlash into the circuit. Because of this I switched to a relay board with optocouplers. I also added a potentiometer to check the anlog inputs, but this does not seem to be influenced by the pump for some reason.

Unfortunately the problem still happens and I am at my wits end.

I hope you can help me figure this out.

#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
 
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);

int water = 0;
int air = 488;

int humidityRaw[6] = {0, 0, 0, 0, 0, 0};
int humidityReal[6] = {0, 0, 0, 0, 0, 0};

void setup() {
  Serial.begin(115200);
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
  pinMode(8,INPUT);
  pinMode(9,INPUT);
  pinMode(13,OUTPUT); //Set pin 13 as OUTPUT pin
  pinMode(12,OUTPUT); //Set pin 13 as OUTPUT pin
}
 
void loop() {

  humidityRaw[0] = analogRead(A0);
  humidityReal[0] = map(humidityRaw[0], air, water, 0, 100);
  delay(20);

  humidityRaw[1] = analogRead(A1);
  humidityReal[1] = map(humidityRaw[1], 0, 1022, 0, 100);
  delay(20);

  int push1 = digitalRead(2);

  if (push1 == 1){
    digitalWrite(13,HIGH);
  }
  else {
    digitalWrite(13,LOW);
  }


  delay(200);
 
  //clear display
  display.clearDisplay();
 
  // display temperature
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Humidity: ");
  display.setTextSize(2);
  display.setCursor(0,10);
  display.print(humidityReal[0]);
  display.print(" ");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print(" %");
  
  // display humidity
  display.setTextSize(1);
  display.setCursor(0, 35);
  display.print("Humidity: ");
  display.setTextSize(2);
  display.setCursor(0, 45);
  display.print(humidityReal[1]);
  display.print(" %"); 
  
  display.display(); 
}

English link for the pumps. So they draw a nominal 200 mA, but probably up to an Amp as they start up.

Well, the TIP120 version is a dead loss as it is a Darlington transistor and you show it wired as an emitter follower. The proper component, wired in the negative motor lead, is a logic-level FET.

I would suspect the problem is your mystery 5 V power supply and how you have wired it. :roll_eyes:

Hi Paul,
thank you for the fast feedback.

If I understand you correctly the TIP120 should be wired up as in the new picture bellow.

As a second power supply I used either a Anker USB brick pluged into my custom board or a breadboard power supply.

gatrixx2k:
If I understand you correctly the TIP120 should be wired up as in the new picture bellow.

Erm, no!

Well almost. The TIP120 should actually be relocated in a museum.

You need a logic level FET in that position to control a pump motor. An AOD4184 would be suitable.

gatrixx2k:
As a second power supply I used either a Anker USB brick plugged into my custom board or a breadboard power supply.

Sorry, I cannot see anything there that resembles a 5 V power supply suitable for pumps. If you are referring to this unit

... then it can power about three of the pumps from one output and another three from a second.

How many of these pumps do you propose to use?

I will order some of the AOD4184 to test them.

The power brick I am using at the moment is the Anker PowerPort+1 (3A at 5V).
The board will have up to 6 pumps connected at some point. But I will only ever run one of them at the same time (coded with priority for the different pumps and check that no other pump is already running).

What I do not understand is why the pump could influence the arduino even when I am using the relay with optocoulter (JD-VCC and no shared ground). Even the 5V supply power for arduino and relay plus pump are to separate Anker USB bricks.

Wires routed next to one another, or in a disorderly mess, can easily cause all kind of interference through capacitive coupling.

Also if you power all the things from the same USB supply (even on different USB ports) the grounds will be connected through the USB wires, and that JD-VCC jumper and optoisolation are not doing much any more.

wvmarle:
Also if you power all the things from the same USB supply (even on different USB ports) the grounds will be connected through the USB wires, and that JD-VCC jumper and optoisolation are not doing much any more.

I am not powering both from one supply/ USB brick. I use two separate USB power bricks. The only shared "ground" would be the neutral conductor of the wall outlets.

I even tried using a powerbank as the secondary power source.

gatrixx2k:
The only shared "ground" would be the neutral conductor of the wall outlets.

I definitely hope not. :astonished:

If it has a three pin IEC connector, only the protective ground should connect to the USB sockets, if that. :astonished:

gatrixx2k:
I even tried using a powerbank as the secondary power source.

As wvmarle points out, "lead dress" is a critical matter when we are dealing with systems which operate at HF radio frequencies. Swathes of jumper wires flowering from a breadboard may work with simple projects, but once you start talking about any degree of power being switched, you need to keep the wiring neatly bundled with each power or signal line together with its ground return and inputs separated from outputs where possible.

Hi,
Can you please post a picture of your project with everything connected?

Thanks.. Tom.... :slight_smile:

TomGeorge:
Hi,
Can you please post a picture of your project with everything connected?

Thanks.. Tom.... :slight_smile:

Hi Tom,
For testing purpose I switched to 3 power supplies:


The USB brick powers the arduino, the bread board supply powers the relay and the power bank powers the pump.

Here you can also get a closer look at the breadboard:

Even with three separate power supplies the arduino sometimes crashes when switching the pump on or off. But it is more stable like this and I do not see the drop of the A0 input anymore.

I just got some some boards with AOD4184 and optocouplers and it is now working like a charm. Thank you all for your help =)

Good pick. I frequently recommend something similar from AliExpress.

It looks like that one even included the "kickback" diode for you (badly assembled). I'll have to examine it more closely later.

Ohh, great :o connections. You might have used some transistors or relays insted.

vishkas:
Ohh, great :o connections. You might have used some transistors or relays insted.

I'm just curious what relays would you have suggested instead of the one shown in the beginning of the post?

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