Go Down

Topic: 5v Relay acting weird (Read 1 time) previous topic - next topic


Oct 26, 2020, 07:51 pm Last Edit: Oct 26, 2020, 07:54 pm by boshkash1151
I have the following attached diagram. The problem is when I disconnect the red line everything works as expected (i.e. turning off channel 0 turns off channel 0). When the red connection is connected and I try to toggle a channel other channels would turn on and random toggle occurs. For example turning on channel 4 only would turn off channel 1,2,3 & 5 leaving 6,7,8 on



It sounds like you have some wiring problems.  Be sure all the grounds are connected.  Debug it and get to work before connecting the mains. If you get when the mains equipment is operating it is probably generating EMI which is messing up your controller.
This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!


I went ahead and changed the controller and everything works as expected. The only problem now is that when i turn on a channel it closes another and then after a while it turns the switch channel back on . Maybe EMI is messing stuff, so how can I shield that 



Nov 06, 2020, 09:50 pm Last Edit: Nov 06, 2020, 09:51 pm by hugo007
You should add a snubber circuit to the loads to minimize de EMI generated.
See this:
Snubber Circuit
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


Hi Hugo007

Do you mean something like that : https://www.amazon.com/Kingjinglo-Absorption-Snubber-Protection-Resistance/dp/B081F9W9X6

Also could that be the reason. It sometimes works and then a day or two it starts acting weird again.


Please can anyone help here?


In order to help you, we need to see your code and understand your wiring.  And we need you to be specific about the problem, what you've tested and found, and details about your grounding connections (as has been suggested).  

Is your AC / DC adapter providing a grounded output or floating?  What is the connection shown as a red conductor on the diagram - is that an AC ground or is it the AC Phase (hot) wire?

Also,what is the available power at the DC adapter?  For example, have you added up all the required power needed to drive the relays, the ESP and the 595 plus any other circuitry that may not be shown?  If the adapter cannot supply sufficient power during relay switching for example, then there's no telling what the outputs might do.  We don't know if your relays are opto isolated, or whether they are high side or low side switching (which may be affected by the grounding issues previously mentioned.  People here want to help.  We need all the detail.

You see, we  cannot help because we do not know enough about your circuit, your code and your problem.  We know only what you have said so far, and it's not enough to diagnose your problem and help you resolve it.  


Hi steve_mcdonald,

I know it has been a long time and I might not get a reply, but I hope for the best :) 

for the code and wiring I followed this tutorial : https://techtutorialsx.com/2016/08/31/esp8266-connection-to-sn74hc595-via-spi/

The relay is this one which is currently unavailable and yes it is opto isolated: https://www.amazon.com/SainSmart-101-70-102-8-Channel-Relay-Module/dp/B0057OC5WK

The DC adapter is one of these and rated at 700ma ( I tried adaptor of up to 2A, but nothing changed) : https://www.aliexpress.com/item/33012749903.html

The red wire is the live wire from the AC while the other coming out of the source is the AC GND.


You'll need:

  • MOV on each relay (NO to COM)
  • 0.1µF capacitor from VCC to GND on 74595
  • Separate power supply for relay board (this enables opto isolation)


The added protection of separating power supplies is sensible and good advice, and the 595 should have a capacitor as noted.  As far as the MOV, I may have misunderstood, but would it be better placed across the line (Active & Neutral) rather than in series with e the Active (across the relay contacts)?


Feb 25, 2021, 10:20 pm Last Edit: Feb 26, 2021, 03:34 am by dlloyd
@steve_mcdonald; Good question. I'm sure that connected across the switched line (or load) to neutral would better at limiting the peak voltage, but I'm wondering if connected across the contacts would be better at extinguishing (or preventing) arcing. It seems that its more popular to connect across the contacts, but that might be because there's no neutral available or that's its easier to mount the MOVs on a PCB (or both). Not really an answer ... both methods do work, but probably one works better than the other.

Go Up