315 MHz RF transmitting correct code but power outlet won't switch on

Hi everyone. I'm trying get use my Arduino UNO send an RF signal to my RF outlet switch to turn on my lamp.

Hardware

  • Arduino + 315 MHz transmitter module
  • Arduino + 315 MHz receiver module
  • Remote control power outlet with remote

What I have done so far

  1. Hook up 1st Arduino to RF transmitter module, uploaded sketch RCswitch/SendDemo
  2. Hook up 2nd Arduino to receiver module, uploaded sketch RCswitch/ReceiveDemo_Advanced
  3. Copied down the code used after pressing "ON" on my RF remote
Decimal: 13328 (15Bit) Binary: 011010000010000 Tri-State: not applicable PulseLength: 1195 microseconds Protocol: 2
Raw data: 11968,552,1864,1764,656,1768,656,548,1864,1768,664,544,1860,556,1860,548,1864,552,1856,556,1856,1768,660,552,1864,548,1864,552,1860,548,1864,
  1. Modify SendDemo sketch to send the same signal
mySwitch.setProtocol(2);
mySwitch.setPulseLength(1185);
mySwitch.send(13328, 15);
  1. Monitor the serial output on the other Arduino running ReceiveDemo_Advanced
Decimal: 13328 (15Bit) Binary: 011010000010000 Tri-State: not applicable PulseLength: 1195 microseconds Protocol: 2
Raw data: 11956,1180,2416,2372,1220,2376,1220,1180,2412,2376,1224,1176,2412,1180,2420,1176,2412,1180,2416,1180,2412,2376,1224,1176,2412,1180,2420,1176,2416,1176,2420,

The problem
Even though the transmitter module is capable of sending a nearly identical signal, the RF outlet doesn't trigger and my lamp doesn't turn on. The remote control still works. Pressing the "ON" button on the remote generates output in the serial monitor, nearly identical to the signal being sent by the transmitter.

Any suggestions or comments would be greatly appreciated. Thank you for taking the time to help me.

Here are a few other things that I have tried with no success.

  • moving the transmitter closer to the RF outlet (3-6 inches away)
  • sending the signal multiple times (invoking the send() function 3 times)
  • changing the repeat transmit using setRepeatTransmit() to 5, 15, 50

I successfully used my 433 mhz transmitter (running Uno here) to toggle my ac socket using this sketch:

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

void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
mySwitch.setPulseLength(165);
}

void loop() {

mySwitch.send(13456849, 24);

delay(1000);
mySwitch.send(13456849, 24);
delay(10000);
}

// note: using 24 bit, pulse length 165

sp_mike:
I successfully used my 433 mhz transmitter (running Uno here) to toggle my ac socket using this sketch:

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

void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
mySwitch.setPulseLength(165);
}

void loop() {

mySwitch.send(13456849, 24);

delay(1000);
mySwitch.send(13456849, 24);
delay(10000);
}

// note: using 24 bit, pulse length 165

Thanks sp_mike

Using the ReceiveDemo sketch, the serial monitor shows a pulse length of 1195 when I press the ON button on my RF remote.

I assumed that the pulse length needed to be the same for the remote outlet to recognize the signal. Are you suggesting that I try shorter pulse lengths?

I was just coming back to the forum to clarify what I actually meant. These were just the figures for what I was using in my environment, but that you need to use your own figures. You have no doubt tried my values by now anyway.

sp_mike:
I was just coming back to the forum to clarify what I actually meant. These were just the figures for what I was using in my environment, but that you need to use your own figures. You have no doubt tried my values by now anyway.

Thank you sp_mike. It's good to know that my code sketch isn't too far off from yours.

I think I'm going to try a few more things as well.

Good luck with it. I hope your chipset is supported !

Here's what I've just tried. However, still no luck.

  • I opened the remote control. The IC part number (AUT980202) doesn't resemble anything that is listed on the rc-switch site as supported. However, I don't believe I should be checking the remote, perhaps I should be checking the RF outlet instead
  • Tried changing protocol to 1, didn't work
  • Tried sending signal using a binary code, didn't work
  • Didn't bother with tri-state because I don't fully understand it and the ReceiveDemo did not register a tri-state code when my remote was pressed

For anyone wondering about the outlets, they are the same as the outlets used in Stephen's project, Android/Arduino RF Outlets Selector | 33 Snowflakes

I bought 2 packs of these this morning: http://www.homedepot.com/p/Verdant-Electronics-Indoor-Wireless-Remote-Control-Kit-RC-015-3/202353567
I am also not having any luck with my 315mhz transmitter. More research to do. I'll let you know if I make any progress.

I found the trick. It now works. First the sketch:

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

Serial.begin(9600);

// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);

mySwitch.setPulseLength(800);
// mySwitch.setProtocol(2); // ** DO NOT define a Protocol** if u do it will override the setPulseLength of 800
}

void loop() {

mySwitch.send(13380, 15); // turn on CH 'A' device 1
delay(2000);
mySwitch.send(13348, 15); // turn off CH 'A' device 1
delay(2000);

mySwitch.send(13332, 15); // turn on CH 'A' device 2
delay(2000);
mySwitch.send(13324, 15); // turn off CH 'A' device 2
delay(2000);

mySwitch.send(13444, 15); // turn on CH 'A' device 3
delay(2000);
mySwitch.send(13572, 15); // turn off CH 'A' device 3
delay(2000);

mySwitch.send(13393, 15); // turn on CH 'C' device 1
delay(2000);
mySwitch.send(13345, 15); // turn off CH 'C' device 1
delay(2000);

mySwitch.send(13329, 15); // turn on CH 'C' device 2
delay(2000);
mySwitch.send(13321, 15); // turn off CH 'C' device 2
delay(2000);

mySwitch.send(13441, 15); // turn on CH 'C' device 3
delay(2000);
mySwitch.send(13569, 15); // turn off CH 'C' device 3
delay(2000);
}

sp_mike:
I found the trick. It now works.

Thank you sp_mike! You are incredible. That worked!

I found that setting the protocol to "2" works as long as you set the pulse length afterwards.

  mySwitch.enableTransmit(10);
  mySwitch.setProtocol(2);
  mySwitch.setPulseLength(800);

I also noticed was that if you don't set a protocol, the ReceiveDemo sketch won't be able to detect the signal and display it in the serial monitor. My guess is that the RCSwitch library isn't able to detect a signal that doesn't follow a protocol it recognizes. Setting the protocol to "2" fixes this.

If I run the ReceiveDemo sketch to capture the button presses of the remote, the serial monitor shows that each signal has a pulse length of approximately 1195 microseconds.

Decimal: 13328 (15Bit) Binary: 011010000010000 Tri-State: not applicable PulseLength: 1195 microseconds Protocol: 2
Raw data: 11968,552,1864,1764,656,1768,656,548,1864,1768,664,544,1860,556,1860,548,1864,552,1856,556,1856,1768,660,552,1864,548,1864,552,1860,548,1864,

The primary difference was using 800 microseconds (thank you for this!) instead of 1195 microseconds. However, I still don't understand why a pulse length of 1195 microseconds would work with the remote but not with our Arduino circuits? Why did you choose to use a pulse length of 800 microseconds?

I'm glad you got your sketch to work. How I found the correct Pulse Length (or close anyway) was by using a radio receiver tuned to 315 mhz. I listened to the audio frequency received from the remote control's signal and then compared it to what I heard coming from my Arduino/315mhz transmitter. I noticed that the Arduino was sending out a much higher pitch signal than the remote control. I found that it was the PulseLength setting that raised or lowered the audio frequency. The value of 800 sounded dead on to my ear. So, from now on I will not just accept the PulseLength value that the ReceiveDemo sketch gives me. I'll verify it with the radio receiver. By the way, the ReceiveDemo sketch gives me a PulseLength of 1196 as received from the remote control. Here is what I found with the PulseLength settings: 770 = no response, 780-810 = normal function, 820=intermittent, 830=no response. I did some testing like you did and verified your results: the Serial Monitor won't display any results if the protocol is not set, even though the ac socket works fine. I will go with your settings of:

mySwitch.enableTransmit(10);
mySwitch.setProtocol(2); // if you use this statement, be sure that the 'mySwitch.setPulseLength(800)' statement follows
mySwitch.setPulseLength(800); //this statement may be used without a 'mySwitch.setProtocol(2)' statement

note: if the 'mySwitch.setPulseLength(800)' is placed "before" the 'mySwitch.setProtocol(2)' the PulseLength from the RCSwitch library will be used, which is 650.

We got a winner !

I can't believe you actually whipped out a radio! That is quite clever of you. Kudos. I will definitely give that a try next time.

Thank you again sp_mike!

FYI:
This is the radio (actually a usb dongle) that I used:
http://www.ebay.com/itm/RTL-SDR-Realtek-RTL2832U-R820T-DVB-T-Tuner-Receiver-in-Retail-Packaging-USA-/331084730394?pt=US_Video_Capture_TV_Tuner_Cards&hash=item4d1630101a

It is the best bang for the buck I have ever made. I purchased them about a year ago for around $ 9.00 U.S. I have 10 of them. Their sensitivity can easily compete with a several hundred dollar scanner. I use SDR# software with them. They cover 24 mhz to around 1700 mhz (I believe). Lots of support on the web for them. Known as "RTL-SDR".

All,

I found a similar device at Home Depot from a company called Westek. Model RFK306.

It uses the AUT980202 chip as well and comes in 4 pre-defined channels (A, B, C and D)

I found that I needed to change the .send() method to 17 bits to use a device at address D. I had to shift the magic values in the above code by 2 bits to accommodate the 17 bit transmit. Other than that, the pulse length of 800 etc. worked well.

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

Serial.begin(9600);

// Transmitter is connected to Arduino Pin #11  
mySwitch.enableTransmit(11);
mySwitch.setProtocol(2);
mySwitch.setPulseLength(800); 
//     //  ** DO NOT define a Protocol** if u do it will override the setPulseLength of 800
}

int32_t iOn = 53440;
int32_t  iOff = 53280;
int32_t adD = 2;
int32_t adC = 4;
int32_t adB = 8;
int32_t adA = 16;
void loop() {
mySwitch.send(iOn + adD, 17);
delay(2000);  

mySwitch.send(iOff + adD, 17);
delay(2000);
}

Bought 3 similar aut980202 based remote switches at a second-hand shop today... they were labeled CH 'B' and sp_mike's code only explicitly covered 'A' and 'C' channels... so I decoded the binary and figured the last 3 bits defined the channel... so made this table:

11010 001000 100  CH A 1 ON     13380
11010 000100 100         OFF    13348

11010 000010 100  CH A 2 ON     13332
11010 000001 100         OFF    13324

11010 010000 100  CH A 3 ON     13444
11010 100000 100         OFF    13572

11010 001000 010  CH B 1 ON     13378
11010 000100 010         OFF    13346

11010 000010 010  CH B 2 ON     13330
11010 000001 010         OFF    13322

11010 010000 010  CH B 3 ON     13442
11010 100000 010         OFF    13570

It worked!