Graeme Morgan

Contact

mail@{this domain}

github

linkedin

Remote control switches

I found some remote control switches for sale in B&Q for the reasonable price of £10 per pair. They came with a little remote control which can be set up to switch up to three sockets. Certainly a handy and competitively priced product, but I was more interested in controlling them from a computer, so that I can automate various tasks (such as having lights come on when I get home at night, and have my HTPC turn my TV on and off). The other option for doing that would be a product such as the Belkin Wemo switches, but at £30 per switch, they don't represent such good value.

back of socketinside socket

The rear of and inside the sockets. They seem to be exactly identical to Fabien's, except with a UK plug.

Thankfully, I found an article by Fabien Le Mentec on reverse engineering the wireless protocol of a very similar set of plugs. He found that the protocol uses on–off keying to send a payload of 25 bits to toggle a single socket on/off.

The switches are arranged in four banks (A, B, C, D) of three (1, 2, 3). The intended usage is that the remote control is set to a single bank, and can then control three switches (exactly why three when only two come in a pack is a minor mystery).

The protocol sends:

Fabien used an RFM22b radio module, and provided code for an Arduino. I ported this to run on a PIC18F2550 via USB. The circuit schematic is shown below. Mostly it's a minimal example of a PIC18F USB circuit, with a simple Zener diode 3.3v supply for the RFM22b and a few components to switch input/output voltages.

circuit schematic

Single-sided PCB artwork is below. The spacing for the RFM22b pins, however, is wrong—obviously that was a cunning plan to fit it into a smaller board, and not because I misread the datasheet.

circuit pcb

And the hardware, completed:

PCB finished

The firmware for the PIC18F2550 is based on Microchip's USB stack, and Fabien's castoplug software. I did find that a lot of the timing isn't so critical, which allowed some simplifications in the code. The code is available at GitHub.

As a user interface for the USB controller, I wrote a small server with Flask. This server also stores the current state of each remote switch (assuming they're not also being controlled by the provided transmitter, which would be confusing), so as to support a toggle command. The code for the server is also available on GitHub.