Relay not working right when powering pump

Hello, I have a problem. I am trying to read 3 sensores and if one of them is under a certain value, a pump should be powered. Everything works, until i connect the pump to the relay. when doing so, the arduino stops sampling and powers all 3 pumps one after one. I have tried to power the relay module with the second power supply, I have tried it with and without a common ground, nothing did work. I don't think it is a program error as it works if the power supply of the pumps is not active.

This is my relay module:

The Circuit:

The Code:

int t1 = 600;       // Zeit zwischen Proben in ms

int Sensor1 = A0;
int Sensor2 = A1;
int Sensor3 = A2;


int messwert1 = 0;
int prozent1 = 0;

int messwert2 = 0;
int prozent2 = 0;

int messwert3 = 0;
int prozent3 = 0;


int messwert1max = 635;
int messwert1min = 260;

int messwert2max = 637;
int messwert2min = 264;

int messwert3max = 637;
int messwert3min = 266;



int Pumpe1 = 2;
int Pumpe2 = 3;
int Pumpe3 = 4;


int tp1 = 1000;
int tp2 = 1000;
int tp3 = 1000;


void setup() 
{

  Serial.begin(9600);

  pinMode(Pumpe1,OUTPUT);
  pinMode(Pumpe2,OUTPUT);
  pinMode(Pumpe3,OUTPUT);
}






void loop() 
{

  messwert1=analogRead(Sensor1);
  messwert2=analogRead(Sensor2);
  messwert3=analogRead(Sensor3);

  prozent1 = map(messwert1,messwert1min,messwert1max,100,0);
  prozent2 = map(messwert2,messwert2min,messwert2max,100,0);
  prozent3 = map(messwert3,messwert3min,messwert3max,100,0);

  if(prozent1 <= 70)
  {
  digitalWrite(Pumpe1,HIGH);
  delay(tp1);
  digitalWrite(Pumpe1,LOW);
  }

 if(prozent2 <= 70)
  {
  digitalWrite(Pumpe2,HIGH);
  delay(tp2);
  digitalWrite(Pumpe2,LOW);
  }

 if(prozent3 <= 70)
  {
  digitalWrite(Pumpe3,HIGH);
  delay(tp3);
  digitalWrite(Pumpe3,LOW);
  }

  Serial.print(prozent1);
  Serial.print(", ");
  Serial.print(prozent2);
  Serial.print(", ");
  Serial.print(prozent3);
  Serial.print(", ");
  Serial.println(0);

  delay(t1);

}

tippe oder füge den Code hier ein

Better to avoid powering the relay board from the Arduino - all it should provide is the signals.

As I said I tried that too, does not make any difference for my problem. but thx. if it works, I will power the relays from the second power supply

Doesn't that defeat the isolation that the relay board is there to provide?

both circuits work on 5V The relays are just there so that the arduino does not need to power the pumps .

That is the circuit now as I have a common ground and the pover provided from the second powersuply

Hallo fabi_pr

The pumps would like to have free-wheeling diodes.

Could you explain that ? I am new to electronics. Or Could you show me in a circuit diagram what you mean, what that is ? (after a google search, I think it is to protect the pumps, but not to help with my problem ?)

For sure.

Take a view here to gain the knowledge.

It would only protect my pumps ? It wouldnt help with my problem ? if I understand correctly ??

Hi,
Can you please post some images of your project?
So we can see your component layout.

What is the distance between the sensors and the UNO?

Thanks.. Tom.. :+1: :coffee:: :australia:

Sure I can. The sensores are about half a meter away. pumps ca 1m ... But as I said, everithing workes fine, untlill I trie to switch power with the relay. if the relay is switching nothing, it workes fine​:thinking::cold_sweat:

Looks like the Arduino and the relays are being powered via the barrel jack. Thats not going to work well. Use a solid +5V power supply, on the +5V pin, to power the arduino, and separately power everything else that is +5v.
Also, if you're not using all 8 relays, use a 2 or a 4 channel one instead.

I tried that to, unfortunately I do not have a 3 relay module and as i was planning to expand this project I want it to work with this one. Could there be a problem with how I set up the relay module ? do I need to remove the jumpers If I do not use one Relay ? I start to think the Relay module might have a problem

Is there anything printed out on the serial monitor when this happens?

No nothing. As you might have seen, after every sampel it prints all values to the serial, when the problem happens it completely stops printing anything. I feel like there is a problem with my relay module. I will try it later with 3 separate relays. But I still do not understand what there could be wrong, as the only connections between the Arduino and the relay module are the 3 signal lines and the common ground. And I don't see way how anything could interfere like this over those 4 Lines. Even if the Relay would set 5v to one of the signal lines, I do not think this would be the outcome of that.

@jim-p

I have now found out, that the relay module is not the problem, and I managed to read the sensor values while the problem happened. In that moment, the Sensor values are all over the place, so powering something thru the relay changes the sensor values which could be completely isolated from the rest. Any help ore Idea what could be the problem ?(I am now using a other relay module, one with optocopler and galvanic isolation)

Hi, I am quite new to electronics and have a problem, I am trying to use a relay module to power 3 pumps , every time a corresponding sensor is under a certain value. (Sensor 1 to low --> pump 1 Powering,...) but now every time I power one pump, the Values off the sensors drop. (Sensor 2 to low --> pump 2 Powering --> Sensor 1 and 2 to low --> all pumps powering ... ) witch is a problem. Surly I have something wrong with my schematics and how I power anything. But I don't know what :smiling_face_with_tear: I could just add a long pause after Powering my pump, witch would solve the problem as the sensor values would be normal until the next time they get read. But I feel like that is not the right way to solve my problem. Surly someone knows exactly what the problem is and how to fix it.

What sensors are you using?

What are you using to power your system?

Is sounds like the supply is inadequate, so its voltage is dropping when the relays are activated.

I moved your post to a more appropriate category

1 Like