One of the goodies of home automation is that you can actually turn appliances on and off based on some pre-defined conditions or via the Internet. Typically that task will require setting up a relay or multiple relays and hooking them up to a Internet-connected micro controller. The task isn’t that trivial if you would like to control several appliances scattered all over the house. One possible approach is to use radio controlled power sockets instead for the obvious advantage of wireless control. I purchased a set that is running on 433.92Mhz quite some time ago and have used it in manual mode since, the model I have is a “Duwi EMW200R” and can switch appliance up to 1000W. There are other models by the same manufacturer that can handle 3500W and I have seen a model that fits a DIN rail.
On the other side, while toying with the sensing shield, I was reviewing the RF12 sample code in the JeeLib and noticed this particular example of a RFM12B module being used to send OOK signals: https://github.com/jcw/jeelib/blob/master/examples/RF12/kaku_demo/kaku_demo.ino
As I already own the RF controlled sockets, I decided to capture their their protocol and be able to control them. Using a dedicated hardware 433Mhz OOK sender for the purpose is piece of cake using the Remote Switch library, I got the sockets switching on and off in less that 5 minutes, but my goal is to use the RFM12B instead. The reason for that is because there is a number of hardware platforms like the JeeNode, NanodeRF, SensingShield and so forth that do already have a RFM12B module installed and there is no need for extra hardware to do the controlling.
For the project I needed the following:
Hardware:
- A 433Mhz OOK receiver so I can capture the RF signals from the remote control unit
- Audio capturing circuit that interfaces the OOK receiver to my microphone jack. I used that same circuit when I captured IR signals for my earlier projects.
- One of my sensing shields with a 868Mhz RFM12B mounted (yes, 868Mhz)
- Optional: An audio loop back cable; I use it to replay recorded RF signals for the IR protocol analyzer.
Software:
- I use Audacity to record the RF signals to a .WAV file but also to compare timings of my synthetic signal vs the original signal
- IR protocol analyzer, a nice program that also works for RF protocol analysis
<protocol name="Duwi"> <description url="www.duewi.de"> DUWI </description> <bitset> <bit value="1"> #990 _330 </bit> <bit value="0"> #330 _990 </bit> </bitset> <packet> <data name="byte0" length="8" bitorder="MSB" /> <data name="byte1" length="8" bitorder="MSB" /> <data name="byte2" length="8" bitorder="MSB" /> </packet> </protocol>
// This example is based in JCW's KAKU RF sockets control code // 2009-02-21 jc@wippler.nl http://opensource.org/licenses/mit-license.php // Note that 868 MHz RFM12B's can send 433 MHz just fine, even though the RF // circuitry is presumably not optimized for that band. Maybe the range will // be limited, or maybe it's just because 868 is nearly a multiple of 433 ? #include <JeeLib.h> #include <util/parity.h> // Turn transmitter on or off, but also apply asymmetric correction and account // for 25 us SPI overhead to end up with the proper on-the-air pulse widths. // With thanks to JGJ Veken for his help in getting these values right. static void ookPulse(int on, int off) { rf12_onOff(1); delayMicroseconds(on + 150); rf12_onOff(0); delayMicroseconds(off - 200); } static void OOKSend(unsigned long cmd) { for (byte i = 0; i < 10; ++i) { for (byte bit = 0; bit < 25; ++bit) { int on = bitRead(cmd, bit) ? 1056 : 395; ookPulse(on, 1313 - on); } delay(10); // approximate } } void setup() { Serial.begin(9600); Serial.println("\n[OOK_RF sockets]"); rf12_initialize(0, RF12_433MHZ); } void loop() { Serial.println("off"); OOKSend(0b0001010101010100010101000); delay(1000); Serial.println("on"); // OOKSend(0b0111010101010100010101000); OOKSend(0b0101010101010100010101000); delay(1000); }
Do I need some more hardware?? At this moment I have just the emonTX, emonGlcd en Nanode RF (EmonBase) (from openenergymonitor.org) all using 868Mhz to communicate . If I understand this article, I can use power sockets on 433Mhz…
Well, that’s the beauty of it: you *can* use the 868Mhz RFM12B to control your 433Mhz power sockets with no additional hardware. Range is limited though, so pick the node that is closest to your appliance. Or alternatively you may issue a broadcast type of message and all the nodes (the emonTX, emonGlcd and the NanodeRF itself) can switch temporary in 433Mhz mode to issue the RF control command, then revert back to 868Mhz mode to continue their normal operation. That should be quite easy to achieve.
And what If I find power sockets on 868 MHZ, then I don’t have to switch between the MHZ’s I don’t know if they actually excist… I will google it up 🙂 Then I will try out your code
My code is for the particular RF sockets that I have. You will need to adjust it for your RF sockets, or take an easier approach and purchase a “KAKU” model , I have the code that controls it in the post.
http://www.klikaanklikuit.nl/shop/stekkerdoos-schakelaar-acd-1000/
Hi Everyone,
I’ve built a wireless data logging project with a nanodeRF (as a base) and a couple of remote RFM12B transceivers – everything working well.
Something I would love to do is to hack/intercept the communications between my home power monitoring system wich is a CurrentCost (www.currentcost.com).
It seems that this device uses the RFM12 to talk with the mains power clamp sensor in 433 Mhz band. I would like to at least try…
Everythins is preatty self explanatory, even so, I would like to ask how did you recorded the RF audio signal?
Best,
I capture the RF data using this method: http://davehouston.org/learn.htm
Since CurrentCost is also using RFM12B, you’d rather try to capture and decode the package sent with your NanodeRF
Googling a bit takes me to this discussion on the subject:
http://www.navitron.org.uk/forum/index.php?action=printpage;topic=11941.0
there are some useful links, check them out
Hi again,
Thank you very much for answering and the links.
I will check and try that process as soon as I can.
Thanks
Which (PHP) code do you use on the internet to send an ON or OFF to the nanodeRF ??
This was just a proof of concept to be used in future projects, I only tested with direct code (the one shown in the post). There won’t be PHP, the web-connected NanodeRF or ArduinoEthernet+Sensing shield will serve normal HTML pages and the user will be able to issue a command. I don’t have immediate need to do it now, so that will be done sometime later.
Where can I find some PHP code that shows me an example to send a command to the NanodeRF ?? I have no id how to start…
Here is an idea: http://blog.thiseldo.co.uk/?p=599
Thanks for the heads up with the IR protocol analyser… I’ve been using my own flakey decoder using CSV from a logic analyser for a long time.
Pingback: Clapping to control RF power sockets | Martin's corner on the web
Hello Martin,
I’ve found that this sketch works really well with the recent Chacon (aka D.IO) power sockets.
This is true for the first device of the A group.
Can you please tell me how can I get the other devices to work? i.e.: what are the the bits that represent the device and what bits represent each group?
Thank you for any help.