RF relay (receiver) and Arduino mega (transmitter)

Hi, I'm trying to control RF learning relay relay with Arduino Mega and transmitter

RF relay is programmed (learned by me) by two-click on it's button with the code below. I'm also using the very same code for turning relay on and off.

Problem is that it works fine only for 2 or 3 minutes (relay is switching on and after a second it goes off and after a second it goes on) and then relay starts chaos (it turn on and immediately off - does not wait a second) and sometimes it does not turn on at all and then after 10 or 15 minutes it stops working completely.
It seems like relay forget the code or receive something similar what turn him off. I have two separated relay module and both behaves almost the same - I must be doing something wrong.

When I use fabric remote control the relay works fine.

Would you have working code for controlling relay? Or should I use different library? Or control 433MHz protocol by calling mySwitch.setProtocol(...) or pulse length mySwitch.setPulseLength(...). I tried that but I didn't had luck with changing that.

my code:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

// setup code here, to run once:
void setup() {
// Transmitter is connected to Arduino Pin #10
} // setup

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

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

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

The fact that you have no problems with the "fabric" remote, means the relay is working fine.

Your mega TX is probably the problem, your code just has the relay going ON and OFF continuously, yet the "fabric" unit needs your finger to press.
So a different stress on the relay circuit.

Can I suggest you put some switches in your mega and control the relay that way before going any further?
What have you got the Relay powered with?

Thanks.. Tom... :slight_smile:

Thanks, I'll give it a try with Mega and transmitter and switches.

Meanwhile I recorded two videos. First video displays everything correct right after relays learned codes from fabric remote control.

Then I clicked a few minutes manually by remote control.

Second video at 0:16 displays strange behavior (turning on and off uncontrollably) when I hold button B which should just turn relay off (and worked on first video). Also notice at 0:21 that one of the relays didn't turned on when I pressed button A (which worked on first video).

Just a note I have already working controlling of my home lights from parking lot by the very same fabric remote control and mega+receiver and controlling of led stripe behind tv by mega+transmitter and nano+receiver+mosfet transistor. I;m trying to say something is already working correctly but relays don't.

In both cases you are using the remote buttons.

  • What is the difference and where does the mega come into the situation?
  • What is "fabric"?
  • What are you using to power the relays?

Thanks.. Tom.. :slight_smile:

Yes in both cases I'm using remote control - I wanted to demonstrate good behavior just after relays learned codes and then, after 30-40 of turning on/off, I wanted to demonstrate weird behavior of the relays.

1/ In the videos there is no Arduino Mega at all. I wanted to demonstrate strange behavior of relays.
2/ Fabric remote control is this

3/ RF relays are powered by 230V AC