2 Channel Relay Not Working No Matter What I Do!

So here is the situation.

I want the Arduino UNO to control a LED strip that requires 12v at 600mA continuous. This is obviously too much for the Arduino so I decided to use a relay to control the lights. However, no matter which tutorial I follow, which relay issue I read, I always end up with the LED coming on and off without a relay click. I decided to try and see if I could run the relay using a separate power supply and have the Arduino just controlling the optocoupler. Still no luck. So I decided to grab another power supply and control the optocoupler circuit manually. But no matter which voltage level I had, the relay remained silent. Frustrated, I bypassed the optocoupler and attempted to power the relay without any of the fancy electronics beforehand. And it did manage to click, which shows that the relay is good. I also did a countinuity check on the optocoupler and confirmed that it was not blown. And I cannot for the life of me figure out what the hell is happening!

I'm stumped and running out of options, If someone would be so kind as to assist me with this relay project I would be eternally grateful! Thanks!

Specs:

2 Channel 5V relay - https://www.amazon.ca/Channel-Optocoupler-Trigger-Expansion-Raspberry/dp/B07L2LCWLW

(UNO supply)

5V pin connected to the Vcc pin
11 pin connected to the In1 pin and set to LOW

(Second power supply)

5V power connected to the JDVcc pin
Ground pin connected to the Gnd pin

And the jumper HAS BEEN REMOVED!

If anyone is wondering, the powerlines are connected to COM and NO.

(Image of diagram below)

The only difference is that I am using the UNO and the powerlines are not 120Vac, they are 12vdc. But as far as I know, that should not make a difference!

Show us a good schematic & image of your circuit wiring.
Posting images:
http://forum.arduino.cc/index.php?topic=519037.0

This is similar:

Like this? Just imagine it's a 2 relay board:
D0upWXs_d.jpg

Exactly like how outsider is showing, only there is 2 relays.

So can you post a good clear photograph of your wiring please.

That is the most amazingly confused description I have seen in quite a while.

It seems we have no idea whatsoever what you are doing! Perhaps you do not yourself. :roll_eyes:

You talk about a relay module (the "/ref=sr_1_4?ie=UTF8&qid=1547409948&sr=8-4&keywords=arduino+relay+2" in the link you cite is simply junk - the link is https://www.amazon.ca/Channel-Optocoupler-Trigger-Expansion-Raspberry/dp/B07L2LCWLW but that pales to insignificance beside the link to your photo :grinning: ).

This relay module must be wired as outsider cites; there is no connection between the "GND" on the module and the Arduino unless indirectly through the separately wired relay supply if this is also connected to the Arduino.

So your

BigKitty10:
(First power supply)
3.3/5V power connected to the Vcc pin
Ground pin connected to the In1 pin

makes no sense. :astonished: Why the reference to 3.3 V which clearly has nothing to do with anything here?

But then you refer to an optocoupler and give a circuit diagram of something connected to an optocoupler. What is this about?

It is indeed confusing. What are you using for power supplies? You do need a 5 V supply to power the Arduino - a common "phone charger" would suit and the same for the relay module. You can use the same supply for both if it is adequately rated but you need to run separate - paired - wiring for power and ground from power supply to relay board and power supply to Arduino and you really should have a substantial - 1 mF - capacitor across the power connections somewhere between the power supply terminals where the supplies split, and the relay board.


Yes, if you are having difficulties explaining your project, some photos taken in adequate light (that is, outside daylight unless you have a fully equipped photo studio) would be a great help. :grinning:

The relay module is https://www.amazon.ca/Channel-Optocoupler-Trigger-Expansion-Raspberry/dp/B07L2LCWLW/ref=sr_1_4
But this will damage a Raspberry Pi if you try and use it with one, so this points to the seller not having a clue about what they are selling. The page should be reported for an inaccurate description.

Therefore it is highly likely he is selling junk.

As a rule everything past the ? In a URL is a tag used to indicate what you were searching for or what intermediary passed you the link.

The OP here is not concerned as he is not using a Raspberry Pi, but why would you expect it to damage a Raspberry anyway? Given the approximately 3 V drop across indicator LED and opto-coupler, the 1k resistor limits the activation current to 2 mA of which I do believe the Pi is capable. Am I wrong?

It is completely impossible to report an eBay listing as incorrect; eBay deliberately prohibits this. Gotta get that commission!

Is Amazon different?

Grumpy_Mike:
As a rule everything past the ? In a URL is a tag used to indicate what you were searching for or what intermediary passed you the link.

The link I cited is correct. I do tell people to remove the "?" and all after for eBay URLs, but in this case, it is the "/ref=sr_1_4" which begins the referrer link and should also be discarded. :grinning:

anyway? Given the approximately 3 V drop across indicator LED and opto-coupler, the 1k resistor limits the activation current to 2 mA of which I do believe the Pi is capable.

The page says

Driver Current:15-20mA each

Which is too much current for a Pi’s GPIO pin. It might be because of indicator LED, or indeed it might be rubbish but I am only going on what they put on the page.

Also if running as a current sync, which is what the page says it can do, this puts 5V on the pin when it is off.

Grumpy_Mike:
Which is too much current for a Pi’s GPIO pin. It might be because of indicator LED, or indeed it might be rubbish but I am only going on what they put on the page.

Very unwise. This is an Amazon advert. It is indeed rubbish. :astonished:

Inspection of the images given confirms this is the circuit:

1k resistor with 2 V across it - 2 mA give or take a milliamp.

Grumpy_Mike:
Also if running as a current sync, which is what the page says it can do, this puts 5V on the pin when it is off.

No, it cannot. The combined voltage drop of LED and optocoupler LED means it could not pull up to more than 2 V if that.

It would be wise to ensure that the relay module is powered from the 5 V supply to the Raspberry so that it cannot be on when the latter is not.

Well sorry for the bad image! I was tired, frustrated, and it didn't help that my computer crashed right in the middle of creating the schematic!

Anyway, here is a premade internet photo of exactly how I wired it! Trust me when I say I wired it exactly like this!

Looks much better.

No soldering problems on the relay PCB?

What is the voltage swing at the output pin?

What is the voltage at the Arduino 5v pin?

Have you tried a different output pin?

Have you tried the 2nd relay?

Relays are 5v coil?

Not recommended that you edit your original post.

Edit:
BTW, if you have access to a camera, it helps us to see the actual circuit wiring.

You have no common ground between the battery supplying the relay module and the Arduino. No wonder it won’t work.

Grumpy_Mike:
You have no common ground between the battery supplying the relay module and the Arduino. No wonder it won’t work.

Mike, please wake up! :astonished:

The whole idea of these opto-isolated modules is that there must not be a common ground between relay module and Arduino to achieve isolation. :roll_eyes:

Hint: Common Vcc! See reply #2

Mike, please wake up!

Yes sorry, actually I am a bit ill at the moment.

Grumpy_Mike:
Yes sorry, actually I am a bit ill at the moment.

Hope it’s not brexititus.

It might actually be that, off to bed now.

larryd:
Looks much better.

No soldering problems on the relay PCB?

What is the voltage swing at the output pin?

What is the voltage at the Arduino 5v pin?

Have you tried a different output pin?

Have you tried the 2nd relay?

Relays are 5v coil?

Not recommended that you edit your original post.

Edit:
BTW, if you have access to a camera, it helps us to see the actual circuit wiring.

Well, I will try to answer these to the best of my abilities.

No there are no problems with the soldering. I even try to use the other relays and they did not work.

I have verified that there is a clean 5v running through the Arduino's 5v pin.

Yes I have tried using different output pins with no luck.

Yes I have tried using not only both relays but the other relays that I bought.

Yes the relays are 5v relays. I have connected 5v directly to the relays and they do activate.

Here is a image of my setup

(If you need help knowing where certain wires are going, please ask)!

From what we can see, the wires are just plugged into the Arduino headers.
This might be okay for Dupont ends but iffy for plain stripped wires.

Can you focus in on your Arduino to module wiring.

Let’s see your sketch.
Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags.
Use the </> icon in the posting menu:
[code]Paste your sketch here[/code]

From what we can see, the wires are just plugged into the Arduino headers.
This might be okay for Dupont ends but iffy for plain stripped wires.

Can you focus in on your Arduino to module wiring.

Let's see your sketch.
Use CTRL T to format your code.
Attach your 'complete' sketch between code tags.
Use the </> icon in the posting menu:
Paste your sketch here

Here

Note: The other wires that do not have the Dupont ends should not effect the relay as far as I'm concerned. They are for other LED's.)

And here is the code. Pins 11 and 12 are for the relays, but for now I'm focusing on 11.

unsigned long TargetFloor;
unsigned long CurrentFloor;
unsigned long LastCurrentFloor;
unsigned long Direction;
unsigned long Arrow;
int a = 1;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  randomSeed(analogRead(0));
  pinMode(10, OUTPUT); //UP ARROW
  pinMode(2, OUTPUT); //DOWN ARROW
  pinMode(3, OUTPUT); //BASEMENT
  pinMode(4, OUTPUT); //1
  pinMode(5, OUTPUT); //2
  pinMode(6, OUTPUT); //3
  pinMode(7, OUTPUT); //4
  pinMode(8, OUTPUT); //5
  pinMode(9, OUTPUT); //6
  pinMode(11, OUTPUT); //UP INDICATOR
  pinMode(12, OUTPUT); //DOWN INDICATOR
  TargetFloor = random(2, 8);
  Serial.println(TargetFloor);
  CurrentFloor = 2;
  TargetFloor = random(1, 8);
  Serial.println(TargetFloor);
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);
  if (CurrentFloor == 1) {
    digitalWrite (3, HIGH);
  }
  else {}
  if (CurrentFloor == 2) {
    digitalWrite (4, HIGH);
  }
  else {}
  if (CurrentFloor == 3) {
    digitalWrite (5, HIGH);
  }
  else {}
  if (CurrentFloor == 4) {
    digitalWrite (6, HIGH);
  }
  else {}
  if (CurrentFloor == 5) {
    digitalWrite (7, HIGH);
  }
  else {}
  if (CurrentFloor == 6) {
    digitalWrite (8, HIGH);
  }
  else {}
  if (CurrentFloor == 7) {
    digitalWrite (9, HIGH);
  }
  else {}
  digitalWrite (10, LOW);
  digitalWrite (2, LOW);
}
void loop() {
  // put your main code here, to run repeatedly:
  if (TargetFloor == CurrentFloor) {
  do
  {
    digitalWrite(10, LOW);
    digitalWrite(2, LOW);
    delay(10000);
    TargetFloor = random(1, 8);
    Serial.println(TargetFloor);
  } while (TargetFloor == CurrentFloor);
  }
  else {}

    if (TargetFloor >  CurrentFloor) {
      Direction = (2);
      if (CurrentFloor == 2) {
        digitalWrite(11, LOW);
      }
      else {}
      Arrow = random(1, 3);
    if (Arrow == 1) {
      digitalWrite(10, LOW);
      digitalWrite(2, LOW);
    } else {
      digitalWrite(10, HIGH);
      digitalWrite(2, LOW);
      }
    }
    else {
           Direction = (1);
           if (CurrentFloor == 2) {
        digitalWrite(12, LOW);
        delay(1000);
        digitalWrite(12, HIGH);
        delay(500);
        digitalWrite(12, LOW);
      }
      else {}
           Arrow = random(1, 3);
    if (Arrow == 1) {
      digitalWrite(2, LOW);
      digitalWrite(10, LOW);
    } else {digitalWrite(2, HIGH);
           digitalWrite(10, LOW);}
           }
    delay(10000);
    if (Direction == 2) {
    do { digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
      digitalWrite(10, HIGH);
      delay(1500);
       if (CurrentFloor == 1) {
    digitalWrite (3, LOW);
  }
  else {}
  if (CurrentFloor == 2) {
    digitalWrite (4, LOW);
  }
  else {}
  if (CurrentFloor == 3) {
    digitalWrite (5, LOW);
  }
  else {}
  if (CurrentFloor == 4) {
    digitalWrite (6, LOW);
  }
  else {}
  if (CurrentFloor == 5) {
    digitalWrite (7, LOW);
  }
  else {}
  if (CurrentFloor == 6) {
    digitalWrite (8, LOW);
  }
  else {}
  if (CurrentFloor == 7) {
    digitalWrite (9, LOW);
  }
  else {}
    delay(1000);
    LastCurrentFloor = CurrentFloor;
    CurrentFloor = LastCurrentFloor + a;
    Arrow = random(1, 3);
    if (CurrentFloor == TargetFloor) {
    if (Arrow == 1) {
      digitalWrite(10, LOW);
    } else {}
    }
    else {}
    delay(500);
  if (CurrentFloor == 1) {
    digitalWrite (3, HIGH);
  }
  else {}
  if (CurrentFloor == 2) {
    digitalWrite (4, HIGH);
  }
  else {}
  if (CurrentFloor == 3) {
    digitalWrite (5, HIGH);
  }
  else {}
  if (CurrentFloor == 4) {
    digitalWrite (6, HIGH);
  }
  else {}
  if (CurrentFloor == 5) {
    digitalWrite (7, HIGH);
  }
  else {}
  if (CurrentFloor == 6) {
    digitalWrite (8, HIGH);
  }
  else {}
  if (CurrentFloor == 7) {
    digitalWrite (9, HIGH);
  }
  else {}
    }
    while (CurrentFloor != TargetFloor);
    Direction = 0;
    }
  else {}
      if (Direction == 1) {
    do { digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
      digitalWrite(2, HIGH);
      delay(1500);
       if (CurrentFloor == 1) {
    digitalWrite (3, LOW);
  }
  else {}
  if (CurrentFloor == 2) {
    digitalWrite (4, LOW);
  }
  else {}
  if (CurrentFloor == 3) {
    digitalWrite (5, LOW);
  }
  else {}
  if (CurrentFloor == 4) {
    digitalWrite (6, LOW);
  }
  else {}
  if (CurrentFloor == 5) {
    digitalWrite (7, LOW);
  }
  else {}
  if (CurrentFloor == 6) {
    digitalWrite (8, LOW);
  }
  else {}
  if (CurrentFloor == 7) {
    digitalWrite (9, LOW);
  }
  else {}
    delay(1000);
    LastCurrentFloor = CurrentFloor;
    CurrentFloor = LastCurrentFloor - a;
    Arrow = random(1, 3);
    if (CurrentFloor == TargetFloor) {
    if (Arrow == 1) {
      digitalWrite(2, LOW);
    } else {}
    }
    else {}
    delay(500);
  if (CurrentFloor == 1) {
    digitalWrite (3, HIGH);
  }
  else {}
  if (CurrentFloor == 2) {
    digitalWrite (4, HIGH);
  }
  else {}
  if (CurrentFloor == 3) {
    digitalWrite (5, HIGH);
  }
  else {}
  if (CurrentFloor == 4) {
    digitalWrite (6, HIGH);
  }
  else {}
  if (CurrentFloor == 5) {
    digitalWrite (7, HIGH);
  }
  else {}
  if (CurrentFloor == 6) {
    digitalWrite (8, HIGH);
  }
  else {}
  if (CurrentFloor == 7) {
    digitalWrite (9, HIGH);
  }
  else {}
    }
    while (CurrentFloor != TargetFloor);
    Direction = 0;
    }
  else {}

delay(4000);
TargetFloor = random(1, 8);
Serial.println(TargetFloor);
}