Advice on using a relay board with arduino needed

I have relay board attached to my arduino.

Now I have this type:

And I assume the idea of the optical coupler IC things is to isolate the Arduino from the inductive kick back from the relay coils.

However the relay board I am actually using at present is one that has inidcator LEDs for each station but there are no optical coupler ICs:

I have put this in my setup() code:

void setup() 
{  
  // Open serial communications and wait for port to open:
  Serial.begin(115200);

  // Wait for serial port to connect - needed for native USB port only
  delay(10);

  if (initSD())
  {
    debug.init();

    //serialHC05.begin(38400);
    serialHC05.begin(9600);

    if (WifiServer.begin() && program.read())
      program.begin();
    else
      debug.logRuntimeError(F("IrrigationController.cpp"), __LINE__);

    WifiServer.synchClock();
    rtc.readClock();
    timeLastAlarms.set(rtc.getHours(), rtc.getMinutes(), rtc.getSeconds());
    debug.log(F("Setup() complete..."));
  }
  else
    debug.logRuntimeError(F("IrrigationController.cpp"), __LINE__);
  digitalWrite(24, HIGH);
}

The digitalWrite(...) at the bottom was to check that the relays were being successfully triggered with the Arduino USB cable connected and without it connected.

I am noticing that the sketch runs fine on the Arduino if the relay board is not connected.

But as soon as I attach my relay board and stand alone power supply I have made, that digitalWrite(...) at the bottom causes my Arduino to reset itself infinitely.

If I remove the connection between the relay board / stand alone power supply and run the sketch then it runs just fine.

Is it likely that inductive kickback is running through the arduino and mucking the electronics up thus causing this unpredictable sketch behavior? It must be - the relay board does not appear to have sort protection on it.

I will swap the relay board out for one with the opitcal couplers and see if the same thing happens.

Hi,
More likely that your power supply cannot provide the current.
The relay board has back EMF protection fitted.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Including you power supply.
Have you tried with USB and relay board only?
Where do you get the 5V for the relay PCB from?

Thanks Tom... :slight_smile:

That 8-channel relay board needs a separate 5volt/1Amp supply (e.g. a tablet charger).
If you connect it the right way, you will have opto isolation.

Remove JD-VCC jumper, and connect the relay supply to JD-VCC and relay ground.
Connect Arduino 5volt to relay VCC (next to pin8).
Connect Arduino outputs to relay inputs.
DO NOT connect Arduino ground to relay ground.
It has no function, and if you do, you loose opto isolation.

Write a HIGH to the pins in void setup() before you make the pins an output with pinMode.
That stops relay chattering during bootup.
Reverse logic, so a LOW on the Arduino pin activates the relay.

That 4-relay board uses 4 * ~75mA from the Arduino 5volt pin.
That could be a problem for some Arduinos on some supplies.
Leo..

Wawa:
That 8-channel relay board needs a separate 5volt/1Amp supply (e.g. a tablet charger).
If you connect it the right way, you will have opto isolation.

Remove JD-VCC jumper, and connect the relay supply to JD-VCC and relay ground.
Connect Arduino 5volt to relay VCC (next to pin8).
Connect Arduino outputs to relay inputs.
DO NOT connect Arduino ground to relay ground.
It has no function, and if you do, you loose opto isolation.

Write a HIGH to the pins in void setup() before you make the pins an output with pinMode.
That stops relay chattering during bootup.
Reverse logic, so a LOW on the Arduino pin activates the relay.

That 4-relay board uses 4 * ~75mA from the Arduino 5volt pin.
That could be a problem for some Arduinos on some supplies.
Leo..

Oh!

I wondered what the hell that jumper was about.

This would be my first attempt at using relays with an arduino - that's my excuse and I am sticking to it.

I take it that, since there is now opticoupling going on, I don't need the relay board GND and arduino GND connected?

boylesg:
I take it that, since there is now opticoupling going on, I don't need the relay board GND and arduino GND connected?

Yes.
The opto LEDs are powered from Arduino's 5volt rail, and switched on/off with the output pins.
No grounds involved.

If you do join grounds, you connect the Arduino circuit to the relay circuit, and loose opto isolation.
Leo..