Trouble with 12V Relay attached to Pump - Arduino MEGA2560

I have attached to my Arduino a 2 Channel 12V Relay. Currently the red light on the Relay is working as my program switches LOW and HIGH every 5 seconds, so I know it's communicating.

My 12VDC/AC power supply is plugged in the + is spliced in through the orange wire connected to the COM2. On the NO2 I have the +(pos) going to the pump. The -(neg) of the pump is connected to the power supplies -(neg).

For some reason I get no response from the NO2 switching on or off. When the red light on the relay is on (I'm assuming it's in HIGH mode which means) and when it's off it's on LOW mode.

The pump is not working, however if I attached the +(pos) from the pump into the IN2 it turns on....

Could this possibly something wrong with my Relay?

My Code:

// constants won't change
const int RELAY_PIN = A5;  // the Arduino pin, which connects to the IN pin of relay

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin A5 as an output.
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(RELAY_PIN, HIGH);
  delay(5000);
  digitalWrite(RELAY_PIN, LOW);  // turn off pump 5 seconds
  delay(5000);
}

Here is the link of the tutorial I am following: https://arduinogetstarted.com/tutorials/arduino-controls-pump

Any help would be greatly appreciated! Thank you so much.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

What is really painful is the lack of a wiring diagram...

I have also been playing with those relays, and you have to take into account that they are OFF when they receive a HIGH on the relay pin, and ON when they receive a LOW.

Did you match the value sent to the relay pin (e.g. through the serial monitor) with the status of your led ?

(yes, a wiring diagram would be useful)

Powering the module from the Arduino regulator is not a good idea as well.
Power positive and negative, no....signal and ground ok.
If you are using a 5v module you could power it through a converter from your 12v unit or simply get a 12v module.

@aarg @espillier here is the diagram for what my setup is following.

I can't seem to post more than 1 picture so here is the link: Pump Diagram

The only difference is I am using a 2 Channel 12V relay

I am powering the pump from the DC / AC power adapter. The Arduino is only sending a signal to the 2 Channel Relay of HIGH and LOW every 5 seconds on the A5 pin

Here is the code I am using, see this link about halfway down the page: https://arduinogetstarted.com/tutorials/arduino-controls-pump

Either way I have ran HIGH without a loop, just running HIGH and no response, tried LOW without a delay or loop, nothing happened.

What do you mean. by match the value sent to the relay pin? My relay pin is A5, the value I'm sending is this: pinMode(RELAY_PIN, OUTPUT);

And not to sure what you mean by through the serial monitor, how do I retrieve the status? Please see the wire Diagram link I just posted

You can't power a 12V relay on 5V. That's what the diagram shows. The "12V' refers to the relay coil voltage.

You can purchase 5V relay modules from the same suppliers, they would work with your diagram. But it's preferable to run the relay power from a different source than the Arduino +5V.

Communicating yes, but while the LED may glow, you can't operate 12 V relays - as they clearly are - on 5 V.

Well, you clearly do not understand them, because they can be selected to operate either active HIGH or active LOW- that is why it is written on the module!

It certainly is not, but blessedly, he was not attempting to do so. Using "Vin" or the "barrel jack" is always a bad idea for a serious project. :roll_eyes:

You can use this relay module. The proper way to do it is to connect "DC +" and "DC -" to your respective 12 V supply terminals by a twin cable. Then remove the two jumpers and connect one or both "com" pins - depending on whether you want to use both relays - to either your Arduino ground if you wish to have the relay(s) active on HIGH, or to "5V" if you want them active on LOW.

Connect the respective "IN" terminal to your Arduino, keeping this wire together with the one connecting the "com" pin to the Arduino ground or "5V".

Are you asking why your 12 volt relay will not work when you connect it to the 5 volt power supply ?

or, are you asking why your Mega did not burn up from the abuse of connecting a heavy load to the 5 volt line ?

use the 12v power supply to supply 12volts to the 12 volt relay.
all you need from the MEGA is a signal out and connect grounds.

@dave-in-nj don't be ridiculous, the power supply I'm using is a 12V DC/AC plugin. So yes that 12V power supply is going into my 12 Volt relay. I have my Mega using the A5 pin to signal out

@Paul_B thank you for your response! So is the diagram I am using totally wrong for this setup? Did you see the link I had posted? Sorry I am trying to follow along, so I guess I currently have it backwards? I had my Arduino connected to the Relay's DC- going to the GRND on the Arduino, and the Relay's DC+ was connected to the 5V power of the Arduino just like the diagram shows. the A5 Pin switch from the Arduino is connected to the IN2 of the Relay. The Relay's COM2 is connected to the 12V Power supplies + and the Relay's NO2 is connected to the Pump's + wire. The Pump's - Wire is connected to the - of the Power Supply.

Could you help me from here as to which is wrong our what to change? Trying to follow along with what you wrong but a little confused still.

The link to the Tutorial I am following is located now at the bottom of my original post above the picture if you could take a look

Here is OPS image…

1 Like

It certainly is!

I certainly did. :grin: That link is for a five volt relay module. And even then it is somewhat suspect and likely to malfunction particularly if you connect 12 V to "Vin" or the "barrel jack".

According to your photo, you do not have a five volt relay module, you have a twelve volt relay module which requires 12 V on "DC +" and "DC -" to function.

You can connect it to the Arduino with a common ground (goes to "DC -") connection as dave-in-nj suggests with the jumpers set to "High" but I have tried to explain in detail the proper way to make use of its opto-isolation for greater reliability.


I think the Mega 2560 is inappropriate ("overkill" and absurdly expensive) for the vast majority of projects except where you are using a graphics display "shield". The Nano is more practical in most cases.

Just to reinforce Paul's message: here's a pic of a 5V relay module (SRD-05VDC-SL-C)

1 Like

Take a few minutes to learn how to use a relay.

Step #1 NEVER use the power fron the Arduino. Rather ALWAYS use a seperate power supply.

Step#2 Read the instructions on relays watch a few videos.

A relay has 3 seperate and totally different connections #1is POWER look at the part number of the blue relay. That lists the voltage for the COIL the COIL voltage needs at keast 100mA power per relay.
When a relay fires it can cause issues on the power line and if mistakenly connected to ahe arduino power it can casue signal issues and mess with sensor readings.

SIGNAL: the arduino will either bring the pun HIGH to switch or LOW usually this is in how the relay module is made and not user choice.
A ground to the logic connection of the relays needs to be made.

The THIRD part of the relay is the contacts. These are completely isolated and can take 230AC voltage.

To review.
Contacts-isolated
Signal = Logic level power
COIL Power = SEPERATE and match to coil requirements

Thank you! They only let new users post 1 image and 1 link for some reason

@Paul_B Thank you for the help! I'll go get a 5v Relay, not sure why I thought 12V relay, maybe because of the power supply.... Still very new at this.

@dave-in-nj Thank you I'll purchase something separate to power the relay instead of the Arduino

What sucks is that tutorial didn't specify the Voltage on the relay. Also the link to purchase didn't work! :laughing: