Trying to connect 12V DC irrigation pump using Relay and power supply

Now, first of all let me tell you that I’m new at using relays and a newbie at Arduino so forgive me if what I’m doing is totally wrong.

What I was trying to do was connecting a 12V DC irrigation pump to an Arduino Uno through a 2 Relay Module, using a direct power supply (yes, no battery,)

It ended up pretty bad and I’m trying to figure it out if the reason is the power supply or the Arduino PIN.

I used the PIN 8 and for some weird reason, it was the only PIN that would turn on the red led on the Relay ( I guess that led means Undervoltage !?)

I’m sending you guys some pics also.
I’ve used this schematic for it


Note that instead of a battery I used a power supply…
Let me know what I messed up!!!

Thank you!

Maybe you set pin 8 as an output with pinMode, but not pin 10?

Difficult to say though; you should post your code.

gwareloth:
Maybe you set pin 8 as an output with pinMode, but not pin 10?

Difficult to say though; you should post your code.

I think the problem is using the home power supply but anyway,
Here is my code and thanks:

int sensor_pin = A0 ;

int output_value ;

int valve_pin = 8 ;

void setup ( ) {
Serial.begin(9600);
   Serial.println("Reading From the Sensor ... " );;
   delay (2000);
 } 

void loop ( ) {
  output_value = analogRead (sensor_pin);
  output_value = map (output_value , 1023 , 0 , 0 , 100);
  Serial.println (" Moisture = ");
  Serial.println (output_value);

  if (output_value < 40)
  {
  Serial.println (" Valve: ON ");
  digitalWrite (valve_pin , LOW);    //Relay operates on opposite signal
  delay (1000); 
   }  

  else
   { 
    Serial.println (" Valve: OFF ");
  digitalWrite (valve_pin , HIGH);    //Relay operates on opposite signal
  delay (1000); 
   } 
  delay(1000);
  }

lolcol11:
I think the problem is using the home power supply but anyway,

But that's the 12V side isn't, and the relay coil is powered by the Arduino 5V, triggered by the digital signal.

What happens if you disconnect everything except the relay module, and use a simple code like blink to simply toggle the relay in loop()?

And you should also show a proper circuit diagram, even a quick scribble in biro and a pic with your phone.

gwareloth:
But that's the 12V side isn't, and the relay coil is powered by the Arduino 5V, triggered by the digital signal.

What happens if you disconnect everything except the relay module, and use a simple code like blink to simply toggle the relay in loop()?

And you should also show a proper circuit diagram, even a quick scribble in biro and a pic with your phone.

Actually, I think it's connected to an electric socket through a cable, so...220v I guess?

lolcol11:
Actually, I think it's connected to an electric socket through a cable, so...220v I guess?

Guessing about voltage is dangerous: post a proper circuit diagram, then there'll be no guessing.

And did you do what I suggested, and test the relay on any pins you care to name with a blink type sketch?

gwareloth:
Guessing about voltage is dangerous: post a proper circuit diagram, then there’ll be no guessing.

And did you do what I suggested, and test the relay on any pins you care to name with a blink type sketch?

The sketch is the same as the following one:

But, instead of the 12v battery, there’s a cable connected directly to the electric socket

Look at the attachments, thank you!

Are you actually trying to run a 12V DC motor, direct off the 220V AC mains? Or am I missing something?

gwareloth:
Are you actually trying to run a 12V DC motor, direct off the 220V AC mains? Or am I missing something?

That's what I was trying to say. Looks like in this country (I'm not at home) the sockets do offer only 220-230v (we do have 12v sockets also).
I made a HUGE mistake, right?

Connect the blue wire from the power supply directly to a motor terminal, connect the brown wire to the NO relay terminal, connect a wire from the COM relay terminal to the other motor terminal, if the motor runs backward, reverse the wires on it's terminals. There should not be a wire on the relay NC terminal.
EDIT: If you put 230VAC on the pump, never mind.
Post a link or picture of that power supply!

lolcol11:
I made a HUGE mistake, right?

Yeah

But that doesn't really relate to your problem of only pin 8 activating the relay and not eg pin 10. so to solve that problem, disconnect the motor side of the relay* and your sensor from the arduino, and just see if the relay activates by itself running blink, but on various pins.

  • I'm kinda hoping you did that already before you fry yourself....