Having trouble determining custom protocol for RC Switch

Hello,

I'm trying to add a new protocol to RC Switch and i'm following this tutorial :

Im at the 15. instruction and i'm pretty much stuck because my data are very different to the data shown in the tutorial (might be a more complex protocol, idk...)

I captured the signal using the script provided in the tutorial and i got this :
1316,600,26892,2520,2500,2496,2528,2472,2544,2464,2544,2468,2552,2468,2536,2476,2524,4784,1308,1268,1304,1264,656,632,664,612,664,620,676,616,1312,1248,1312,612,672,1256,680,604,676,616,1300,624,664,624,664,612,680,1256,668,624,648,620,676,616,652,624,672,604,676,620,1300,628,660,1260,688,596,676,604,1320,1248,676,608,680,604,676,604,676,616,676,604,676,616,1304,620,672,1256,1312,616,672,1252,1308,624,664,608,676,612,668,1260,668,608,1316,620,668,1248,672,616,1316,592,26828,2520

If you copy-paste it into rc-switch raw data viewer you will have a graphical representation of the signal

My problem is that i don't understand how am i supposed to determine the protocol, the signal looks weird...
The sync bits seems to be { 1, 44 } with 605 pulse length but i can't determine what the hell are the next bits, in the graphic the second part after the long silence seems to be an other kind of sync signal but i'm super newbie and i don't understand how I should interpret it...

Can someone guide me please ? I have been trying to understand it for about 2 weeks now...

Thanks in advance,

That does not look like an RC-Switch protocol to me. The pulses should be constant width with variable spacing.

Take a look at typical examples in the "add new remote" Wiki: Add_New_Remote_Part_1 · sui77/rc-switch Wiki · GitHub

There are lots of remote protocols. All are proprietary, but many have been decoded. Search for your particular model of remote to see if someone has done that already.

Oh ok,

Too bad i didn't find anything for my somfy remote ^^

Is there anyway to send the same signal "manually" by hard coding it ? I have an emitter

Sure, just duplicate that pulse timing "by hand", using delayMicroseconds() and digitalWrite(). Note that digitalWrite() takes about 4 us on an AVR based Arduino, if I recall correctly.

I imagine i only have to do digitalWrite HIGH/LOW with good timing then ? I should even be able to just create a loop that read my comma separated value and digitalWrite/pause ?

EDIT : Thanks for your answer :slight_smile:

EDIT 2 : Do i need to do anything with "interupt pin" ? I'm pretty newbie and i saw some people using it

Yes. Use them to define an array. Don't forget that array indices start with 0. Google will probably find you some example code.

Do i need to do anything with "interupt pin"

No, can of worms for a beginner!

To be more precise i'm a newbie in electronic, not code. I have roughly 5 years of pro experience in JS/PYTHON/PHP but very few exp with low level (i did some Golang tho)

I think that you will discover that C/C++ has many clever gotchas in store for you, with operator precedence providing more than one of them.

It originally started as a (more or less) low level language for systems programming on small machines.

I will try to replicate the signal today, thanks for your help!

So i'm trying with this code below

static int timings[] = {656,616,660,624,672,604,680,616,672,608,668,620,1304,624,668,1248,1316,616,672,1252,1324,604,676,600,680,616,680,1244,672,608,1332,596,676,1248,684,608,1308,588,26864,2508,2516,2500,2520,2476,2548,2468,2544,2472,2528,2472,2552,2468,2552,4792,1296,1252,1308,1268,672,620,664,616,1308,1248,1324,1256,1308,624,668,1248,684,608,1324,608,676,608,660,624,668,612,688,1236,684,604,692,596,1312,1252,676,608,676,620,1320,604,680,1248,676,600,676,612,1320,1248,672,620,668,612,672,612,672,604,680,620,664,616,1312,608,676,1260,1324,600,684,1240,1332,608,684,588,680,612,668,1272,660,620,1312,604,676,1248,676,616,1312,588,26848,2508,2516,2488,2536,2480,2528,2464,2544,2472,2540,2472,2544,2460,2544,4784,1308,1260,1300,1268,664,620,664,628,1308,1252,1312,1256,1312,620,672,1252,660,612,1324,616,668,612,660,620,672,620,660,1264,660,616,668,616,1324,1248,676,600,684,608,1316,628,664,1244,672,620,664,612,1328,1244,660,628,668,616,664,616,676,612,668,616,668,620,1316,612,676,1240,1320,616,664,1252,1308,628,676,600,676,612,672,1244,676,616,1320,604,676,1252,672,612,1312,588,26864,2512,2516,2484,2528,2472,2548,2472,2548,2468,2544,2468,2540,2472,2544,4788,1304,1260,1316,1248,672,620,680,596,1316,1264,1300,1272,1312,608,680,1252,660,632,1308,612,680,608,664,624,672,616,652,1260,680,612,660,624,1304,1264,680,600,676,604,1336,608,668,1256,668,616,660,620,1312,1256,664,624,672,604,680,616,660,620,668,620,668,620,1312,616,656,1260,1324,612,668,1256,1316,612,668,624,672,608,672,1256,676,608,1308,616,672,1248,680,616,1312,592,26836,2508,2516,2492,2540,2464,2528,2468,2544,2480,2532,2472,2540,2468,2536,4800,1288,1280,1308,1256,664,620,660,612,1324,1252,1312,1256,1304,620,672,1248,676,616,1308,620,668,612,664,624,660,624,672,1252,664,620,688,588,1316,1256,672,608,680,616,1308,612,676,1252,668,624,668,616,1312,1260,656,620,676,604,684,600,680,616,660,612,676,620,1304,612,672,1256,1308,620,680,1232,1324,620,676,608,668,608,672,1256,688,600,1300,632,672,1252,676,604,1320,580,26832,2500,2532,2480,2540,2472,2536,2480,2536,2484,2544,2452,2548,2472,2544,4780,1316,1260,1304,1256,684,604,676,620,1304,1252,1316,1252,1316,620,664,1264,672,604,1324,616,676,592,684,616,664,612,676,1256,668,612,672,612,1312,1268,676,600,676};
static int previous_state = 0;

void setup() {
  Serial.begin(9600); 

}

void loop() {
  for (byte i = 0; i < sizeof(timings) - 1; i++) {
    if (previous_state == 0) {
      Serial.println("HIGH");
      digitalWrite(13, HIGH);
      previous_state = 1;
    } else {
      Serial.println("LOW");
      digitalWrite(13, LOW);
      previous_state = 0;      
    }
    delayMicroseconds(timings[i] - 5);
  }
}

And it doesn't seems to do anything ^^'

I wired :
5v => VCC
GND => GND
Pin 13 => DATA

It prints HIGH and LOW, so it is doing something.

If you mean it is not activating the radio, think about how long the Serial.print() statements take to execute, especially at the glacial rate of 9600 Baud, which transmits about one character per millisecond.

Should I remove the print ?

Am i doing the right thing without the print ?

I'm having trouble understanding if i should use a library or i can do it this way

Well even without the print it doesnt seem to work...

I'm using this transmiter btw Kit émetteur-récepteur 433MHZ - Articles retires | GO TRONIC

I modified my code a bit to remove some useless timings and it now looks like this :


static int timings[] = {1308,588,26864,2508,2516,2500,2520,2476,2548,2468,2544,2472,2528,2472,2552,2468,2552,4792,1296,1252,1308,1268,672,620,664,616,1308,1248,1324,1256,1308,624,668,1248,684,608,1324,608,676,608,660,624,668,612,688,1236,684,604,692,596,1312,1252,676,608,676,620,1320,604,680,1248,676,600,676,612,1320,1248,672,620,668,612,672,612,672,604,680,620,664,616,1312,608,676,1260,1324,600,684,1240,1332,608,684,588,680,612,668,1272,660,620,1312,604,676,1248,676,616,1312,588,26848,2508,2516,2488,2536,2480,2528,2464,2544,2472,2540,2472,2544,2460,2544,4784,1308,1260,1300,1268,664,620,664,628,1308,1252,1312,1256,1312,620,672,1252,660,612,1324,616,668,612,660,620,672,620,660,1264,660,616,668,616,1324,1248,676,600,684,608,1316,628,664,1244,672,620,664,612,1328,1244,660,628,668,616,664,616,676,612,668,616,668,620,1316,612,676,1240,1320,616,664,1252,1308,628,676,600,676,612,672,1244,676,616,1320,604,676,1252,672,612,1312,588,26864,2512,2516,2484,2528,2472,2548,2472,2548,2468,2544,2468,2540,2472,2544,4788,1304,1260,1316,1248,672,620,680,596,1316,1264,1300,1272,1312,608,680,1252,660,632,1308,612,680,608,664,624,672,616,652,1260,680,612,660,624,1304,1264,680,600,676,604,1336,608,668,1256,668,616,660,620,1312,1256,664,624,672,604,680,616,660,620,668,620,668,620,1312,616,656,1260,1324,612,668,1256,1316,612,668,624,672,608,672,1256,676,608,1308,616,672,1248,680,616,1312,592,26836,2508,2516,2492,2540,2464,2528,2468,2544,2480,2532,2472,2540,2468,2536,4800,1288,1280,1308,1256,664,620,660,612,1324,1252,1312,1256,1304,620,672,1248,676,616,1308,620,668,612,664,624,660,624,672,1252,664,620,688,588,1316,1256,672,608,680,616,1308,612,676,1252,668,624,668,616,1312,1260,656,620,676,604,684,600,680,616,660,612,676,620,1304,612,672,1256,1308,620,680,1232,1324,620,676,608,668,608,672,1256,688,600,1300,632,672,1252,676,604,1320,580,26832,2500,2532,2480,2540,2472,2536,2480,2536,2484,2544,2452,2548,2472,2544,4780,1316,1260,1304,1256,684,604,676,620,1304,1252,1316,1252,1316,620,664,1264,672,604,1324,616,676,592,684,616,664,612,676,1256,668,612,672,612,1312,1268,676,600,676};
static int previous_state = 1;

void setup() {
  // Serial.begin(9600); 

}

void loop() {
  for (byte i = 0; i < sizeof(timings) - 1; i++) {
    if (previous_state == 0) {
      digitalWrite(12, HIGH);
      previous_state = 1;
    } else {
      digitalWrite(12, LOW);
      previous_state = 0;      
    }
    delayMicroseconds(timings[i] - 4);
  }
}

If i paste my timings on rc-switch raw data viewer this should be the correct timings to replicate my remote control signal.

Have you used the RC-Switch library capture function to determine if your program and transmitter is accurately imitating the original remote?

I would need 2 arduino no ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.