How to add USB to radio controlled sockets
Radio controlled sockets are a great way to save power in your home. Devices consuming more power on standby than the sockets do can easily be switched off with a remote. For example my desk lamp from a swedish furniture store consumes 10x more power (in the off state) than a radio controlled socket.
Even if the sockets consume more power in standby than the attached electronic device, they offer the luxury of turning stuff off and on without even moving. In short: They are really handy.
However, if you’ve installed the sockets, one sentence will often reoccur: Where the f*** is my remote?
The goal of this post is to show you a way of adding USB support to remote controlled sockets. This opens up a whole new world to remote controlled sockets. Plug this kind of remote into a computer and you can do amazing things.
This first post will show you how to do the hardware modifications to the remote control. As remote controls are usually different on the inside depending on the manufacturer, the results presented here cannot be applied to all remote controls. But if you buy the same model that I have used you should have no problems.
- Remote controlled sockets set
- AT Mega 8
- Nokia CA-42 Data cable
The Nokia data cable contains a pl2302 USB-to-serial chip from prolific. The data cable is a very cheap way to get to PCBs having all necessary parts for doing serial to USB translation. You could, of course, use any other flavor of serial connection.
The remote control uses the SC5262 chip (datasheet). This chip is capable of sending address and data bits over the air by pulling the /TE pin low. The D0 pin is used for the On/Off information sent to the socket. D1-D3 are unused. A0-A3 are used for channel selection and A4-A7 are used for device selection. The addresses are not binary encoded. One pin of the channel bits is pulled to GND by the channel selector switch on the back and one pin of the device bits is pulled to GND by pressing the appropriate button on the remote. This button press also sets the D0 pin appropriately and pulls /TE low which starts the transmission.
- Prepare the microcontroller with a serial boot loader (Refer to my post on that topic)
- Connect the microcontroller to the remote control board (Connections to the SC5262 chip are in the photo gallery)
- Flash the software into the microcontroller
You see my quick and dirty approach on the images below.
Now let’s take a closer look at the second point, connecting the microcontroller to the remote control board.
The first step is to remove the SMD components seen in the first picture under the yellow cables. The pins D0 and /TE should now be unconnected (and will be later connected to our microcontroller). Also the channel select switch should be unsoldered. This allows you to have software control over the channel.
The second step is to mount the microcontroller to the back side of the board. The “dead bug” technique worked well for me but feel free to use any other method you like. The connections from the AVR to the SC5262 are found in the picture gallery above.
The original remote control is powered by 12V. I found that using 5V from USB as a power supply works as well. The range of the remote control is a bit lower but still sufficient. It’s up to you: Use 5V and no battery for being maintenance free or use the battery and get a better range. The supply voltage of the microcontroller has to match with your USB -to-serial adaptor. In case of the Nokia cable, the AVR has to be powered with 3.3V. Oh, and not to forget: Connecting the Grounds of AVR, Remote control and USB-to-serial adaptor together.
Now, if you have connected the serial wires to the AVR, you are ready to flash the software. If you have not yet done it, clone my repository: hg clone https://bitbucket.org/befi/remote-controlled-socket
You find the software for the microcontroller in the subdirectory uc/remote_controlled_socket. The programming of the software is done the same as described in in my post about the serial boot loader. Just type make, reset the microcontroller and within two seconds type make program. Congrats, you now have your USB enabled remote control!
Ok, it’s time to test our remote control. Plug the module into your computer. First, set the baud rate of the serial interface:
stty -F /dev/ttyUSB0 19200
The remote control is now ready to receive your commands. The characters ’1′ – ’4′ are used to switch a socket on. Characters ‘A’ – ‘D’ are used to switch it off:
echo 1 > /dev/ttyUSB0
echo A > /dev/ttyUSB0
The following video shows the remote control in action: