# Trouble with 12V Relay attached to Pump - Arduino MEGA2560

**URL:** <https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675>\
**Category:** General Guidance\
**Created:** [August 14, 2021, 9:06pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675 "2021-08-14T21:06:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 14, 2021, 9:06pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/1 "2021-08-14T21:06:33Z")

</div>

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:

```cpp
// 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](https://arduinogetstarted.com/tutorials/arduino-controls-pump)

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

 ![image1](https://europe1.discourse-cdn.com/arduino/original/4X/c/c/0/cc013fffdd4d3e9f5644870a5848b786f19dc2bd.jpeg)

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 14, 2021, 9:07pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/2 "2021-08-14T21:07:37Z")

</div>

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](https://forum.arduino.cc/index.php?topic=710766.0).

Other general [help and troubleshooting advice can be found here.](https://support.arduino.cc/hc/en-us)  
It will help you get the best out of the forum in the future.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [August 14, 2021, 9:29pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/3 "2021-08-14T21:29:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![espillier](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@espillier](https://forum.arduino.cc/u/espillier)\
**Post date:** [August 14, 2021, 9:40pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/4 "2021-08-14T21:40:28Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [August 14, 2021, 10:21pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/5 "2021-08-14T22:21:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 12:52am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/6 "2021-08-15T00:52:35Z")

</div>

@anon57585045 @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](https://arduinogetstarted.com/images/tutorial/arduino-pump-wiring-diagram.jpg)

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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 12:53am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/7 "2021-08-15T00:53:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 12:56am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/8 "2021-08-15T00:56:55Z")

</div>

Here is the code I am using, see this link about halfway down the page: [https://arduinogetstarted.com/tutorials/arduino-controls-pump](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

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [August 15, 2021, 1:05am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/9 "2021-08-15T01:05:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [August 15, 2021, 2:47am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/10 "2021-08-15T02:47:02Z")

</div>

> [@blakecodez](#):
>
> 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.

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

> [@espillier](#):
>
> 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.

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!

 ![](https://europe1.discourse-cdn.com/arduino/original/4X/c/b/b/cbbb9dcccd783fb74641662a3bee494188d546ee.png)

> [@bluejets](#):
>
> Powering the module from the Arduino regulator is not a good idea as well.

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. 🙄

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".

---

<div class="post-metadata">

**Author:** ![dave-in-nj](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dave-in-nj](https://forum.arduino.cc/u/dave-in-nj)\
**Post date:** [August 15, 2021, 3:19am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/11 "2021-08-15T03:19:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 4:16am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/12 "2021-08-15T04:16:38Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 4:25am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/13 "2021-08-15T04:25:54Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![lastchancename](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/lastchancename/32/215426_2.png) [@lastchancename](https://forum.arduino.cc/u/lastchancename)\
**Post date:** [August 15, 2021, 4:49am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/14 "2021-08-15T04:49:00Z")

</div>

Here is OPS image…

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/8/a/c/8ac1820794dd086d407297cfbd8c67b03fa6f687.jpeg)

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [August 15, 2021, 8:02am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/15 "2021-08-15T08:02:33Z")

</div>

> [@blakecodez](#):
>
> So is the diagram I am using totally wrong for this setup?

It certainly is!

> [@blakecodez](#):
>
> Did you see the link I had posted?

I certainly did. 😁 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.

---

<div class="post-metadata">

**Author:** ![espillier](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@espillier](https://forum.arduino.cc/u/espillier)\
**Post date:** [August 15, 2021, 8:55am UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/16 "2021-08-15T08:55:48Z")

</div>

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

 ![IMG_2032](https://europe1.discourse-cdn.com/arduino/original/4X/a/5/6/a56245a23c9cd1dd2b2538c91354bd5e3fe22616.jpeg)

---

<div class="post-metadata">

**Author:** ![dave-in-nj](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dave-in-nj](https://forum.arduino.cc/u/dave-in-nj)\
**Post date:** [August 15, 2021, 12:14pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/17 "2021-08-15T12:14:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 3:50pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/18 "2021-08-15T15:50:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 3:51pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/19 "2021-08-15T15:51:28Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![blakecodez](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@blakecodez](https://forum.arduino.cc/u/blakecodez)\
**Post date:** [August 15, 2021, 3:53pm UTC](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675/20 "2021-08-15T15:53:37Z")

</div>

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

[Next page](https://forum.arduino.cc/t/trouble-with-12v-relay-attached-to-pump-arduino-mega2560/895675.md?page=2)
