Control RF Mains Plugs using the RFM12Pi

I've recently got a RFM12Pi connected to my Pi, and am looking to try to control my RF Mains Plugs (http://www.maplin.co.uk/remote-controlled-mains-sockets-5-pack-348217) from it.

 

There's a project which allows it to send the correct signal at https://github.com/dmcg/raspberry-strogonanoff but that assumes you have a transmitter connected directly to the GPIO pins on the Pi, which I don't have.

 

Is there a way to send this signal through the RFM12Pi?

manicmoddin's picture

Re: Control RF Mains Plugs using the RFM12Pi

Hi,

 

I dont believe there will be as most of these units use a 433 MHZ AM signal not the FM that the RF Transceivers use.

I have had limited suces using the other transmitter / receiver pair that they sell (vy48 [http://www.maplin.co.uk/transmitter-and-receiver-pair-22965]) with mome easy kits and an arduino, so if you can get the GPIOs working on the Pi, this should be fine in this instance but there will be some cross over required.

Google Home easy hacks and you will find what I have for them, Currently not got anything set up, but will be doing in the near future hopefully.

 

Jimmy

paul_tanner's picture

Re: Control RF Mains Plugs using the RFM12Pi

I'm also working on this.

As I am not running emoncms on this project I want to do a standalone demo and am going to try in node.js first (PHP and python are fallback options).  This will initially do something simple like toggle a socket on and off.  I'll use BBSB sockets which are compatible with the KAKU OOK protocol. 

Have not got past plugging the unit in yet but any comments welcome.

Paul

paul_tanner's picture

Re: Control RF Mains Plugs using the RFM12Pi

Got a little further.  Sent "1,1,1k" and got back:

> 0k

Available commands:
  123 x      - Toggle configuration change protection, 1=Unlocked
  <nn> i     - set node ID (standard node ids are 1..26)
  <n> b      - set MHz band (4 = 433, 8 = 868, 9 = 915)
  <nnn> g    - set network group (RFM12 only allows 212, 0 = any)
  <n> c      - set collect mode (advanced, normally 0)
  ...,<nn> a - send data packet to node <nn>, with ack
  ...,<nn> s - send data packet to node <nn>, no ack
  <n> l      - turn activity LED on DIG8 on or off
Current configuration:
65 i1 g210 @ 433 MHz  Lock: 1

which tells me that the k command is not supported in the supplied firmware.

I need to get hold of an updated version.

ffimon's picture

Re: Control RF Mains Plugs using the RFM12Pi

Being the thug I am I would have probably tried interfacing to the remote.

mharizanov's picture

Re: Control RF Mains Plugs using the RFM12Pi

KAKU code was removed from the RFM2Pi firmware to save space and keep code size <8K when the project was running on Attiny84. Now it can be easily returned for the v2 boards with Atmega328. I have experimented with sending OOK to power plugs with a RFM12B and it works well on short distance, however while sending OOK you will miss packets.. In my view, a dedicated 433mhz OOK sender is a better option.

glyn.hudson's picture

Re: Control RF Mains Plugs using the RFM12Pi

Hi Paul,

As martin said the KAKU code is not in the RF12 demo currently running on your RFM12Pi./ 

The sketch which is running on your RFM12Pi is: https://github.com/mharizanov/RFM2Pi/blob/master/firmware/RF12_Demo_atmega328/RF12_Demo_atmega328.ino

as you can see the remote KAKU commands are not listed.

I've just created a new sketch in the RFM12Pi repo on mharizanov github called Full_RF12demo_atmega328. It's the vanilla RFM12 demo sketch from JeeLabs bit with a few tweaks such as baud rate, turn off bad packet reporting and "OK" printing: https://github.com/mharizanov/RFM2Pi/tree/master/firmware/Full_RF12demo_atmega328

It's quite easy to update your RFM12Pi. If you're running the prebuilt emoncmspi SD card then simply run:

cd RFM2Pi/firmware/
git pull
cd RFM12Pi Full_RF12demo_atmega328
$ sudo service rfm12piphp stop
sudo avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:Full_RF12demo_atmega328.cpp.hex

If your not running the pre-built emoncmspi SD card then you will need to follow the instructions here to get avrdude to work on you're raspi: http://wiki.openenergymonitor.org/index.php?title=RFM12Pi_V2#Upgrading_RFM12Pi_Firmware_Direct_from_the_Pi

I've tested the new sketch here on my Pi and it works fine to receive data and log to emocms (normal RFM12Pi operation)

Let me know how you get on. Best of luck.

Glyn. 

glyn.hudson's picture

Re: Control RF Mains Plugs using the RFM12Pi

If you have an emonTx / JeeNode / NanodeRF / Arduino + RFM12B to hand you could try the kaku demo in the JeeLib examples

https://github.com/jcw/jeelib/tree/master/examples/RF12/kaku_demo

paul_tanner's picture

Re: Control RF Mains Plugs using the RFM12Pi

Thx Glyn,

I have now updated the firmware in the RFM12pi with your full version and everything is working.

As I am doing this standalone I used this procedure (adapted from the above link).

$ sudo apt-get update # just in case

$ sudo apt-get install arduino

$ sudo apt-get install python-dev

$ sudo apt-get install python-rpi.gpio
$ git clone https://github.com/mharizanov/avrdude-rpi.git
$ cd avrdude-rpi
$ sudo cp autoreset /usr/bin
$ sudo cp avrdude-autoreset /usr/bin
$ sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
$ sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
$ cd ..
$ git clone https://github.com/mharizanov/RFM2Pi.git
$ cd RFM2Pi/firmware/Full_RF12demo_atmega328
$ avrdude -v  -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 38400 -U flash:w:Full_RF12demo_atmega328.cpp.hex
 

Then you can control the thing via minicom (my BBSB socket set to channel A1) 

minicom -b 9600 -o -D /dev/ttyAMA0

1,1,1k to turn on

1,1,0k to turn off

Also wrote a program in node.js with module "serialport" that flashes a light connected to the socket.

This can be done in your language of choice of course.

Paul

glyn.hudson's picture

Re: Control RF Mains Plugs using the RFM12Pi

Ya! Fantastic news. Good work.

Could you post up the make and model of the plug so that others can also get this to work. 

I'll test the full RFM12Demo sketch to work for standard emoncmspi operation, if it works without a hitch after a period of time I'll make this the default firmware that shipped on the RFM12Pi's.

I'll also talk to Trystan regarding making a emoncms GUI amd event trigger in emoncms. 

Fabio's picture

Re: Control RF Mains Plugs using the RFM12Pi

Hi guys,

I have managed to control Elro Remote Switches via the RFM12Pi v2 module.

Now I also want to receive plain RF codes.

Is there any way to communicate with the rfm12b itself?

Like digitalRead or something less JeeLib-ish? JeeLib only seems to support group and node communication...

 

I was thinking about a sketch like this: http://forum.jeelabs.net/files/RFM12B_Receive_RC_switch.pde

 

Thanks!

galen's picture

Re: Control RF Mains Plugs using the RFM12Pi

mtully's picture

Re: Control RF Mains Plugs using the RFM12Pi

Hi all,

I installed the "full" firmware on my RFM12 pi with the intention of using KAKU. I noticed that my emoncms web UI became unresponsive after a few months, and tracked it back to a bug in the firmware, which was causing hundreds of inputs to be created causing the UI to get bogged down.

Pull request here: https://github.com/mharizanov/RFM2Pi/pull/6

Sorry - I don't know how to compile the .hex file from the .ico on OS X, if anyone can tell me I'll happily compile the .hex and include it in the pull request also.

Cheers,

Mark

glyn.hudson's picture

Re: Control RF Mains Plugs using the RFM12Pi

Pull request has been merged, cheers Mark

xrayman's picture

Re: Control RF Mains Plugs using the RFM12Pi

Sorry for digging up this post.

I'm not certain if this helps anyone?

I bought the remote controls described in the very first post of this thread. I must admit I had misread the thread and believed that the author further down had been successful in getting them to work. Never mind, I did pull the remote apart and stuck an oscilloscope onto the RF output and recorded traces for ON/OFF for each channel and button combination. I have CSV files as well as these screen grabs. If anyone wants the CSV files I'll post them as a zip.

pb66's picture

Re: Control RF Mains Plugs using the RFM12Pi

It's definitely interesting, I can't comment on how useful the CSV data is (probably 'very' in the right hands) but certainly if the file sizes permit an upload I would be keen to take a look and once they are uploaded we can refer back to them if they are useful it the future.

I have several packets of these OOK mains adapters and I intend to get them hooked up one day. (another hopeful ambition on my forever escalating list of things to do) .

Plu the (hopefully) soon to be released emonPi has provision for a OOK transmitter so that should stir up some interest too.

Paul

Bramco's picture

Re: Control RF Mains Plugs using the RFM12Pi

Paul,

I'm not clued up on the new Hope transceiver but I can't imagine it can run both AM and FM in tandem. I imagine you will either have to use it as one or the other so if you switch to AM then you'll potentially miss transmissions from any emonTX.

So as per some of the other threads on this topic, you will need one transceiver for FM style modulation for talking to emonTXs and one for AM style OOK modulation for talking to rf sockets etc.

So in the emonPi the Hope transceiver will be used for comms with emon devices and therefore won't be available for OOK type comms.

Please correct me if I'm wrong here.

Simon

pb66's picture

Re: Control RF Mains Plugs using the RFM12Pi

Hi Simon, what you say is correct (although you could run rfm12's)  However

Plus the (hopefully) soon to be released emonPi also has provision for an OOK transmitter in  addition to the usual RFM transiever, so that should stir up some interest too.

I'll correct myself instead, for not being clearer :-)

Bramco's picture

Re: Control RF Mains Plugs using the RFM12Pi

Got it Paul, I hadn't noticed that, or had forgotten that it was there on the board layout. But then it's been almost a year since this was first mooted......    ;-)

xrayman's picture

Re: Control RF Mains Plugs using the RFM12Pi

Sorry for the slow reply I think I need to have a look at my notification settings. I've uploaded the files in an archive. Each folder corresponds to a signal generated from the remote. There are files (index.txt, index.pdf) explaining which channel and button was pressed to generate which signal (and folder).

 

I did find a blog online that showed how to generate the pulse sequences and then to use it to turn the plug on and off:

http://jeelabs.org/2009/03/03/ook-signaling-with-an-rfm12b/

I'm not sufficiently versed in the rfm12b to have tried it yet. I also use my Pi for monitoring so I do not mind loosing  a few status packets to automate turning lights on and off I do mind loosing a lot whilst I make a mess of things trying to learn to program it.

I'm also much happier in python, fortran and PHP than other languages so they do take a while to get right.

pb66's picture

Re: Control RF Mains Plugs using the RFM12Pi

Thanks for posting the data I shall take a closer look when I can.

JeeLib and the RF12demo sketches do already have an option or interface for OOK.

Depending on your setup you could just run a second device for OOK, If using a Pi with a RFM2Pi consider adding a JeeLink or jeeNode, that way you can leave one ticking over while experimenting on the other. 

emonHub is python based and can use a Jeelink, JeeNode or rfm2pi for data, if you are willing I wouldn't mind collaborating on a python based OOK interface. We could try using a stock firmware with OOK api on the rfm device and do the work in python.

Paul

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.