Go Down

Topic: 315 MHz RF transmitting correct code but power outlet won't switch on (Read 2 times) previous topic - next topic

tomato16


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: [Select]

  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: [Select]

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?

sp_mike

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 !



tomato16

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!


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

Go Up