Android/Arduino RF Outlets Selector
Here’s a great little project I implemented with Arduino and Android – switching outlets from my smart phone!
I started with off the shelf RF Wireless Outlets. At $6 per outlet, they are a complete steal. I got lucky and found all 4 channels of these wireless/RF outlets at a local Big Lots:
Compare that pricing to one unit of the Belkin WeMo Switch
Here’s a 315MHz Android-compatible transmitter/receiver on Amazon: SMAKN 315Mhz Rf Transmitter and Receiver Kit
All the code is on Bitbucket. That includes a simple remote control Android application (as seen in video).
And the brain it runs on (I used the Arduino Ethernet model, there may be better choices now…): Arduino Ethernets on Amazon
This is what the circuit looks like… very simple, just hook up the 4 pins of the transmitter to the correct place and you will be ready to load the code onto the Arduino!
The Arduino can hook up to your router via the Ethernet shield, and when it’s turned on will be running a web server at the URL:
And of course the Android comes in with a basic UI over top of those URL permutations, so you can click a toggle button for all the outlets, rename them, etc.
I based the code on a cool outlet project that was pretty mature, called RC Switch, but in Europe the RF protocols and outlets are a bit different. There was also a reference from Instructables, but those RF on/off timings didn’t match my outlets. If you don’t have luck with my code as-is, modify the pulse length timings to match what is found here. There may be more variants that look the same, as a lot of these outlet modules look the same but are rebranded.
Reverse Engineering / Troubleshooting
Hopefully during the project you can implement it in a straight-forward way, but if the same protocol does not control the relays, read on to how I troubleshot this project originally…
To figure out the problem above, I used the Arduino as a logic analyzer to figure out what exactly wasn’t working, and that was probably the most fun part of the project. I soldered leads onto the stock wireless remote to spy on the signal that was being transmitted, and saw the digital signal graph on my TV screen. Amazing! As a programmer, I forget sometimes that there is electricity flowing through everything and changing direction every few nanoseconds.
This Arduino logic analyzer is a great open-source code project, and saved me big time here. It has 500 kHz max resolution, but since there is only 1kb of RAM, you’re limited to 1024 samples. That resolution was actually so good, that the first few times I thought it wasn’t working… I was zoomed in too far and didn’t see any transitions. As soon as I zoomed out to 1 kHz, I saw everything! And 20 kHz was finally the sweet spot to measure the timings accurately.
This is how I instrumented the remote control for use with the logic analyzer. I soldered many jumpers onto the circuit — only 2 carried the signal I wanted. The orange wire, and the right-most white wire both had the correct waveform — though the white one was inverted. I also provided power from the Arduino, since the remote had a 12V battery, some traces might have been carrying too much juice for the Arduino!
Feel free to provide critique or suggestions!