Using multiple SSRs simultaneously

I'm pretty new to arduino and electronics, so bear with me on what is likely an obvious question.

I'm trying to use a Mega 2560 and a set of relays to turn on and off Christmas lights in a pattern. They all turn on individually, but when I try to turn them all on at the same time, only 4-5 of them will turn on out of 10 total.

I know there is a 200ma current limit from the board, so I'm guessing that's why I'm having issues trying to turn them all on at the same time. I've tried putting resistors between the relays input voltage and the arduino, but if I go above 10 ohms the SSRs won't open.

I'm using the arduino to open and close the relay, and the relay is connected to both sides of the neutral line in a short extension cord that the lights are plugged into. This way it is easy to swap out which lights are being turned on and off.

Any help is appreciated, thanks!

Here is the setup for 1 of the relays, there are 10 of these total:

I'm using these SSRs: https://www.amazon.com/gp/product/B07MQVQPDK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

The code is pretty basic:
int ssr13 = 13;
int ssr12 = 12;
int ssr11 = 11;
int ssr10 = 27;
int ssr9 = 47;
int ssr8 = 8;
int ssr7 = 4;

int CycleCounter = 0;

void setup() {
// put your setup code here, to run once:
pinMode(ssr13, OUTPUT);
pinMode(ssr12, OUTPUT);
pinMode(ssr11, OUTPUT);
pinMode(ssr10, OUTPUT);
pinMode(ssr9, OUTPUT);
pinMode(ssr8, OUTPUT);
pinMode(ssr7, OUTPUT);

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:

digitalWrite(ssr13, HIGH);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,LOW);
Serial.println("1");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,HIGH);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,LOW);
Serial.println("2");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,HIGH);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,LOW);
Serial.println("3");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,HIGH);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,LOW);
Serial.println("4");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,HIGH);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,LOW);
Serial.println("5");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,HIGH);
digitalWrite(ssr7,LOW);
Serial.println("6");
delay(2000);

digitalWrite(ssr13, LOW);
digitalWrite(ssr12,LOW);
digitalWrite(ssr11,LOW);
digitalWrite(ssr10,LOW);
digitalWrite(ssr9,LOW);
digitalWrite(ssr8,LOW);
digitalWrite(ssr7,HIGH);
Serial.println("7");
delay(2000);

digitalWrite(ssr13, HIGH);
digitalWrite(ssr12,HIGH);
digitalWrite(ssr11,HIGH);
digitalWrite(ssr10,HIGH);
digitalWrite(ssr9,HIGH);
digitalWrite(ssr8,HIGH);
digitalWrite(ssr7,HIGH);
Serial.println("All");
delay(4000);

}

What is the coil resistance of those relays ?

FYI - those are not "SSRs".

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Have you considered the obvious solution of using an external power supply ?

The usual problem with relays and Arduino is that the relay coils need a fair bit of current to activate, somewhere in the 20-90mA range and so, as you observe, the Mega can't source enough current. With a multiple relay module, you can usually power the coils from another supply and the Arduino just has to handle triggering the optoisolator.

I don't think what's shown in your drawing is the same thing as the Amazon relay in the link. The drawing shows sone kind of SSR (solid state relay), but the Amazon part is a conventional coil relay, which probably requires a lot more current, and which should have a diode across the coil to prevent spikes when the relay is turned off. I think you would need to use transistors to drive the coils, powered by a 5V source that doesn't go through your Mega.

Can you tell us what current flows through the relay contacts when it's turned on, or how many watts a string of lights consumes?

Show us a real schematic of your wiring.

You cannot drive or control those bare mechanical relays directly with an Arduino output.

You need a transistor switch, protected by a flyback diode, connected to the Arduino output to control the relay and an external power supply of the correct voltage and sufficient current to drive the relay.

Right! Those are not SSRs (solid state relays), and yes current is the problem. The specs I found say 0.35 Watts for the coil, which is 70mA at 5V.

There are SSRs that operate at 5V and low current but they can be tricky... AC & DC (on the "contact side") relays are not interchangeable and sometimes they "leak" so they don't shut-off completely with a "light" (low current) load.

You can't just stick a resistor in series with the relay coil... Yes, that will reduce the current and it reduces the voltage across the coil.

See Ohm's Law* and Voltage Divider.

So it seems.

If you are using the mechanical relays specified (correct link https://www.amazon.com/gp/product/B07MQVQPDK/) then you have seriously overloaded the Mega pins by short-circuiting them.

A Mega 2560 would seem to be serious overkill for such a project - to use these relays, you could easily drive eight at a time with a TPIC6B595 and control a number of these using three Arduino pins.

In fact, you could/ should do the same to drive real SSRs.

Suitably dangerous! It is the live line that should always be switched. :astonished:

Hi, @cjacobs61
Welcome to the forum.
Your link shows these;

Can you please post a picture(s) of your project?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Hello
Beside the hardware discussion, are you happy with your sketch?

Good question.

const byte SSR [] = { 4, 8, 47, 27, 11, 12, 13 };

void setSSR ( byte n )
{
  byte B = 1 << n;
  for ( byte N = 0; N < 7; N ++ )
  {
    if ( n < 7 ) digitalWrite ( SSR [ 6 - N ], bitRead ( B, N ) );
      else digitalWrite ( SSR [ N ], HIGH );
  }
  delay ( 2000 );
  if ( n > 6 ) delay ( 2000 );
}

void setup ()
{
  for ( byte n = 0; n < 7; n ++ ) pinMode ( SSR [ n ], OUTPUT );
  Serial.begin ( 115200 );
}

void loop ()
{
  for ( byte Light = 0; Light < 8; Light ++ )
  {
    Serial.println ( Light );
    setSSR ( Light );
  }
}

Hello
This is a smart and pretty solution by using the bitRead() function, I love bit operations.
Have a nice day and enjoy coding in C++.

Thanks, @paulpaulson. Good day to you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.