[SOLVED] 5v 8 channel relay board - external power source problem.

Hi friends.

Shortly: I can’t run my relay board with a wall type adapter.

Details: I have a wall type adapter for my relay board (Songle 5v 8 channel) and it gives 5.9v with 600ma.

Relay board is working without any problem with Arduino Mega’s 5v and GND pins but not with the adapter.

I am feeding the Arduino with another 9v wall type adapter which is 500ma.

What could be the problem?

(Sorry for the low res. pictures)

Thanks in advance.

Relay page: http://www.sainsmart.com/8-channel-dc-5v-relay-module-for-arduino-pic-arm-dsp-avr-msp430-ttl-logic.html

Draw us a schematic how you wired it using the adapter.

I am not so good at Fritzing :slight_smile: and i don’t have relay board part inside of it.

My adapter has 2 holes inside of its jack and i also tried with that kind of breadboard part http://www.aliexpress.com/item/5pcs-lot-MB102-Breadboard-Power-Supply-Module-3-3V-5V-For-Arduino-Board-Free-Shipping-Dropshipping/1134862681.html

When i change the wires to the Arduino, it is working!

If you removed both the 5v and Gnd pins you may no longer have a common Gnd btween relay board and the Arduino.

Thank you friends, you ended up the pain :slight_smile:

As a note to others: 5v 8 channel relay boards have 2 GND pins and one of them should be connected to the Arduino while other is connected to the external source. I think the current which comes from Arduino’s digital pin should be come back with its GND pin.

[Solved] But 5v 1000ma wall type adapter which is brand new couldn’t run the relay. I couldn’t understand the problem.
Answer: The problem was the polarity of the adapter jack.

Sample Relay code:

/* Used Arduino Mega pins and Relay ones
- D46 > In1, D47 > In2, D48 > In3, D49 > In4, D50 > In5, D51 > In6, D52 > In7, D53 > In8
- VCC > 5V
- I GND on Relay board > Arduino's GND
- II GND on Relay board > External Power source's GND (If you use external power source) */

void setup(){
  for(int i=46; i<=53; i++){
   pinMode(i, OUTPUT);
  }
}

void loop(){
  for(int i=46; i<=53; i++){
    int z = i-45;
    digitalWrite(i, LOW);
    delay(z*20);
    digitalWrite(i, HIGH);
    delay(z*20);
  }
}

I have the same problem. Please check the adaptor. You must use the right polaritation. Pull out jumper at JD VCC then connect the positif to JD VCC and the other to ground. Be sure to measure the voltage. If there is minus sign, change the polarisation then it become positif. I solve the problem by changing the adaptor because when I measure the voltage, the result are - 5V and + 2,5V. Relay need +5V to make it work.

Connections for complete opto-isolation:

Test Code:

/* 8 Relay Module configured for Opto-isolation
   Arduino UNO pins 3 to 10 connected to IN1 to IN8
   Connections: http://i.imgur.com/MDNQGeC.png */

void setup() {
  for (int i = 3; i <= 10; i++) {
    pinMode(i, INPUT_PULLUP);
    pinMode(i, OUTPUT); // defaults HIGH (relays off)
  }
}

void loop() {
  for (int i = 3; i <= 10; i++) {
    digitalWrite(i, LOW); // energize relays until all on
    delay(1000);
  }
  for (int i = 3; i <= 10; i++) {
    digitalWrite(i, HIGH); // de-energize relays until all off
    delay(1000);
  }
}

Really, that works without the left hand ground being connected to the Arduino Gnd?

Arduino +5 ------- Anodes on LEDs ------- IN1(1-8) -------- Arduino output pin ------- Arduino GND

.

Yes, if the GND is connected, isolation is lost.

The circuit is equivalent to having a LED + resistor in series, where the LED’s anode is connected to 5V. The LED (IRLED) is illuminated when the controlled end of the resistor (IN1-IN8) goes LOW. The Arduino outputs (when LOW) provide a path to Arduino’s GND.

LarryD … you’re quick! (really though, I’m a bit sluggish).

Had to think about it too.

2016-03-07_11-25-12.png
.

I see didn't the arduino was just sinking current from +5 thru the Opto LED and the indicator LED.

dlloyd:
Connections for complete opto-isolation:

Test Code:

/* 8 Relay Module configured for Opto-isolation

Arduino UNO pins 3 to 10 connected to IN1 to IN8
  Connections: http://i.imgur.com/MDNQGeC.png */

void setup() {
  for (int i = 3; i <= 10; i++) {
    pinMode(i, INPUT_PULLUP);
    pinMode(i, OUTPUT); // defaults HIGH (relays off)
  }
}

void loop() {
  for (int i = 3; i <= 10; i++) {
    digitalWrite(i, LOW); // energize relays until all on
    delay(1000);
  }
  for (int i = 3; i <= 10; i++) {
    digitalWrite(i, HIGH); // de-energize relays until all off
    delay(1000);
  }
}

Sorry for digging up an out dated topic, but this thread was the reason I was able to identify that I had initially connected my 8 channel relay module incorrectly and have since updated my circuits. My question now is in the above example sketch, “i” is first assigned to be an INPUT_PULLUP() in pinMode, than switched to be an OUTPUT(). Can you explain how INPUT_PULLUP() is being used in this application? I understand that the +5V is sourcing current to the LED circuit on the relay board, and when the OUTPUT is sent LOW, the voltage finds its ground and flows through the LED and opto, thus telling the relay to latch and the VAC~ flows. However, I am not able to grasp how INPUT_PULLUP() is being used, and most/all other threads/tutorials only show this being used to monitor a switches position. Any insight?

myggle: My question now is in the above example sketch, "i" is first assigned to be an INPUT_PULLUP() in pinMode, than switched to be an OUTPUT(). Can you explain how INPUT_PULLUP() is being used in this application?

This "trick" of making the pin HIGH first (enabling the internal pull up resistors), before anything else, stops the relays from "chattering" during bootup of the Arduino. digitalWrite(pin, HIGH); pinMode(pin, OUTPUT); does the same thing. Leo..

Thanks for the reply Wawa! Would this also apply during future pin state changes? Like if LOW is on and HIGH is off, would the pin revert back to the input pullup when off?

Regarding pinMode, they show 3 possible ways the pin can behave, but actually there are 4.

When using pinMode(OUTPUT); the output will default LOW. As you can see, there are 2 possible ways to make the output default HIGH, but both ways do the same thing - they enable the pullup resistor before the pin is changed to OUTPUT mode.

Perhaps a future version of of the IDE would make all possible modes available like this:

INPUT, INPUT_PULLUP, OUTPUT, OUTPUT_HIGH

or…

INPUT, INPUT_PULLUP, OUTPUT_LOW, OUTPUT_HIGH

ok, that makes perfect sense to me now. Thank you for the info dlloyd and Wawa!

Not sure, but I think the pull up resistor is disabled once the pin has changed to an output.

Doesn't matter anyway if a ~20k resistor stays between pin and VCC. It's a fraction more current that the pin has to sink compared to the ~2mA the opto requires. Leo..