Troubleshooting Flickering on Christmas Lights powered from relay controlled by Arduino

We are first time arduino users trying to use an Arduino Uno into shift registers into relays to power 16 Christmas lights. We are so close to having everything working but are getting flickering as the relays switch and trying to troubleshoot this piece. We believe the problem is with the relay or could be needing something to help with signal noise, but have gotten to the point where we are stuck.
Video of problem flickering
Flickering video

HARDWARE
Ardiuno Uno
2x Shift Register74HC595 Amazon Link
2x 8 Solid State Relay Amazon Link
8x outlets from home depot

Code
Works on our LED test system and the LEDs on the relays are working as intended, but have extra blinks on the actual lights.

//---------------------------------------
// CONSTANTS
//---------------------------------------

// name of SR pin -> Arduino pin # connected to SR pin
#define SER 4    // data in
#define SRCLK 6  // shift register clock
#define SRCLR 3  // clear shift register
#define RCLK 5   // storage register (sometimes called the latch pin)
#define OE 2     // enable output

#define TOTAL_SHIFT_PINS 16

void setup() {
  // put your setup code here, to run once:
  pinMode(SER, OUTPUT);
  pinMode(SRCLK, OUTPUT);
  pinMode(SRCLR, OUTPUT);
  pinMode(RCLK, OUTPUT);
  pinMode(OE, OUTPUT);
  clearShiftRegisters();
  turnOutputsOn();
}

void loop() {
  // put your main code here, to run repeatedly:
  shiftDataIn(HIGH);
  copyShiftToStorage();
  delay(2000);
  shiftDataIn(LOW);
  copyShiftToStorage();
  delay(2000);
}

// This doesn't change the value stored in the storage registers.
void turnOutputsOn() {
  digitalWrite(OE, LOW);
}

// clear the shift registers without affecting the storage registers.
void clearShiftRegisters() {
  digitalWrite(SRCLR, LOW);
  digitalWrite(SRCLR, HIGH);
}

// All the data in the shift registers moves over 1 unit and the new data goes in at shift register 0.
// The data that was in the shift register 7 goes to the next register (if any).
void shiftDataIn(int data) {
  digitalWrite(SER, data);
  digitalWrite(SRCLK, HIGH);
  digitalWrite(SRCLK, LOW);
}

// copy the 8 shift registers into the shift registers,
// which changes the output voltage of the pins.
void copyShiftToStorage() {
  digitalWrite(RCLK, HIGH);
  digitalWrite(RCLK, LOW);
}

Schematic / circuit diagram
Basic

Prototype board

Relays to outlets

Pictures of actual system (It didn't like me uploading so many pictures so these will follow)
Arduino to proto board
IMG_5585

Protoboard to relays and relays to outlets
IMG_5586
IMG_5587
IMG_5588
Note we did ground the relays to the ardiuno ground as we weren't getting all 8 on a board to turn on without it.

Outlets and power
IMG_5589
We use separate power for the arduino, relays, and outlets (this is all LED lights plugged into the outlets so running everything off our extension cord plugged into power)

As this is bulky and I'd rather leave it outside (as I did program it to always on so I could at least plug everything in while we figure out the input piece), I also have a little test system with LEDs that works great and doesn't flicker so trying to figure out what's going wrong between the two. This has 220 resistors in line with LEDs so I could figure out the code part and see what lights were going to be doing.

Any help figuring out how to stop the Christmas lights flickering would be great. If we can get the simple blink program working then I have a lot of more fun code ready, but it feels like it will give you a seizure with our current extra blinking going on. (I'd also love to understand what is going on differently between the LED test setup and the actual outlets into the lights outside so I can better replicate my test system so once we get this out we can move away from a very prototype mode to something more permenent.

Rest of the pictures

[grid]






[/grid]

  • Admire your efforts. :thinking:



  • Wires are very long and look a bit like a dog’s breakfast.
    Noise between wiring is a problem.

  • Cannot see decoupling on the switch register prototyping PCB.
    This needs to be corrected first thing. <—————<<<<<

  • Show us the back of the register board.

  • A proper neat schematic showing all connections is needed for us to see if there are design problems.

You failed to identify the 5 volt power to the Arduino. I see there is a warning about the unknown voltage range for the relays: "0V - 0.5V Low stage (SSR is OFF), 0.5V - 2.5V (unknown state), 2.5V - 20V High state (SSR is ON); ". Your project is likely spending too much time in the unknown state!

1 Like

What for? Uno has more than 16 i/o pins.

Looks like a recipe for getting someone electrocuted...

Yeah, we don't quite know what we are doing so there are wires everywhere.

We do not have any decoupling on the switch register. Looks like this may be the problem. It looks like we will need to buy some of those. 10nF size okay? And these would go between the VCC and GND pins for each shift register?

Here is a pic of the back of the board and a new schematic


We are powering the Arduino running the usb to power. I uploaded a new schematic pic. How do we get out of the unknown state? Would the decoupling on the shift register help with that?

  • Suggest you use 100nF ceramic capacitors; mount them as close as possible to each I.C. power pin.

  • Also, add a 100uF reservoir capacitor on the 5v line right where it connects to the prototyping PCB.

FIRST! determine that your project is spending too much time in the unknown state. Use an oscilloscope to monitor the signal.

  • We need to see a link to the relay board you are using.

  • There needs to be a proper reference point between the Arduino and this board.

Can you talk more about what the exact symptom is? Could it be that the lights you've chosen just flicker when power is first applied? Is the relay "bouncing"? If so, you'd hear it. Is there ample electrical capacity, or could turning them all on at once cause a low-voltage condition? I'm trying to think why else the lights would flicker.

  • Solid state relay.

OK, you'd need really good hearing to hear that.

1 Like

Are you certain the flickering isn't a design feature of the outdoor lights you selected and that you are within the 2A limit of each SSR?

Move everything off the solderless breadboard and solder onto the prototype board.

Update, we got capacitors and added one per each shift register connecting the VCC and Ground pins. We then tested it and we still had the flickering. We added in the capacitor to the 5v line prior to the PCB and tested again and still had the issue.

The Arduino isn't connected to the relay board directly. It all goes through the shift registers.

What for? Uno has more than 16 i/o pins.

We then decided to give this a try and go directly from the Arduino to the relay board. Pins 2 and 3 to switch 1 and 2 to test and see if that would solve things. It did even more strange flickering but was clearly on when it was supposed to be on, but it looks like the relay is stuck in an unknown state when not on. But I don't have an oscilloscope to measure. We connected up a multimeter and it is not switching cleanly off to 0.

At this point, I think we need different relay boards. Does anyone have a suggestion?

One at a time - scale up till you encounter a problem.

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