Problem with IR relay

Previously I had made a IR relay system to control my room appliances. It consist of three relays, switching two lights and one fan. I had used standalone 328p circuit. It is working as expected but there are some problems with it. It some times (once in a week) stops working until i push restart button. I dont know the cause!

I have attached circuit diagram below, in which the powers source for standalone atmega is a mobile phone charger and that for relays is a 8V 2amp led lights adapter. Relays used in this circuit were 5volt relays.

Please help me to solve this problem.
Is phone charger is not sufficient power supply?...
Do i need to enable brown out detection?...

Appliances connected with relay in this order(in the attached picture). Also i want to meet that i had used a two way switch to toggle between normal wall switchboard switching method and IR relay switching method.

For your 240VAC appliance connection diagram, I think you mean N (neutral), not GND. Otherwise, this is a problem.

Does the issue go away if the 240VAC is disconnected or turned off to all relays? Do you have to wait a week to find out or does the problem occur when the relay(s) switch the load, or if all relays are energized then switch the load?

Sorry for that mistake, yes it is Neutral not GND.

Actually when i switch repeatedly, mostly then it got hang. Or sometimes when i came in room and try to switch appliances, it fails to work in first attempt only. Not a specific way of its failure.

Also thanks for reply ddloyd.

Try to draw a real transistor next time :wink: I was thinking, huh, what's he doing with those AND gates... Same for the diode.

But what I do miss are 100nF ceramic caps near the ATmega and the IR.

And as code problem isn't ruled out as well. So please post the code.

Actually when i switch repeatedly, mostly then it got hang. Or sometimes when i came in room and try to switch appliances, it fails to work in first attempt only. Not a specific way of its failure

Need to add arc-suppression. Some common methods are MOV, Ferrite Core, RC Snubber.

I would try ferrite cores first (if available) or use MOVs like this.

Hi,
Can you verify that the transistors are BC548, NPN and that the BC548 are between the relay coil and the +8V supply?
This is the way you have it drawn, you are switching high side and would be having problems biasing the BC548 into conduction.

Also the direction of your protection diodes on the relay coils, the cathodes appear to be connected to the neg end of the coil this would make the current bypass the coil and the relay will not function.


As has been mentioned can you use transistor symbol please.

Looking at your 240Vac circuit, are you aware that when in IR Control mode, none of your appliances are protected by your Switch Board, you bypass your fuses in IR Control mode.

Thanks.. Tom... :slight_smile:

Sorry for the wrong symbol used for transistor, it is 'BC 547' used in an ' emmiter follower circuit'.

Septillion, there is 100uF capacitor present between IR receiver's terminals. Also there are 100nF capacitor between pin 7-8 and pin 21-22 of atmega(i forgot that in circuit diagram ). Also i will attach the code in 2-3 hours.

I agree ddloyd, i think spark production may be a factor. Due to unavailability of ferrite core and mov (right now), can you please tell more about rc snugger. Also please can you explain how this spark production in relay cause the whole circuit failure and require to be reset.

Also i want to mention here that previously when there was no reset switch in my circuit, the whole system got back to work (after failure) on triggering the 2 way switch(used in 240 v circuit diagram) repeatedly very fast. I think it cause the circuit's power supply to stop for fraction of seconds which results in reset of the system...

Thanks for reply guys.

I agree ddloyd, i think spark production may be a factor. Due to unavailability of ferrite core and mov (right now), can you please tell more about rc snugger. Also please can you explain how this spark production in relay cause the whole circuit failure and require to be reset.

MarkT gave a good explanation here.

To eliminate interference on the power rails, a separate power source for relay coil power and Opto-Isolators (Opto-Couplers) are commonly used in many of the relay modules that are available. This doesn't suppress the arcing on the contacts, it just isolates the Arduino from the conductive interference.

Solid State relays have built-in opto isolation and the zero-cross switching type doesn't create EMI/RFI problems.

RC snubbers are usually sized for the type and size of load ... there are some examples on this forum (I haven't required using these myself). Caution if switching lamp loads ... the small current through the snubber can cause fluorescent and other lighting to periodically flicker or glow dim while the relay contacts are open (lamp load switched off).

Ok. I will use optocoupler. Will it be enough to prevent the circuit from interference?

Ok. I will use optocoupler. Will it be enough to prevent the circuit from interference?

You would need to use 3 optocouplers and remove the ground wire that joins the ground of both supplies.
You may need to increase the distance from the Arduino board to the AC circuit and relays (possibly up to 2 meters).

No guarantees (the arcing will still occur) however the Arduino will be immune to any conductive interference. Usually opto-isolation and enough distance resolve the problem.

:astonished: 2m is quite a long distance.

Do use of varistor (MOV, to supress spark) along with opto coupler for each relay solves the problem completely? I.e. No need to place them 2m apart?

I've had great success with just MOVs. These are the easiest to install and are inexpensive. Next easiest would be using ferrite cores.

I think MOVs is a really good place to start, but there's no guarantees.

Thanks a lot. I'll try that as soon as it will be available to me.

Hi,

Sorry for the wrong symbol used for transistor, it is 'BC 547' used in an ' emmiter follower circuit'.

Even in emitter follower, the 5V output of the arduino will only give 5 - 0.7 = 4.3V for your relays, as the emitter will be 0.7V below the base.

This is the common way of doing it.

But, I agree opto couplers will be better, and remember to keep ALL your 240Vac wiring away from the arduino and its low voltage circuitry.

Tom..... :slight_smile:

Yes previously I had used bc 547 in common way but it didn't work. So i used emitter follower circuit, and that worked fine. But now i am making a new circuit using 12 v relay and it not working in either way(using BC547). So i am thinking to use 2N2222 NPN transistor.

Also let me know that if i still need transistors, along with opto coupler?

Can i use opto couplers at place of transistor as a switch?

Please let me know if i said something wrong .

Your schematic is incredibly hard to read, but it appears that the diodes on the relays are backwards.

#include <IRremote.h>

int RECV_PIN = 11;
int r3 = 9;
int r2 = 12;
int r1 = 10;
IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(r3,OUTPUT);//Pin For relay3
  pinMode(r2,OUTPUT);//Pin For relay2
  pinMode(r1,OUTPUT);//Pin For relay1
}

void loop() 
{
  if (irrecv.decode(&results)) 
  {
    if(results.value==551520375)//<--Replace the button 1 decimal value here
    {
      if(digitalRead(r3)==LOW)
      {
        digitalWrite(r3,HIGH);
      }
      else{
    digitalWrite(r3,LOW);
    }
    }
    if(results.value==551504055)//<--Replace the button 2 decimal value here
    {
      if(digitalRead(r2)==LOW)
      {
        digitalWrite(r2,HIGH);
      }
      else{
    digitalWrite(r2,LOW);
    }
    }
    if(results.value==551536695)//<--Replace the button 3 decimal value here
    {
      if(digitalRead(r1)==LOW)
      {
        digitalWrite(r1,HIGH);
      }
      else{
    digitalWrite(r1,LOW);
    }
    }
    if(results.value==551489775)//<--Replace the button 4 decimal value here
    {
       if(digitalRead(r1)==HIGH)
      {
        digitalWrite(r1,LOW);
      }
       if(digitalRead(r2)==HIGH)
      {
        digitalWrite(r2,LOW);
      }
     
     if(digitalRead(r3)==HIGH)
      {
        digitalWrite(r3,LOW);
      }
    }
    
    irrecv.resume();
  }
}

That's the code i had used.

aarg:
but it appears that the diodes on the relays are backwards.

I think flyback diodes are used in that way only, once i had connected that oppositely and it didn't work.

Sorry for the rough schematic.

Rishabh8721:
I think flyback diodes are used in that way only, once i had connected that oppositely and it didn't work.

Sorry for the rough schematic.

When I say backwards, I do not mean reverse biased. In fact, they should be reverse biased. On the diagram, they are forward biased.