I am having trouble with controlling a water pump using an Arduino.
All I have in my circuit is the Arduino, a relay, a 12V battery pack, and my 12V water pump.
The water pump doesn't turn on when connected to the Arduino but does turn on when connect it directly to the 12V battery pack I have.
Here is my code:
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT); // Set pin 7 to output
}
void loop() {
digitalWrite(7, HIGH); // Set pin 7 as "high" or turn it on
Serial.println("Should be on"); // prints that the pump should be on
delay(10000); // 10 second delay
digitalWrite(7, LOW); // Set pin 7 as "low" or turn it off
Serial.println("Should be off"); // prints that the pump should be off
delay(10000); // another 10 second delay
}
My wiring:
5V pin on Arduino is connected to DC+ (VCC) pin on relay
GND pin on Arduino is connected to DC- (GND) pin on relay
Pin 7 on Arduino is connected to IN1 pin on relay
COM pin on relay is connected to positive/red wire of battery pack
NO pin on relay is connected to positive/red wire of water pump
Black/negative wire of battery pack is connected to black/negative wire of water pump
Any help would be greatly appreciated! Thanks in advance!
larryd:
Take good pictures of the wiring and show them to us.
Does the relay board LED operate when being controlled from the Arduino ?
Does the relay click when operating from the Arduino ?
Edit:
That relay might take ~190mA for the coil which might be loading the Arduino.
Try a different i/o pin.
Yes, the red LED labeled "PWR" or "Power" lights up when the circuit is powered up.
There is also a green LED that turns on and off.
No, the relay doesn't make a clicking sound when connected to the Arduino.
Using a different i/o pin doesn't work.
Also, I did some research on relays and apparently if they don't click then the wiring or the relay isn't working. But I double checked my wiring and it should be working so I'm not sure. The relay package I bought had multiple relays so I switched relays and the circuit still didn't work.
The top of the relay has some logos. The main logo says "SONGLE" with a picture of Then there is some lettering that says, "10A 250VAC 10A 125VAC", "10A 30VDC 10A 28VDC", and on the last line in slightly bigger lettering, "SRD-12VDC-SL-C".
Changing the time to 1 second on/off still makes it so that I can't hear any clicking noise from the relay.
When your pump is ON, the motor generates a huge amount of electrical noise that can cause interference in the Arduino.
A diode is placed across these coils to stop this electrical noise.
These diodes are placed across ‘non-reversing DC inductive loads’ like your motor.
The diode lead that has a painted band (cathode) is connected to the positive motor wire, the other lead is connected to the negative motor wire. This is the reverse biased connection mentioned.
You can also add a .1uF ceramic capacitor in parallel with this diode to also help reduce noise interference.
The tutorial you site should have had these added in their circuitry.
If you ‘don’t add these components’ your Arduino can and probably will experience problems.
With a 12V relay module, you have to connect 12+ (red wire) to the relay module DC+ pin, 12- (black wire) to to DC-, Arduino GND to DC- (along with the 12V- wire), Arduino output pin to relay module IN pin. 12V+ (red wire) to relay NO terminal, pump+ wire to relay COM, AND diode cathode (end with band), pump- AND diode anode to 12V-.
larryd:
Your pump motor is made up from coils of wire.
When your pump is ON, the motor generates a huge amount of electrical noise that can cause interference in the Arduino.
A diode is placed across these coils to stop this electrical noise.
These diodes are placed across ‘non-reversing DC inductive loads’ like your motor.
The diode lead that has a painted band (cathode) is connected to the positive motor wire, the other lead is connected to the negative motor wire. This is the reverse biased connection mentioned.
You can also add a .1 ceramic capacitor in parallel with this diode to also help reduce noise interference.
The tutorial you site should have had these added in their circuitry.
If you ‘don’t add these components’ your Arduino can and probably will experience problems.
Ok then, I will get a 5V relay and a diode. Thanks for your help!
That type of relay module should be taken off the market, too easy for noobs to blow it up along with their Arduino.
Opto isolated relays should have SEPARATE terminals for coil power and logic, 2 terminals for coil + and -, 2 for signal common and input. And why bother making them active LOW when every noob in the universe expects HIGH to be ON?
JCA34F:
With a 12V relay module, you have to connect 12+ (red wire) to the relay module DC+ pin, 12- (black wire) to to DC-, Arduino GND to DC- (along with the 12V- wire), Arduino output pin to relay module IN pin. 12V+ (red wire) to relay NO terminal, pump+ wire to relay COM, AND diode cathode (end with band), pump- AND diode anode to 12V-.
Doing this can cause problems.
There will be ‘no physical isolation’ between the motor and Arduino.
Also, you ‘must connect’ the relay PCB jumper to the ‘high trigger’ setting.
If left at the LOW setting, the Arduino output pin can be damaged.