Wednesday, 12 February 2014

DIY Phone-Controlled Mains Sockets


Next Steps
  • Get it working with Wiring-Pi so that RC Switch can operate from the Raspberry Pi directly and free up the Arduino.
  • Adapt the android code to work with SSH/Pi/etc (Currently using command line via ConnectBot)

Version 2
After the original was broken (physical damage from a fall), I re-implemented with the RC-Switch Arduino library. (http://code.google.com/p/rc-switch/).

Version 1
The RF plugs I used were the Maplin Gadget range. The controller is powered by a 12V battery and allows 4 sockets to be controlled across 4 channels (so theoretically up to 16 different sockets could be used)

Each button on the controller has 3 connection points - let's call them left, top and right. all three need to be connected in order for the button press to register.

In the "On" column, the left connections on all the buttons are connected to the same line.

In the "Off" column, the left connections are connected up in the same way.

The top point on all 8 buttons is connected to the same point - this is the one that controls the little LED at the top.

The right hand side for each row is connected - ie, the right point of 1-On is the same as the right point of 1-Off.

So, the transistors need to go as follows:

1: Between the left point of one of the on buttons, to the top point of the same button.

2: Between the left point of one of the off buttons, to the top point of the same button.

3: Between the top point of one of the buttons, to the right side of either button 1 (on or off)

4: Between the top point of one of the buttons, to the right side of either button 2 (on or off)

5: Between the top point of one of the buttons, to the right side of either button 3 (on or off)

6: Between the top point of one of the buttons, to the right side of either button 4 (on or off)












The channel selection switch has 6 points. The two middle ones are grounds, and the 4 others represent each channel. Use a transistor to connect each channel to ground

Now you have 10 transisitors: 1 & 2 are On and Off, 3-6 are the switch selection, and 7-10 are the channel selection.

Connect these transistors to the microcontroller & write your software.

To operate the remote, 3 transistors need to be active.

I found the easiest way to do this was to firstly choose the channel and make that transistor active. Then choose either on or off and make the appropriate transistor active. Then finally, pick the switch to activate. I found that it's best to make the switch active for a second and then turn it off. Having the transistor remain active and "hold down the button" didn't work. If necessary, have the switch transistor pulsed a couple of times.

Remember to make sure that the transistors are deactivated after you've sent your signal.

Originally the code was written for Arduino, but has now been moved to an ATTiny2313.

Due to the number of microcontroller outputs required, a 74HC595 shift register was used. To enable serial communication, the ATTiny was connected to a Wiznet ethernet to serial module, via a MAX232 level converter.

The android software uses a simple ListActivity as the display, and reads the list items from a text file on the SD card in the below format.

// This is a comment line
11. Item Name

The numbers indicate which channel and button the device is on, the rest of the line is a plain-english description of the device. Upon selecting an item, it displays a simple dialog box asking the user to confirm their choice, before sending the command to the Wiznet device via Wifi.

No comments:

Post a comment