Go Down

Topic: Lidl SilverCrest Remote Electrical Sockets 91210 RCS AAA3680 A IP20 (Read 6228 times) previous topic - next topic

Collie147

Spent a week or so trying to control the Lidl Remote Sockets I bought with pre-written code found on the net but to no avail.  Eventually worked it out for myself.  If anybody else is wondering how to do it I've posted an example below.  A fair chunk of it has been taken from other examples, so I can't take complete credit for it.  Either way, an Uno, an Ethernet Shield and a set of 433Mhz Transmitter/Receivers are definitely cheaper than http://www.steckerchecker.com/ which SilverCrest recommend.  Instructions on setup contained in commented code.  Hopefully somebody will find it of use!


Code: [Select]
/*
SilverCrest 91210 RCS AAA3680 - A IP20
Below code will transmit on and off signals to SilverCrest 91210 Remote Electrical Sockets
I've taken some bits of code from various websites (mostly from rayshobby.net and randysimons.com)
Recorded the wave signatures (instructions taken from those websites)
Cut the end off an old sent of headphones and plugged into Line-In on PC.  Recorded with Audacity on 48000Hz Sampling Freq.
Receiver set up to +5 and GND on Arduino and Rec pin sent to 39K Resistor (I only had a 47K resistor but worked ok). 
39 K resistor sent to Headphone (left or right) and 10K resistor.  10K resistor sent to Gnd Arduino and Gnd from Headphone.
Recorded wave signature defined as Long (1) and Short (0), the shortest worked out at roughly 18 samples at 48000Hz 18/48000=375ns (found 373 worked better). 
Each Long signal was about 3 times the length of the Short and the delay between sequences was rougly 6 times the short length.
Sequence had two distinct sub sequences -
1. 4x with an another Short and a Short delay
2. 4x with and another Long (extra long) and an extra long delay
Below setup as two Button Pins (each button pin 1 is sent to arduino pins 5 and 8 and pin 4 sent to ground)
Button 1 sends the signal
Button 2 cycles through the functions (A, B, C, D and Master)
433Mhz Transmitter set up on pin 3
LED on pin 13 flashes while sending signal
*/

#define BUTTON_PIN1  5
#define BUTTON_PIN2  8
#define RF_DATA_PIN 3

#define SHORT_DELAY 373
#define LONG_DELAY  (3*SHORT_DELAY)
#define TOTAL_DELAY (SHORT_DELAY + LONG_DELAY)
#define SYNC_DELAY  (6*SHORT_DELAY)
#define EXTRALONG_DELAY (3*LONG_DELAY)
unsigned long signal;
unsigned long signalA1 = 0b110101100100001101110000;
unsigned long signalA0 = 0b110111001010000100010000;
unsigned long signalB1 = 0b110101100100001101110100;
unsigned long signalB0 = 0b110111001010000100010100;
unsigned long signalC1 = 0b110101100100001101111100;
unsigned long signalC0 = 0b110111001010000100011100;
unsigned long signalD1 = 0b110111001010000100010010;
unsigned long signalD0 = 0b110101100100001101110010;
unsigned long signalM1 = 0b110111001010000100011010;
unsigned long signalM0 = 0b110101100100001101111010;
boolean onOff;
int Plug;


void setup() {               
  pinMode(RF_DATA_PIN, OUTPUT);
  pinMode(BUTTON_PIN1, INPUT_PULLUP);
  pinMode(BUTTON_PIN2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Ready");
  onOff=0;
 
}

void loop() {
  if (digitalRead(BUTTON_PIN2) == LOW) {
    Plug = Plug + 1;
    if (Plug == 5){
      Plug = 0;
    }
    Serial.println(Plug);
  }
 
  if (digitalRead(BUTTON_PIN1) == LOW) {
   
    onOff = !onOff;
   
    ActivatePlug();
  }
}
void ActivatePlug() {
 
 
  unsigned long signal0 = 0;
  unsigned long signal1 = 1;
  if (Plug == 0){
    if (onOff == 0) {
      signal = signalA1;
     
    }
    else if (onOff == 1) {
      signal = signalA0;
     
    }
    Serial.print("A ");
    Serial.println(onOff);
  }
  if (Plug == 4){
    if (onOff == 0) {
      signal = signalM1;
    }
    else if (onOff == 1) {
      signal = signalM0;
     
    }
    Serial.print("Master ");
    Serial.println(onOff);
  }
  if (Plug == 1){
    if (onOff == 0) {
      signal = signalB1;
    }
    else if (onOff == 1) {
      signal = signalB0;
     
    }
    Serial.print("B ");
    Serial.println(onOff);
  }
  if (Plug == 2){
    if (onOff == 0) {
      signal = signalC1;
     
    }
    else if (onOff == 1) {
      signal = signalC0;
     
    }
    Serial.print("C ");
    Serial.println(onOff);
  }
  if (Plug == 3){
    if (onOff == 0) {
      signal = signalD1;
     
    }
    else if (onOff == 1) {
      signal = signalD0;
     
    }
    Serial.print("D ");
    Serial.println(onOff);
  }
  Serial.print(Plug);
  Serial.print(" ");
  Serial.println(onOff);
  Serial.println(signal, BIN);
// for (unsigned char j=0; j<5; j++) { //repeat the whole thing 5 times
    for (unsigned char i=0; i<3; i++) { // repeat 1st signal sequence 3 times
      for (unsigned char k=0; k<24; k++) { //as 24 long and short signals, this loop sends each one and if it is long, it takes it away from total delay so that there is a short between it and the next signal and viceversa
        unsigned long d = ((bitRead(signal, 23-k)) == 1 ? LONG_DELAY : SHORT_DELAY);
        digitalWrite(13, HIGH);
        digitalWrite(RF_DATA_PIN, HIGH);
        delayMicroseconds(d);
        digitalWrite(RF_DATA_PIN, LOW);
        digitalWrite(13, LOW);   
        delayMicroseconds(TOTAL_DELAY - d);
        }
      //send the short 0 signal in the 1st sequence and the pause between repeats
      unsigned long d = (SHORT_DELAY);
      digitalWrite(13, HIGH);
      digitalWrite(RF_DATA_PIN, HIGH);
      delayMicroseconds(d);
      digitalWrite(RF_DATA_PIN, LOW);
      digitalWrite(13, LOW);   
      delayMicroseconds(SYNC_DELAY); 
   
   
    }
    for (unsigned char i=0; i<3; i++) { // repeat 2nd signal sequence 3 times
      for (unsigned char k=0; k<24; k++) {
        unsigned long d = ((bitRead(signal, 23-k)) == 1 ? LONG_DELAY : SHORT_DELAY);
        digitalWrite(13, HIGH);
        digitalWrite(RF_DATA_PIN, HIGH);
        delayMicroseconds(d);
        digitalWrite(RF_DATA_PIN, LOW);
        digitalWrite(13, LOW);   
        delayMicroseconds(TOTAL_DELAY - d);
        }
      // send the extra long 1 signal in the 2nd sequence and long pause between repeats
      unsigned long d = EXTRALONG_DELAY;
      digitalWrite(13, HIGH);
      digitalWrite(RF_DATA_PIN, HIGH);
      delayMicroseconds(EXTRALONG_DELAY);
      digitalWrite(RF_DATA_PIN, LOW);
      digitalWrite(13, LOW);   
      delayMicroseconds(EXTRALONG_DELAY);
   
      delayMicroseconds(SYNC_DELAY);
      }
// }
onOff != onOff;
}


kenmc

Hi have the same set of switches, but am having zero success with them, either with your code, or using the RFSwitch library.

The RF switch can deliver me the codes from the remote,at least in theory, as when I then try to send them to the switch from the arduino, i have nothing happening. Plugging the values into your code has no effect either. The other thing is that any given button appears to cycle through about 4 or 5 different codes, one per press.

What's interesting is that the RCSwitch library seems to think that the relationship between high and low changes for "1s" and "0s" whereas yours seems to maintain a constant ratio.

I wonder if it's possible that even though they have the same model number they are different internally?

Have you tried listening for your remotecontrol using the RC Switch Recieve Demo (simple or advanced) at all? If so, does it give you the same values as you determined with audacity?

I attempted to use audacity but on a laptop, there's no line-in, only mic, so the background noise makes the signal appear too noisy really.

Cheers
Kenmc

kenmc

Just for fun, I connected the RF433 receiver up to my Raspberry Pi and got it to sniff the codes sent by the RC unit; same behaviour, a repeating cycle of codes per button.

So fecking annoying, as my Energenie set just worked out of the box, and I've had an ATTiny powered room heat sensor-switch in my daughters bedroom for a month or so. I just wanted to get the xmas tree lights working from the web :(
Grrr

Poopi

Here are the results from lay with my set of Lidl outlets:
Code: [Select]

/*
SilverCrest 91210 RCS AAA3680 - A IP20
Below code will transmit on and off signals to SilverCrest 91210 Remote Electrical Sockets

Based on code from http://forum.arduino.cc/index.php?topic=202556.msg1492685#msg1492685
Modifed by Poopi, Tested on Teensy 2.0++

Sequence had two distinct sub sequences -
1. 4x with short sync and short '1's
2. 4x with long sync and longer '1's

Codes were cycled - 4 different codes per each plug but you can choose any of these codes - I used all to mimic original RCU
Seems that 4 last bits are a PLUG identifier and first 4 bits are a remote identifier

Remaining 16 bits seems to be common for all plugs ( Plug C have reverted On/Off sequences sic! )
All codes captured from original RCU usin logic analyzer


Below setup as two Button Pins (each button pin 1 is sent to arduino pins 5 and 8 and pin 4 sent to ground)
Button 1 sends the signal
Button 2 cycles through the functions (A, B, C, D and Master)
433Mhz Transmitter set up on pins 27 and 24
Pin 27 - transmit
Pin 24 - VCC of the transmitter

LED on pin 6 flashes while sending signal
*/

#define DEBUG

/*Setup*/
#define BUTTON_PIN1    26
#define BUTTON_PIN2    25

#define RF_DATA_PIN    27
#define RF_ENABLE_PIN  24
#define BLINK_LED_PIN  6

#define MAX_CODE_CYCLES 4

#define SHORT_DELAY       380
#define NORMAL_DELAY      500
#define SIGNAL_DELAY     1500

#define SYNC_DELAY       2650
#define EXTRASHORT_DELAY 3000
#define EXTRA_DELAY     10000

enum {
  PLUG_A = 0,
  PLUG_B,
  PLUG_C,
  PLUG_D,
  PLUG_MASTER,
  PLUG_LAST
};

unsigned long signals[PLUG_LAST][2][MAX_CODE_CYCLES] = {
  { /*A*/
    {0b010000110001000000110000, 0b010001011000011101000000, 0b010000010111111001110000, 0b010010110101111110110000},
    {0b010011010100101000100000, 0b010001100010110000010000, 0b010000001110110110010000, 0b010010101111000110100000}
  }, 
  { /*B*/
    {0b010000110001000000110100, 0b010001011000011101000100, 0b010000010111111001110100, 0b010010110101111110110100},
    {0b010011010100101000100100, 0b010001100010110000010100, 0b010000001110110110010100, 0b010010101111000110100100}
  }, 
  { /*C*/
    {0b010011010100101000101100, 0b010001100010110000011100, 0b010000001110110110011100, 0b010010101111000110101100},
    {0b010000110001000000111100, 0b010001011000011101001100, 0b010000010111111001111100, 0b010010110101111110111100}
  }, 
  { /*D*/
    {0b010000110001000000110010, 0b010001011000011101000010, 0b010000010111111001110010, 0b010010110101111110110010},
    {0b010011010100101000100010, 0b010001100010110000010010, 0b010000001110110110010010, 0b010010101111000110100010}
  }, 
  { /*MASTER*/
    {0b010000110001000000111010, 0b010001011000011101001010, 0b010000010111111001111010, 0b010010110101111110111010},
    {0b010011010100101000101010, 0b010001100010110000011010, 0b010000001110110110011010, 0b010010101111000110101010}
  }, 
};

boolean       onOff;
unsigned char plug;
unsigned char swap;

void setup() {               
  pinMode(BLINK_LED_PIN, OUTPUT);
  pinMode(RF_DATA_PIN, OUTPUT);
  pinMode(RF_ENABLE_PIN, OUTPUT);
  digitalWrite(RF_ENABLE_PIN,LOW);
  pinMode(BUTTON_PIN1, INPUT_PULLUP);
  pinMode(BUTTON_PIN2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Ready");
  onOff = 1;
  swap  = 0;
  plug  = PLUG_C;
}

void loop() {
  if (digitalRead(BUTTON_PIN2) == LOW) {
    plug++;
    plug%=PLUG_LAST;
    Serial.print("PLUG_");
    Serial.print(plug == PLUG_MASTER?'M':(char)('A'+plug));
    Serial.println(" activated");
    delay(1000);
  }
 
  if (digitalRead(BUTTON_PIN1) == LOW) {
    digitalWrite(BLINK_LED_PIN,HIGH);
    ActivatePlug(plug,onOff);
    digitalWrite(BLINK_LED_PIN,LOW);

    onOff = !onOff;
    delay(500);
  }
}


void sendSync(){
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(SHORT_DELAY);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(SYNC_DELAY - SHORT_DELAY); 
}

void sendValue(boolean value, unsigned int base_delay){
  unsigned long d = value? SIGNAL_DELAY - base_delay : base_delay;
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(d);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(SIGNAL_DELAY - d);
}

void longSync(){
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(EXTRASHORT_DELAY);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(EXTRA_DELAY - EXTRASHORT_DELAY); 
}

void ActivatePlug(unsigned char PlugNo, boolean On) {
  if( PlugNo < PLUG_LAST ) {

    digitalWrite(RF_DATA_PIN,LOW);
    digitalWrite(RF_ENABLE_PIN,HIGH);
    delayMicroseconds(1000);

    unsigned long signal = signals[PlugNo][On][swap];
   
    swap++;
    swap%=MAX_CODE_CYCLES;
   
#ifdef DEBUG
    Serial.print("PLUG_");
    Serial.print(plug == PLUG_MASTER?'M':(char)('A'+plug));
    Serial.print(" ");
    Serial.println(onOff?"On":"Off");
    Serial.println(signal, BIN);
#endif

    for (unsigned char i=0; i<4; i++) { // repeat 1st signal sequence 4 times
      sendSync();
      for (unsigned char k=0; k<24; k++) { //as 24 long and short signals, this loop sends each one and if it is long, it takes it away from total delay so that there is a short between it and the next signal and viceversa
        sendValue(bitRead(signal, 23-k),SHORT_DELAY);
      }   
    }
    for (unsigned char i=0; i<4; i++) { // repeat 2nd signal sequence 4 times with NORMAL DELAY
      longSync(); 
      for (unsigned char k=0; k<24; k++) {
        sendValue(bitRead(signal, 23-k),NORMAL_DELAY);
      }
    }
    digitalWrite(RF_ENABLE_PIN,LOW);
  }
}

kenmc

Interesting, that you get 4 codes per button also. Although for some reason I was not always able to see the codes on every button press, like there was some small timing issues when receiving the data.

will give that a blast tonight hopefully. Did your plugs work ok with Collie147s original code?

Just out of curiosity, where did ye all buy your plugs? Mine were bought in Ireland, but I highly doubt that that would make any much of a difference

Poopi

Quote

Interesting, that you get 4 codes per button also. Although for some reason I was not always able to see the codes on every button press, like there was some small timing issues when receiving the data.

Maybe you have problem with your audio card capture methods. I used cheap usb logic analyzer.
Quote

will give that a blast tonight hopefully. Did your plugs work ok with Collie147s original code?

Nope. Different codes. Looks like they have different identifiers ( i.e. see first 4 bits ). I would need more transmitters to compare.
Quote

Just out of curiosity, where did ye all buy your plugs?

Poland. I think that as long as yours have a "www.stackerchecker.de" logo on the box they should be the same.

kenmc

I didn't use audio analyzer, rather rc-switch library (github somewhere, can't find it now). This works 100% reliably with my energenie remotes. Box is in the bin, so dunno about the logo on the box :(
Will see how i go.
K

kenmc

Wheeeee signs of life!!!! starting to control the silvercrest controls with this code, when I insert the correct rf codes for my RCU.
What's even MORE interesting though is that this code ALSO drives my Energenie plugs with the correct codes from THAT RCU.
Must have been a timing thing or something, which might explain why the protocol was coming through as a "3" for the silvercrests vs a 1 for the energenies.
Thanks a million!

pepiarduin

Please give me source code, to control these sockets in all functions,
Thank you very much.
Pepi

witq

Hi, created an account just to post this. I recorded the codes from my remote with the rc-switch library's advanced receive example. I used them with Poopi's code (prefixed with 0b) and they work with my switches. Maybe someone else can use them:

Code: [Select]

A on codes:

100000011101011001110000
100001110011001101000000
100000000100111100110000
100011000110000010110000

A off codes:

100011100000110010010000
100010100101101010100000
100010001010110100010000
100010011001000100100000

B on codes:

100010001010110100010100
100010011001000100100100
100010100101101010100100
100011100000110010010100

B off codes:

100011000110000010110100
100000011101011001110100
100001110011001101000100
100000000100111100110100

C on codes:

100000011101011001111100
100001110011001101001100
100000000100111100111100
100011000110000010111100

C off codes:

100010100101101010101100
100011100000110010011100
100010001010110100011100
100010011001000100101100

D on codes:

100010001010110100010010
100011100000110010010010
100010100101101010100010
100010011001000100100010

D off codes:

100011000110000010110010
100000000100111100110010
100001110011001101000010
100000011101011001110010

MASTER on codes:

100010100101101010101010
100010011001000100101010
100010001010110100011010
100011100000110010011010

MASTER off codes:

100001110011001101001010
100000011101011001111010
100011000110000010111010
100000000100111100111010

betamaster50

Hi !

I got also the SilverCrest from Lidl (Holland). It works for me as well.

I get the codes first using the RCSwitch Library with the example code "receive advanced". I test all  4 set of codes for each button. The reception is a bit unstable and I find it works better with the arduino conected to a 9V battery instead of the noisy USB port.

Once I have all 4 codes for each button I paste them into the code from Poopi. And works!

here my codes:
Code: [Select]
A on codes:
101100010110110110101100
101110101110010001101100
101111000001000101011100
101101000101010100011100

B off codes:
101101010010011101111100
101111100011110000101100
101111110111001110001100
101110111000101110111100

B on codes:
101101110100001000110101
101101101010100111100101
101110011101111000000101
101100100000100011110101

B off codes:
101111011001101011010101
101100111011111101000101
101110001100011010010101
101100001111000011000101

C on codes:
101101010010011101111110
101111100011110000101110
101111110111001110001110
101110111000101110111110

C off codes:
101110101110010001101110
101101000101010100011110
101111000001000101011110
101100010110110110101110

D on codes:
101111011001101011010111
101100111011111101000111
101100001111000011000111
101110001100011010010111

D off codes:
101101110100001000110111
101100100000100011110111
101101101010100111100111
101110011101111000000111

MASTER on codes:
101111100011110000100010
101110111000101110110010
101101010010011101110010
101111110111001110000010

MASTER off codes:
101111000001000101010010
101101000101010100010010
101110101110010001100010
101100010110110110100010

betamaster50


Here is a slightly changed version of the code for testing all switches in series.


Code: [Select]
/*
SilverCrest 91210 RCS AAA3680 - A IP20
Below code will transmit on and off signals to SilverCrest 91210 Remote Electrical Sockets

Based on code from http://forum.arduino.cc/index.php?topic=202556.msg1492685#msg1492685
Modifed by Poopi, Tested on Teensy 2.0++

Sequence had two distinct sub sequences -
1. 4x with short sync and short '1's
2. 4x with long sync and longer '1's

Codes were cycled - 4 different codes per each plug but you can choose any of these codes - I used all to mimic original RCU
Seems that 4 last bits are a PLUG identifier and first 4 bits are a remote identifier

Remaining 16 bits seems to be common for all plugs ( Plug C have reverted On/Off sequences sic! )
All codes captured from original RCU usin logic analyzer


Below setup as two Button Pins (each button pin 1 is sent to arduino pins 5 and 8 and pin 4 sent to ground)
Button 1 sends the signal
Button 2 cycles through the functions (A, B, C, D and Master)
433Mhz Transmitter set up on pins 27 and 24
Pin 27 - transmit
Pin 24 - VCC of the transmitter

LED on pin 6 flashes while sending signal
*/

#define DEBUG

/*Setup*/
#define BUTTON_PIN1    26
#define BUTTON_PIN2    25

#define RF_DATA_PIN    10
#define RF_ENABLE_PIN  24
#define BLINK_LED_PIN  6

#define MAX_CODE_CYCLES 4

#define SHORT_DELAY       380
#define NORMAL_DELAY      500
#define SIGNAL_DELAY     1500

#define SYNC_DELAY       2650
#define EXTRASHORT_DELAY 3000
#define EXTRA_DELAY     10000

enum {
  PLUG_A = 0,
  PLUG_B,
  PLUG_C,
  PLUG_D,
  PLUG_MASTER,
  PLUG_LAST
};

unsigned long signals[PLUG_LAST][2][MAX_CODE_CYCLES] = {
  { /*A*/
    {0b101111000001000101011100, 0b101100010110110110101100, 0b101110101110010001101100, 0b101101000101010100011100},
    {0b101101010010011101111100, 0b101111100011110000101100, 0b101111110111001110001100, 0b101110111000101110111100}
  }, 
  { /*B*/
    {0b101101110100001000110101, 0b101101101010100111100101, 0b101110011101111000000101, 0b101100100000100011110101},
    {0b101111011001101011010101, 0b101100111011111101000101, 0b101110001100011010010101, 0b101100001111000011000101}
  }, 
  { /*C*/
    {0b101101010010011101111110, 0b101111100011110000101110, 0b101111110111001110001110, 0b101110111000101110111110},
    {0b101110101110010001101110, 0b101101000101010100011110, 0b101111000001000101011110, 0b101100010110110110101110}
  }, 
  { /*D*/
    {0b101111011001101011010111, 0b101100111011111101000111, 0b101100001111000011000111, 0b101110001100011010010111},
    {0b101101110100001000110111, 0b101100100000100011110111, 0b101101101010100111100111, 0b101110011101111000000111}
  }, 
  { /*MASTER*/
    {0b101111100011110000100010, 0b101110111000101110110010, 0b101101010010011101110010, 0b101111110111001110000010},
    {0b101111000001000101010010, 0b101101000101010100010010, 0b101110101110010001100010, 0b101100010110110110100010}
  }, 
};

boolean       onOff;
unsigned char plug;
unsigned char swap;

void setup() {

  pinMode(RF_DATA_PIN, OUTPUT);
  pinMode(RF_ENABLE_PIN, OUTPUT);
  digitalWrite(RF_ENABLE_PIN,LOW);

  pinMode(BUTTON_PIN1, INPUT_PULLUP);
  pinMode(BUTTON_PIN2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Ready");
  swap  = 0;
  plug  = PLUG_C;
}

void loop() {

    plug++;
    plug%=PLUG_LAST;
    for (byte a=0; a<=1; a++) {
      onOff = a;
      digitalWrite(BLINK_LED_PIN,HIGH);
      ActivatePlug(plug,onOff);
      digitalWrite(BLINK_LED_PIN,LOW);
      #ifdef DEBUG
      Serial.print("PLUG_");
      Serial.print(plug == PLUG_MASTER?'M':(char)('A'+plug));
      Serial.print(" ");
      Serial.println(onOff?"Off":"On");
      //Serial.println(signal, BIN);
      #endif
      delay(1000);
    }
    Serial.println("===========");
    delay(500);
}


void sendSync(){
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(SHORT_DELAY);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(SYNC_DELAY - SHORT_DELAY); 
}

void sendValue(boolean value, unsigned int base_delay){
  unsigned long d = value? SIGNAL_DELAY - base_delay : base_delay;
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(d);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(SIGNAL_DELAY - d);
}

void longSync(){
  digitalWrite(RF_DATA_PIN, HIGH);
  delayMicroseconds(EXTRASHORT_DELAY);
  digitalWrite(RF_DATA_PIN, LOW);
  delayMicroseconds(EXTRA_DELAY - EXTRASHORT_DELAY); 
}

void ActivatePlug(unsigned char PlugNo, boolean On) {
  if( PlugNo < PLUG_LAST ) {

    digitalWrite(RF_DATA_PIN,LOW);
    digitalWrite(RF_ENABLE_PIN,HIGH);
    delayMicroseconds(1000);

    unsigned long signal = signals[PlugNo][On][swap];
   
    swap++;
    swap%=MAX_CODE_CYCLES;

    for (unsigned char i=0; i<4; i++) { // repeat 1st signal sequence 4 times
      sendSync();
      for (unsigned char k=0; k<24; k++) { //as 24 long and short signals, this loop sends each one and if it is long, it takes it away from total delay so that there is a short between it and the next signal and viceversa
        sendValue(bitRead(signal, 23-k),SHORT_DELAY);
      }   
    }
    for (unsigned char i=0; i<4; i++) { // repeat 2nd signal sequence 4 times with NORMAL DELAY
      longSync(); 
      for (unsigned char k=0; k<24; k++) {
        sendValue(bitRead(signal, 23-k),NORMAL_DELAY);
      }
    }
    digitalWrite(RF_ENABLE_PIN,LOW);
  }
}



dmarkey

Just to add - I have had success with this sketch with similar sockets under the "Delta" brand. http://www.adverts.ie/other-electronics/remote-controlled-wall-sockets-4/6137830

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy