Pages: [1]   Go Down
Author Topic: 315 MHz RF transmitting correct code but power outlet won't switch on  (Read 1664 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
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,
4. Modify SendDemo sketch to send the same signal
Code:
mySwitch.setProtocol(2);
mySwitch.setPulseLength(1185);
mySwitch.send(13328, 15);
5. Monitor the serial output on the other Arduino running ReceiveDemo_Advanced
Code:
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 17, 2014, 02:23:51 pm by sp_mike » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
  • Confirm that the chipset in the remote is on the supported device list, https://code.google.com/p/rc-switch/
  • Try changing the protocol to 1 (instead of 2) and then setting the pulse length afterwards
  • Try sending the signal using a binary code
  • Try sending the signal using a tri-state code
Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good luck with it. I hope your chipset is supported !
« Last Edit: January 17, 2014, 04:45:41 pm by sp_mike » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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, http://www.33snowflakes.com/blog/arduino-wireless-outlet/
« Last Edit: January 17, 2014, 09:02:45 pm by tomato16 » Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}




   
 

« Last Edit: January 19, 2014, 05:55:43 am by sp_mike » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
  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.

Code:
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?
Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !


« Last Edit: January 20, 2014, 07:45:48 am by sp_mike » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Logged

Spokane,WA
Offline Offline
Newbie
*
Karma: 2
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Pages: [1]   Go Up
Jump to: