Home > Electronics > Controlling Opal branded wireless electrical socket

Controlling Opal branded wireless electrical socket

The weather is getting so cold currently that the cars heater needs to be turned on for more than an hour. Since I don’t want to wake up any earlier than possible, I went to get a socket that could be remotely timed. I found Belking Wemo switch, but unfortunately it proved to be an utter waste of money. The configuration software is extremely poor and the device refused to connect to my homes access point no matter what I tried.

I had previously bought cheap sockets with a remote. These were branded “Opal” and cost next to nothing in a pack of two sockets and one remote and they seem to work well enough. Only minus was the strange 12v battery the remote uses.

_DSC3951

Socket, front

I popped open the remote to check how it worked. The layout seems to be easy enough. The +12v from the battery is dropped to +5v for the microcontrolled under the epoxy blob. The controller scans the keypad and generates the code which is fed to RF part. The RF transmitter requires the +12v straight from the battery and operates in 433 MHz frequency. I cut the signal trace from the controller to the transmitter and soldered wires to the test pad in the signal trace and the ground. Using the oscilloscope I checked what the controller is outputting when the keys are pressed.

Beginning of the signal

Beginning of the signal

 

 

 

 

 

 

 

 

 

 

The signal seems to consist of preamble, 5 bytes of data and stop sign. The preamble is following:

480µs high
480µs low
480µs high
480µs low
3.4ms high
3.4ms low

_DSC3950

Socket, back

After that, 40 bytes of data follows. Each byte starts with 440µs high, followed by 440µs low for 0-bit or 1.28ms low for 1-bit. The stop sign is single 440µs of high, before returning to low level. The remote always sends the same sequence five times for each key press.

For one of the keys, it gives the following data:

01011111
10000110
10100000
01111001
01001011

On my remote, first four bytes are always the same and only the last byte changes. To turn the socket of, last byte is inverted, so in this case to turn the same socket of, last byte would be: 10110100.

Connections to the remote

Connections to the remote

The following Arduino code listens the serial port for “1” or “0” character and turns one of the sockets on and off respectively:

#define CODE_SIZE 40
#define OUT_PIN 3

byte code_on[] = { 0, 1, 0, 1, 1, 1, 1, 1, \
                1, 0, 0, 0, 0, 1, 1, 0, \
                1, 0, 1, 0, 0, 0, 0, 0, \
                0, 1, 1, 1, 1, 0, 0, 1, \
                0, 1, 0, 0, 1, 0, 1, 1 };


byte code_off[] = { 0, 1, 0, 1, 1, 1, 1, 1, \
                1, 0, 0, 0, 0, 1, 1, 0, \
                1, 0, 1, 0, 0, 0, 0, 0, \
                0, 1, 1, 1, 1, 0, 0, 1, \
                1, 0, 1, 1, 0, 1, 0, 0 };
                
void write_rc(byte state)
{
  digitalWrite(OUT_PIN, HIGH);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, LOW);
  if(state)
    delayMicroseconds(1320);
  else
    delayMicroseconds(440);    
}

void send_preamble()
{
  digitalWrite(OUT_PIN, HIGH);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, LOW);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, HIGH);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, LOW);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, HIGH);
  delayMicroseconds(3440);
  digitalWrite(OUT_PIN, LOW);
  delayMicroseconds(3440);
}

void send_stop()
{
  digitalWrite(OUT_PIN, HIGH);
  delayMicroseconds(440);
  digitalWrite(OUT_PIN, LOW);
}

void send_code(int on)
{
  int i;
  
  send_preamble();
  
  for (i = 0; i < CODE_SIZE; i++) {
    if(on)
      write_rc(code_on[i]);
    else
      write_rc(code_off[i]);
  }
  
  send_stop();
}

void setup()
{
  pinMode(OUT_PIN, OUTPUT); 
  Serial.begin(19200);
}

void loop()
{
  int i;
  byte state;
  
  if(Serial.available() > 0) {
    state = Serial.read();
    if(state == '1') {
      for(i = 0; i < 6; i++) {
        send_code(1);
        delay(20);
      }
    }
    if(state == '0') {
      for(i = 0; i < 6; i++) {
        send_code(0);
        delay(20);
      }
    }
  }
}
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: