WiFi Controlled Power Outlets with Raspberry Pi

[Tim] was looking for a way to control his power outlets using WiFi. He looked into purchasing a WeMo but he realized that he could build something even better with more bang for his buck. He started out by purchasing a five pack of Etekcity wireless remote control outlet switches. These are kind of like the WeMo, only they aren’t controlled via WiFi. Instead, they come with an RF controller. [Tim] just needed to find a way to bridge the gap between the RF remote and WiFi.

[Tim] decided to use a Raspberry Pi as the brains of the controller. He also purchased a SMAKN 433MHz RF receiver and transmitter for communicating with the wireless outlet switches. The wiring for the modules is pretty simple. There are only four wires. There are power and ground wires for each module. Then the transmitter needs two GPIO pins while the receiver only needs one.

[Tim] began with a fresh installation of Raspbian. He then installed Wiring Pi, which gives you the ability to interface with the GPIO pins in a way that is similar to Arduino. He also installed Apache and PHP to create a web interface for switching the outlets. The last step was to write some custom software. The software included a script that allowed [Tim] to sniff out the controls of his RF remote. The correct codes are entered into the “toggle.php” file, and everything is set. All [Tim] has to do now is browse to his Pi’s web server and click a button. All of the custom code is available via git.

39 thoughts on “WiFi Controlled Power Outlets with Raspberry Pi

  1. Or you could use pilight, which has drivers for many many rf sockets and other devices. Works a treat for me and I wrote drivers for my kambrook rf sockets and my pet-training “beepy” collars.

    I added the HTML shortcuts to tasker and now control everything from my phone!

    1. bigger problem, trivially easy to ‘hack’. some would say the same for zwave/lo-pan but it requires much more sophistication and access to pull off. these things can be controlled by anyone.

  2. Standby power consumption of RF switch?

    Has anyone an idea how power-hungry those RF switches tend to be in standby?

    One of the applications those things are touted for is avoiding standby of electrical appliances, but considering there’s a solid state AC relay with all the snubbing around it and a power supply for a radio receiver (and the radio receiver itself, of course) — perhaps it exceeds the 0.5W standby of my TV: this application would be out, no?

    Swithching a lamp on or off would be something completely different, of course.

    1. I haven’t measured power usage (my switching is for convenience rather than energy saving), but my now-old-fashioned X10 modules use latching relays, so it only requires switching power when changing state. I hope the new fangled RF IoT ones do the same, otherwise they could be adding a Watt or two when switched on, as well as receiver power.

      With a ‘feel test’, I would expect my HomeEasy sockets draw less than 1W.

      If using a pi to control them, it would be wise to look at openhab or misterhouse to do the ‘everything but RF’ part of the job, to save reinventing wheels. Openhab was quite limited on the pi (I use mh but expecting to move to openhab as it seems to be more actively developed just now), but hopefully will be faster on the Pi 2.

      1. Hey, Nigel — thanks for this data point: a “feel test” is already much more data than I’ve got :-)

        Besides, I think consumption will vary wildly on device maker. Latching relays sound like the ideal solution, but I fear that they’re going out of fashion in favour of “solid state relays” (a glorified TRIAC or something more newfangled), whatever they do to leakage currents.

        > my switching is for convenience rather than energy saving

        This, of course stays a legitimate use. I was rather thinking of replacing a manual switch: that would only make sense if the machine behind it (TV, backup server) has a significantly higher standby power usage than the switch itself.

        And if Okian’s fears in another post are still material, we’ve lost compared to the waste going into replacing the switches every couple of months anyway ;-)

      2. It is not about the relay, it is about the fact that you use a transformer less power supply. It will consume about the same amount of power whether you load it 0% or 100% of its capacity. Latching relay or not….

    2. The original X10 Appliance Module has a custom mechanical “relay”. Works a lot like those pens in which you press a button to extend or retract the tip. It’s driven by a solenoid only when a change of state is required, so no power is required by the switch otherwise. Off the shelf, you can buy “latching relays” that are held in either state via permanent magnets and perform a similar function, for about $5.

      But it still has a primitive internal power supply that draws about 1W when idle. Most small switching power supplies draw at least 0.5W. If you really want to trim away every possible watt, you need to be able to switch multiple AC outlets per device.

  3. Looking at the reviews for the outlet product, it seems these outlets tend to stop working after a couple of months.

    Usually what happens is, in the instant of burning out an incandescent lamp will overload the SCR and burn that out as well. Probably HF voltage spikes that wouldn’t normally bother a lamp would do this as well (as in “lightning strike”).

    Has this vulnerability been fixed in a different model/type, or will all remote outlets (SCR type, not relay type) burn out in a short time?

    1. Most of them are relay based, but the cheap ones have small current capabilities. There is a fuse(most common i have seen is 4A) that usually blows with the incandescent light bulb. Also common for the cheap ones is to have a non replaceable fuse.

        1. As regards the fuse, the older RadioShack X10 models had a wire jumper on the circuit board that acted as the fuse. When one burned out, you could crack it open, see a pair of holes where a component might go, and note that there was a line of vaporized copper between the holes.

          Solder a new wire across the holes and if the triac isn’t also burned out this repairs the device.

          Just thought that might be useful…

          1. The two kinds of outlets I have used had a 4A fuse that was soldered with 2 wires to the PCB. You could replace it, but it required quite a lot of work. I remember a friend having some early and expensive ones that had a user replaceable fuse.

  4. I have always wondered what it will be like with a near strike and lotsa e-switches and e-lamps to replace.
    I long knew that incandescents were good at killing dimmers when they die. Just like dimmers kill AM radio with their filthy power.

  5. Ive bought a few cheap wifi controlled power sockets off aliexpress.

    That kankun even has a google plus group dedicated to putting openwrt onto the thing. For about $17 including shipping it really does show what a rip some of the other less featured products are.

    1. The $17 is from aliexpress, where you can also buy 3 classical ones for the same money. But yet in a store they will cost double that. Let’s not forget the kind of prices and products each store has.
      It is not fair to say that a well designed wifi controlled outlet is expensive at 30-40, because it is a different quality product. With the arrival of cheaper wifi connectivity you will get cheaper products, but I would not think that one costing under $20 is good enough quality, simply because it will take some money to put in a good relay, fuse and an efficient power supply.
      A $10 per outlet 15A switch that does not blow the fuse when the light bulb goes down is worth buying over a $5 per outlet 4A that blows after one year.

  6. One problem I’ve found with the RF433 modules is “bit error”. I am using two to control aspects of my heating and hot water system. Occasiaonly the wrong switch gets triggered. On inspection it looks like there is only one bit difference between the control sequences for the two units. I am not sure if it is the wrong thing being transmitted or the unit is triggering off the wrong command. I am using a raspberry pi – so thiere is the possibility that the control strings are being altered by multi-tasking. I send three identical pulses at a time to try to avoid this.

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