rf-switch and 315mhz transmitter is a no go?

Hi guys,

I purchased few days ago this 315mhz rf kit http://www.ebay.ie/itm/121038336534?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#ht_3567wt_1163 for a small robot i am building for my son. I was planning to record the signal the key fob sends with the famous rc-switch library(GitHub - sui77/rc-switch: Arduino lib to operate 433/315Mhz devices like power outlet sockets.) and then with those values do my stuff. Buttt i am not getting anything to the the serial monitor. In the past i used a 433mhz transmitter and it worked just fine but now i am just not getting anything. Any ideas - directions?

You have the kit with transmitter and receiver (with decoder chip) at 315MHz ?

And do you also have a 315MHz receiver ?
That receiver is connected to the Arduino ?

In the photo I see a SC2272 decoder chip on the receiver board.
The transmitter has probably a SC2262 inside.
Did you run the example sketch of RCswitch that recognizes the protocol and the timings ?

hi erdin, my answer in all your questions is yes! I even opened the transmitter and I confirmed that the oscillator is at 315mhz. from the rs-switch library I run the receive_simpl and advanced. I used the digital pin 2 as the creator suggests. do I have to change somewhere what band I want to use?

There is no band, and no channels. Only 433MHz and 315MHz.

If you have a 315MHz receiver without decoder chip, the advanced RCswitch example should be able to recognize it.
Some receiver modules have a weak output and is not always accepted by an Arduino input.

I had a piezo connected to my Arduino and I changed the RCswitch library so that I could hear a 'click' when something was received. You have to do something like that. You can also use Serial.println in the interrupt of RCswithc, but using the Serial function in an interrupt will work only once (and maybe not even a full line of text).

There are four buttons on the remote control, and respectively correspond to the four data bits to the receiving board output pin D0, D1, D2, and D3 of. Press the buttons transmit signals, the corresponding data bit is output high.

first, test pair without Arduino, connect 5 v power, press the button 0~3, receiver's D0~D3 should read high.

second, connect it with Arduino, use digitalRead to get data, and no famous library needed.

@UnSeen =- were you able to get your 315 to work with the arduino?

Hope so...

Gaver

Hi Everyone,

i'm stuck ,I need some help, I've been playing around with RF 315mhz transmitter/receiver. I was able to get the receiver received the raw code from one of my RF light switch control. But I unable to get the transmitter to send the same code out: here is the codes I've used for 315mhz: which i got from RCSwitch library

Receiver:

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();
#define RelayPin13  13 // led for RF low=ON
#define RelayPin12  12 // led for RF low=ON
void setup() {
  Serial.begin(9600);
  pinMode(RelayPin13, OUTPUT);
  pinMode(RelayPin12, OUTPUT);
 digitalWrite(RelayPin13, HIGH);
 digitalWrite(RelayPin12, HIGH);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {
    
    int value = mySwitch.getReceivedValue();
    
    if (value == 0) {
      Serial.print("Unknown encoding");
       digitalWrite(RelayPin13, LOW);
        digitalWrite(RelayPin13, HIGH);
    } else {
      digitalWrite(RelayPin12, LOW);
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
      digitalWrite(RelayPin12, HIGH);
    }

    mySwitch.resetAvailable();
  }
}

output captured on Serial port:
Received 1080228 / 24bit Protocol: 1

Transmitter:

/*
  Example for different sending methods
  
  http://code.google.com/p/rc-switch/
  
  Need help? http://forum.ardumote.com
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

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

  // Optional set pulse length.
  // mySwitch.setPulseLength(320);
  
  // Optional set protocol (default is 1, will work for most outlets)
  // mySwitch.setProtocol(2);
  
  // Optional set number of transmission repetitions.
  // mySwitch.setRepeatTransmit(15);
  
}

void loop() {

 
  /* Same switch as above, but using decimal code */
  mySwitch.send(108228, 24);
  delay(1000);  
 
}

nothing happened after upload this code to my Arduino mega 2560
315mhz transmiter wiring- data pin connected to arduino pwm pin 10, vcc to arduino 5v , gnd to arduino gnd + 20inches wire for antena

please help me to point out what am I missing here ?

Thanks

Could you modify your first post and put the code between [code] ... [/code] tags ?
You could have started a new topic for this, but it's okay.

Do you have those very cheap modules from Ebay ?
They work well, some others use inverted signals.

I think your transmitter sketch is okay.
Perhaps the protocol or the number is not right ?
If you run the advanced example, carefully write down the number.

The RCSwitch code is not the best code I have seen. I also assumes some timings, that could be different for some chips. If you can capture the receiver output signal, perhaps you can see if it is different than normal.

Thanks Erdin,

I will post the pic of the setup and more details on data captured on serial port
I hope I had a bad RF transmitter, I bought them from china for 3$
I will order a new set and see what happen.

Tree whole dollars ? Why pay so much ?
The cheapest ones are okay:

They have normal signals for the transmitter and receiver (0 = no signal, 5v = signal). I set my Arduino input for the receiver to pinMode( INPUT_PULLUP);, because the output pin of the receiver is a little weak, but it will work also with normal pinMode( INPUT);.

You have to add an antenna wire. Without antenna the range could be 2 meters, and with antenna it is 20 meters (through walls and bricks and concrete). More range is possible if the antenna length is tuned and the transmitter is at 12V.

This page contains a lot information about them. Perhaps you have to open the transmitter to see the chip that is used. That page is for a module with a decoder chip included, so that is a different.

More details on data capture on serial port

Decimal: 1080228 (24Bit) Binary: 000100000111101110100100 Tri-State: not applicable PulseLength: 299 microseconds Protocol: 1
Raw data: 9300,264,956,16,52,172,976,316,1688,4248,116,32,100,36,1056,60,76,32,4080,56,316,876,328,860,336,868,328,276,924,1812,420,3700,276,3772,644,32,24,344,84,2956,204,1164,136,1472,2888,512,3596,428,44,

I think i had the similar transmitter to the one on your ebay link

Yes, those are the cheap 315MHz modules.

In your transmitter sketch, you use a different protocol, the wrong number and the pulse length is a little different.

Thanks Erdin

strange thing is the data captured from my RF remote had inconsistent "pulse length"
below is data from the same button pressed for a few times. What would I use for pulse length value ? 300 or 299

Decimal: 1080226 (24Bit) Binary: 000100000111101110100010 Tri-State: not applicable PulseLength: 300 microseconds Protocol: 1
Raw data: 9304,260,936,260,940,256,940,856,340,260,936,260,936,260,944,256,952,248,1064,2544,2240,1020,180,632,340,860,340,260,936,68,120,76,3872,360,3888,72,28,28,3972,216,3764,364,64,44,3680,152,36,64,2500,

Decimal: 1080226 (24Bit) Binary: 000100000111101110100010 Tri-State: not applicable PulseLength: 299 microseconds Protocol: 1
Raw data: 9308,260,936,260,936,260,932,864,340,256,940,256,956,244,960,280,1428,708,3332,2084,148,692,336,860,336,860,340,260,936,860,340,860,340,856,344,256,940,452,36,28,196,52,3344,404,3576,476,3712,316,1184,

Decimal: 1080226 (24Bit) Binary: 000100000111101110100010 Tri-State: not applicable PulseLength: 299 microseconds Protocol: 1
Raw data: 9304,260,936,260,936,264,932,864,336,260,936,260,936,260,936,264,936,260,932,864,336,860,340,860,340,860,340,256,940,860,340,856,344,856,340,720,88,36,768,48,2392,684,3524,240,36,116,3632,32,16,

Decimal: 1080226 (24Bit) Binary: 000100000111101110100010 Tri-State: not applicable PulseLength: 300 microseconds Protocol: 1
Raw data: 9304,260,936,260,936,260,936,860,340,260,932,264,936,260,936,260,936,264,936,860,336,864,340,856,340,860,340,256,940,860,348,852,360,1228,816,12,928,116,1592,568,3640,68,16,304,740,44,2908,120,100,

Decimal: 1080226 (24Bit) Binary: 000100000111101110100010 Tri-State: not applicable PulseLength: 300 microseconds Protocol: 1
Raw data: 9308,256,936,260,940,256,940,860,340,256,940,260,936,260,952,248,988,336,1840,3328,340,860,336,860,344,856,340,264,936,856,340,860,340,856,344,244,3684,512,16,60,3612,396,3176,44,364,692,3468,84,3936,

my current sketch still has no respond

/*
  Example for different sending methods
  
  http://code.google.com/p/rc-switch/
  
  Need help? http://forum.ardumote.com
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {

  Serial.begin(9600);
    pinMode(13, OUTPUT);      
  // initialize the pushbutton pin as an input:
    pinMode(7, INPUT);     
  // Transmitter is connected to Arduino Pin #10  
  mySwitch.enableTransmit(10);

  // Optional set pulse length.
 mySwitch.setPulseLength(299);
  
// Optional set protocol (default is 1, will work for most outlets)
 mySwitch.setProtocol(1);
  
  // Optional set number of transmission repetitions.
//mySwitch.setRepeatTransmit(15);
  
}

void loop() {

  
 buttonState = digitalRead(7);

 if(buttonState == HIGH) {
   digitalWrite(13, LOW);
  mySwitch.send(1080226, 24);
  delay(1000); 
 }
 else {
  digitalWrite(13,HIGH);
 }
 
}

The value of 299 or 300 is the same to me.
Sometimes the timing changes for battery operated devices. It could be a 10% or 20% change with a low battery.

I don't know why your sketch is not working. I think it should work.
Is your wiring okay ?

Íve got 433mhz receiver/transmitter worked on the first try. 433mhz worked consistently
433mhz used different sketch though. 315mhz give me a lot of problem, I check the wiring over and over many times, there are only 3 pins on the 315mhz transmitter 5vdc , ground and Data . data go to pin 11 .. not sure if I need a resistor for the transmitter..?? only problem I could think of might be the antena or RCswitch sketch . Im ordering 2 different sets from 2 different suppliers , 8$ each from sparkfun.com and Seeedstudio.com. Hope it will work : :frowning:
Do you know any good example sketch for 315mhz transmitting data?

Have a great day Erdin

Those modules for 433MHz or 315MHz are the same, it should not be different.
As far as I know, the 433MHz is for Europe (and the 315MHz is illegal), and the 315MHz is for the US.
They are only set to different frequencies, but the modules are the same.

I filled in the right numbers (as you did) and it worked. I use 433MHz modules. Both receiving and transmitting was no problem.
I'm not very fond of the RCSwitch library, but it worked, so it's okay.

I am very enthousiastic about the VirtualWire library. It works very well with those cheap 433/315MHz modules. It uses it's own protocol, so it is used with an Arduino as transmitter, and with an Arduino as receiver. Example sketches are in the VirtualWire library included.
http://www.airspayce.com/mikem/arduino/
If you want to try it, the example sketches invert the signals for transmitter and receiver. Remove that line for the cheap modules from Ebay. Those modules use normal signals (0V = off, 5V = on).

Thanks Erdin,

got the 315mhz part # WRL10535 from sparkfun, wired up and play around with the RCswitch sketch
I finally get it to work using this line of code

 mySwitch.send("000100000111101110100010");
  delay(1000);

instead of this

//  mySwitch.send(108226, 24);
//  delay(1000);

My next step is trouble shooting the IR emitter (had the same problem- received but didn't transmit)

It should be possible to use the number, I don't know why that doesn't work. But at least it is working now.

I tried IR once with Arduino, but got confused with 38kHz/36kHz receivers and timing. You better start a new topic if you have questions about IR communication.

Thanks will do