I've been using remote RF outlets to control Christmas decorations for years. It's definitely easier than trying to get under and around the tree to plug lights into an outlet or go outside to plug in the outdoor lights. Yet I constantly lose (and miraculously find) the remote every year. I've also had a 434 MHz transmitter for a while and decided to put it and the Particle Internet Button to use. It's (almost) a perfect match considering the RF remote can control 4 outlets and the Particle Internet Button has 4 buttons! The only thing lacking is that the RF remote has "all on" and "all off" buttons. Meh.
So, I have the hardware, but where do I find the RF codes? I received an SDR (software-defined radio) last year for Christmas and used it to sniff the codes (that's another tutorial I will publish in the future). Apparently, I'm the only person who has an Arduino (or comparable microcontroller) and these remotes, so I couldn't find any data on them online. If you don't have RF remote outlets, look up the Arduino RC-switch library to see what it supports--that will make things MUCH easier for you.
Sniffing was easy, and I was able to discern the following codes. Each one contained a common preamble of 14 bits transmitted before each set of codes. Each button transmitted two different codes, the first code 3 times with a short delay between each, then a longer delay, followed by the second code 3 times with another short delay between each. Here's what each button transmitted:
- 1 ON:
10011011100111011111110101
x3, pause,10011011100111011100111001
x3 - 1 OFF:
10011011100111111110111001
x3, pause,10011011100111011100111001
x3 - 2 ON:
10011011100111111011111100
x3, pause,10011011100111111000110000
x3 - 2 OFF:
10011011100111011010110000
x3, pause,10011011100111111000110000
x3 - 3 ON:
10011011100111110111111011
x3, pause,10011011100111110100111111
x3 - 3 OFF:
10011011100111010110111111
x3, pause,10011011100111110100111111
x3 - 4 ON:
10011011100111010011110010
x3, pause,10011011100111010000110110
x3 - 4 OFF:
10011011100111110010110110
x3, pause,10011011100111010000110110
x3 - All ON:
10011011100111001011110000
x3, pause,10011011100111001000110100
x3 - All OFF:
10011011100111101010110100
x3, pause,10011011100111001000110100
x3
As you can see, each code begins with a common 14-bit preamble of 10011011100111
. Beyond that, I couldn't make quick rhyme or reason of the rest of each code. Fortunately, I didn't have to! Figuring out the timings of each bit and pauses was the hardest part, but I eventually "brute forced" it by creating my own timings and comparing them to the sound file recorded from the SDR. After a few rounds of timing adjustments, I was toggling the outlets in code! I'll be writing up another article about that whole process with plenty of screenshots.
Now on to hacking it all together! One minor issue with the Particle Internet Button is that the Photon GPIO pins are exposed on the bottom, but there's no easy way to wire them up and keep it stable on a flat surface. I designed and 3D printed a mount that keeps the dome in place and has channels for wiring the GPIO to the 434 MHz transmitter. The wiring for that was simple:
- Photon
VIN
--> 434 MHz transmitterVCC
(pin 3) - Photon
GND
--> 434 MHz transmitterGND
(pin 1) - Photon
D2
--> 434 MHz transmitterDATA
(pin 2) - 17cm wire antenna --> 434 MHz transmitter
ANT
(pin 4)
The 17cm wire antenna was just a single wire from some ethernet with one end stripped to put into the breadboard. I got the 17cm length from a quick Google search for "434mhz antenna length".
Now I have a fancy set of buttons to turn the RF outlets on and off. When an outlet is "thought" to be on, the LEDs for that button are brighter. When off then the LEDs are dim. Voila! Done!
Not hardly. What good is a wi-fi device without taking advantage of the wi-fi. I created a function in the code to accept commands to toggle the RF outlets. Now I can control the outlets remotely! Bingo! Done!
Not yet. Ugh. Manually triggering the outlets even remotely was still too much work. I'd really like to have all the lights turned on at sunset and turned off when the kids go to bed. I originally thought I was going to have to write a webhook to automagically figure that stuff out. Oh wait, no I don't! IFTTT (If This Then That) has Weather (for sunset) and Date & Time (for time of day) channels that can do this for me. I've published the recipes so you can see how they're done and adapt them for your needs:
- Turn on roof lights at sunset
- Turn on Christmas tree at sunset
- Turn off roof lights at 10:00 PM
- Turn off Christmas tree at 2:00 AM
Aside from figuring out the RF codes, everything was quick and fairly trivial. The only issue I had is that the RF transmitter isn't as powerful as the original RF remote, so I had to place the button in a location within range of the RF outlets. I tried a 34cm antenna, but it didn't improve anything. I also tried more powerful USB power adapters without any improvements, so I assume there are simply limitations to that transmitter or maybe the timings in the code are a little "off" for that distance. If anyone has recommendations, leave them in the comments.
I know it's a little late for Christmas this year (well, 2015), but I hope this post may inspire other similar projects or put to use for Christmas 2016!
Comments