mba
Posts: 110
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark

Controlling 433MHz RF outlets with Android devices

Sun Jan 19, 2014 9:58 am

Hi,

This tutorial will show you how to control your lighting and other devices with some cheap 433MHz RF based power outlets. The setup uses wiringPi for accessing the necessary GPIO pin, rcswitch-pi for sending the commands out of the 433MHz module and LIRC for controlling the whole thing when it receives the right remote commands. You don’t need any infrared receiver or transmitter, the only extra hardware you need beside your Raspberry Pi is a very cheap 433MHz transmitter module which you can get on ebay for less than $2 (including free shipping and a receiver module which you don’t need for this tutorial). Here a picture of the transmitter (left) and receiver (right) that I bought on ebay.
Image
I will be using AMOTE which is an app for Android I wrote that basically is a versatile LIRC client that can request LIRC to blast IR commands through dedicated IR blaster circuitry or simulate button presses that will make LIRC pretend it had received the commands through an IR receiver. In AMOTE you can design your own universal remote control with buttons known to your LIRC server and I will configure a couple of buttons with simulated events which LIRC will translate into RF commands using lircrc. It all sounds very complicated but in practice it’s actually quite simple.

Connecting the RF module to Raspberry Pi
Its quite simple to connect the RF module. When you have selected the GPIO pin you want to use then connect the DATA pin of the module to this pin, next connect VCC to 5V and the GND to a Ground pin on the Raspberry Pi pin header. In the illustration below I choose GPIO pin 22 as my data pin.
Image

Install LIRC
For instructions on how to install LIRC on Raspberry Pi see this link.

Install wiringPi
wiringPi is maintained in git and the same goes for rcswitch-pi so you need to install git if you don’t already have it on your system

Code: Select all

sudo apt-get install git-core
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
Install rcswitch-pi
Before compiling rcswitch-pi you must decide which GPIO pin you will use as the data pin for your RF module. I used GPIO pin number 22 (which is the number you can read on the Raspberry Pi connector schematic) this number has to be translated to a wiringPi pin number which in my case is 3. See http://wiringpi.com/pins/ for more info. Just edit send.c and change PIN to the number that fits your purpose. After make has finished you can copy the send executable to /usr/bin for easier access later on

Code: Select all

git clone https://github.com/r10r/rcswitch-pi.git
cd rcswitch-pi
make
sudo cp send /usr/bin
Configure and test your RF outlets
If you have connected the RF module to your Raspberry Pi I recommend testing that everything is working before going further. You need to configure the address of your RF outlets, the image below shows an outlet configured with system code ‘11111’ and device code ‘A’:
Image
Using send from rcswitch-pi we can turn this outlet on with the following command:

Code: Select all

sudo send 11111 1 1
First argument is the system code ‘11111’, second argument is the device A = 1 and last is the value for the state of the outlet 1 = ‘on’.
You can try turning it off again by issuing this command:

Code: Select all

sudo send 11111 1 0
Configure event script lircrc
Making LIRC do stuff when it receives commands can be done by adding a special configuration file called lircrc in /etc/lirc. Here’s an example of a lircrc file which I will be using for this tutorial

Code: Select all

begin
 prog = irexec
 remote = LAMPS
 button = LAMP1_ON
 config = send 11111 1 1
end

begin
 prog = irexec
 remote = LAMPS
 button = LAMP1_OFF
 config = send 11111 1 0
end

begin
 prog = irexec
 remote = LAMPS
 button = LAMP2_ON
 config = send 11111 2 1
end

begin
 prog = irexec
 remote = LAMPS
 button = LAMP2_OFF
 config = send 11111 2 0
end
This configuration file will make LIRC execute irexec when receiving one of the buttons from the LAMPS remote. The 'config' part of each entry is the argument passed to irexec and you can see we are calling the 'send' from rcswitch-pi with an appropriate outlet code and device address and a command.
Next we Add a remote to LIRC lircd.conf. It does not matter how its configured we only simulate the events, so in thery you can take any configuration file from http://lirc.sourceforge.net/remotes/ rename the remote and buttons. For this tutorial I added the remote below to my lircd.conf file. Just append it to the end of the file. Notice that the remote name and button names are identical to the names used in the lircrc file:

Code: Select all

begin remote

  name  LAMPS
  bits           12
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       2453   529
  one          1257   532
  zero          660   532
  gap          44813
  toggle_bit_mask 0x0

      begin codes
          LAMP1_ON                     0x5D0
          LAMP1_OFF                    0xA90
          LAMP2_ON                     0x1D0
          LAMP2_OFF                    0xE90
      end codes
end remote
When both /etc/lirc/lircrc and /etc/lirc/lircd.conf has been configured properly you can now restart lirc with the following command to make the changes take effect:

Code: Select all

sudo /etc/init.d/lirc restart
And its now time to test if LIRC is able to control the outlets. Using irsend you can query the LIRC server for remotes and buttons. I will query the LAMPS remote for a list of buttons:

Code: Select all

[email protected] ~ $ irsend LIST LAMPS ""
irsend: 00000000000005d0 LAMP1_ON
irsend: 0000000000000a90 LAMP1_OFF
irsend: 00000000000001d0 LAMP2_ON
irsend: 0000000000000e90 LAMP2_OFF
With these informations you can now control the two lamps. Here I turn on lamp 1 again using irsend:

Code: Select all

irsend SIMULATE "00000000000005d0 00 LAMP1_ON LAMPS"
Configure AMOTE
Finally you can configure AMOTE to control your outlets. See the manual on AMOTE here. Just add a new server with the ip address of the Raspberry Pi running LIRC load the remotes and button from this server, add a new button to your layout, call it something like “LAMP1 ON” and select LAMP1_ON button from the LAMPS remote, remember to put a checkmark in the simulate option on the key like shown below:
Image

Best regards
Martin
AMOTE - a LIRC client for Android. Build your own Android-based universal remote.

rdampier10
Posts: 2
Joined: Sat Feb 15, 2014 6:53 pm

Re: Controlling 433MHz RF outlets with Android devices

Sat Feb 15, 2014 8:06 pm

Looking for some help I have lirc installed and running but having some problems with the irexec deamon. When I run irexec at the command line irexec runs the lircrc as written. When started at the command line as a deamon the lircrc commands don't execute. I have done the lircrc file both in the/ete/lirc directory and as the .lircrc in the users home directory. But I had no luck getting the irexec and lircrc running as a daemon.

camillo777
Posts: 26
Joined: Tue Feb 04, 2014 1:21 pm

Re: Controlling 433MHz RF outlets with Android devices

Mon Feb 17, 2014 5:08 pm

Hi very nice!
How much range are You getting with those 433MHz TX&RX?
Did You solder an antenna?
Thank you!
Best regards,
Camillo

mba
Posts: 110
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark

Re: Controlling 433MHz RF outlets with Android devices

Mon Feb 17, 2014 6:42 pm

rdampier10 wrote:Looking for some help I have lirc installed and running but having some problems with the irexec deamon. When I run irexec at the command line irexec runs the lircrc as written. When started at the command line as a deamon the lircrc commands don't execute. I have done the lircrc file both in the/ete/lirc directory and as the .lircrc in the users home directory. But I had no luck getting the irexec and lircrc running as a daemon.
When a lircrc file exist in /etc/lirc and you start lirc eg. with
sudo /etc/init.d/lirc restart
then irexec will get started and daemonized automatically.

Br
Martin
AMOTE - a LIRC client for Android. Build your own Android-based universal remote.

mba
Posts: 110
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark

Re: Controlling 433MHz RF outlets with Android devices

Mon Feb 17, 2014 6:47 pm

camillo777 wrote:Hi very nice!
How much range are You getting with those 433MHz TX&RX?
Did You solder an antenna?
Thank you!
Best regards,
Camillo
I have succesfully tested it with a socket placed about 6-8m away through two closed doors. Its vital to have an antenna with the right length soldered to the transmitter, and it must be precisely 17.3cm long.

Br.
Martin
AMOTE - a LIRC client for Android. Build your own Android-based universal remote.

rdampier10
Posts: 2
Joined: Sat Feb 15, 2014 6:53 pm

Re: Controlling 433MHz RF outlets with Android devices

Wed Feb 19, 2014 7:04 pm

mba wrote:
rdampier10 wrote:Looking for some help I have lirc installed and running but having some problems with the irexec deamon. When I run irexec at the command line irexec runs the lircrc as written. When started at the command line as a deamon the lircrc commands don't execute. I have done the lircrc file both in the/ete/lirc directory and as the .lircrc in the users home directory. But I had no luck getting the irexec and lircrc running as a daemon.
When a lircrc file exist in /etc/lirc and you start lirc eg. with
sudo /etc/init.d/lirc restart
then irexec will get started and daemonized automatically.

Br
Martin

Agreed I see the irexec running as a daemon when I do a ps aux it also shows the lircrc path it loaded but the config lines don't execute.

the lircrc file consist of
begin
prog = irexec
button = KEY_0
config = echo 'hello from lircrc'
end
when this file is in the /home/pi/.lircrc and irexec is run from the command line I get the expected results whenever the key_0 is pressed.
now I do sudo irexec -d /home/pi/.lircrc
I see then irexec running as a daemon as user root when I do a 'ps aux' but I don't get the expected response when the remote key_0 is pressed.
I also tried placing the lircrc file in the /etc/lirc directory and I see irexec running as a daemon with the /etc/lirc/lircrc It does not produce the desired results.
That is why I am posting this I can't why it runs as a command line call but not as a daemon.

Thanks
Bob

mba
Posts: 110
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark

Re: Controlling 433MHz RF outlets with Android devices

Wed Feb 19, 2014 8:11 pm

rdampier10 wrote:
mba wrote:
rdampier10 wrote:Looking for some help I have lirc installed and running but having some problems with the irexec deamon. When I run irexec at the command line irexec runs the lircrc as written. When started at the command line as a deamon the lircrc commands don't execute. I have done the lircrc file both in the/ete/lirc directory and as the .lircrc in the users home directory. But I had no luck getting the irexec and lircrc running as a daemon.
When a lircrc file exist in /etc/lirc and you start lirc eg. with
sudo /etc/init.d/lirc restart
then irexec will get started and daemonized automatically.

Br
Martin

Agreed I see the irexec running as a daemon when I do a ps aux it also shows the lircrc path it loaded but the config lines don't execute.

the lircrc file consist of
begin
prog = irexec
button = KEY_0
config = echo 'hello from lircrc'
end
when this file is in the /home/pi/.lircrc and irexec is run from the command line I get the expected results whenever the key_0 is pressed.
now I do sudo irexec -d /home/pi/.lircrc
I see then irexec running as a daemon as user root when I do a 'ps aux' but I don't get the expected response when the remote key_0 is pressed.
I also tried placing the lircrc file in the /etc/lirc directory and I see irexec running as a daemon with the /etc/lirc/lircrc It does not produce the desired results.
That is why I am posting this I can't why it runs as a command line call but not as a daemon.

Thanks
Bob
I guess thats because when you run it from the commandline echo will write to std. output and you can see it in the console but when run as a daemon it was not started from the commandline and therefore does not output to the console. Try echo'ing to a file instead like this:
echo 'hello from lirc' > /tmp/hello_lirc
And see if the file is not created and contains the text.

Br
Martin
AMOTE - a LIRC client for Android. Build your own Android-based universal remote.

armaster
Posts: 5
Joined: Thu Apr 24, 2014 5:40 am

Re: Controlling 433MHz RF outlets with Android devices

Thu Apr 24, 2014 6:48 am

I'm looking for a little help here. I created /home/pi/lirc.conf file, /home/pi/.xmbc/remote.xml and Lircmapxml. Remote control works well in XBMC. However, when I exit from XBMC and run irw from the command line, I can see keys from my remote:

Code: Select all

2 0 KEY_1 devinput
2 0 KEY_1_UP devinput
If I run sudo /etc/init.d/lirc restart and then irw I can see keys from remote like this:

Code: Select all

0000000099664ab5 00 KEY_1 edision_rc1_red
0000000099664ab5 01 KEY_1 edision_rc1_red
I also created /home/pi/.lircrc file:

Code: Select all

begin
 prog = irexec
 remote = edision_rc1_red
 button = KEY_1
 config = echo 'rc1' > /home/pi/temp_rc
 repeat = 0
end
But nothing happens if I press key 1 on remote from XMBC. If I exit XBMC then I can see output in my temp_rc file only if I run sudo /etc/init.d/lirc restart and then sudo irexec -d /home/pi/.lircrc.

Why I must restart lirc and run irexec manually to work and why doesn't work from XBMC? I would like to run script from XBMC which will execute isend command but I stuck here. Can you please help?

albertoa
Posts: 2
Joined: Tue Dec 30, 2014 2:25 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Dec 30, 2014 2:40 pm

I am able to send commands via Terminal and it turns on and off my Bestets outlet: sudo send 11111 1 1

However, when I try to run LIRC, it is not working.
sudo /etc/init.d/lirc restart
[ ok ] No valid /etc/lirc/lircd.conf has been found..
[ ok ] Remote control support has been disabled..
[ ok ] Reconfigure LIRC or manually replace /etc/lirc/lircd.conf to enable..
Instructions link on how to install LIRC on Raspberry Pi is not working. Am I missing something?
Thanx a lot.

albertoa
Posts: 2
Joined: Tue Dec 30, 2014 2:25 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Dec 30, 2014 5:06 pm

Solved. It was the first line in lircd.conf file, an #UNCONFIGURED comment that I found in /etc/init.d/lirc and makes it does not startup.

But now I have this error, and Amole do not connects.
sudo fuser /dev/lirc
Specified filename /dev/lirc does not exist.
irsend SIMULATE "00000000000005d0 00 LAMP1_ON LAMPS"
irsend: command failed: SIMULATE 00000000000005d0 00 LAMP1_ON LAMPS
irsend: SIMULATE command is disabled
Any idea? Thanks a lot.

User avatar
dannyk96
Posts: 2
Joined: Wed Aug 01, 2012 2:02 pm
Location: Bristol

Re: Controlling 433MHz RF outlets with Android devices

Mon Jan 05, 2015 2:40 pm

I am having trouble getting started.

My existing hardware (Tellstick in a USB port) works fine using tdtool - indeed I have for a while used tdtool with a cron job to automate a pair of HomeEasy switches than control lights.

tdtool via /etc/tellstick.conf does not ask for ant device code '11111' or otherwise.

I have bought off eBay a 433MHz board identical you yours and wired it up on a breadboard.
However I have no idea what to set the '11111' string to.
I have guessed various bitcocdes but to no avail.
What should it be for HomeEasy switches that work using the Tellstick (in my case as 'A1 and A2' house/device codes)
?

darios70
Posts: 3
Joined: Tue Jun 14, 2016 12:42 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Jun 14, 2016 12:45 pm

hi,
is possible to connect ther RF receiver to a 5v rele module? do I need something else to drive the rele module? I'm trying to avoid wired connections to drive the rele module. thanks

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: Controlling 433MHz RF outlets with Android devices

Tue Jun 14, 2016 2:05 pm

@darios70 much easier to buy the whole kit for less than $4, see http://www.ebay.com/itm/191816976973

darios70
Posts: 3
Joined: Tue Jun 14, 2016 12:42 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Jun 14, 2016 2:34 pm

thanks for your suggestion but it's not exactly what I need. I already have two rele modules driven by raspberry gpio through a wired connection and I want to add another one, but I dont have any free space left in the
electrical conduit, so I was looking for a wifi o RF connection. any suggestion?

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: Controlling 433MHz RF outlets with Android devices

Tue Jun 14, 2016 2:46 pm

You say WiFi or IR but I assume you mean RF too?

When you say no space in the conduit do you still have available gpio pins?

Maybe this link is better for you http://www.ebay.com/itm/282005636831 but it looks like you need your own RF transmitter (under $1 from http://www.ebay.com/itm/182033267191 with a spare receiver as you can't buy transmitters on their own, I have tried).

Not really sure what you are looking to do but if you were able to do away with the Pi you could use a $4 WeMos D1 Mini and Blynk. Blynk gives 128 virtual pins plus the digital pins and single analogue port on the WeMos.

Blynk works with the Pi if you don't want to move to the Arduino type WeMos and you get at least 32 virtual pins plus the digital pins etc. With Blynk you can control all your devices locally or via the internet.

darios70
Posts: 3
Joined: Tue Jun 14, 2016 12:42 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Jun 14, 2016 3:52 pm

thanks very much, the the "DC 5V 433MHz Wireless RF Relay Control Switch On/off Switch" was exactly what I was looking for!!!!
I need only a bigger one with more than one rele, mine has 8 rele modules!!!
thankssss

Murphyprecht
Posts: 6
Joined: Thu Sep 05, 2013 11:19 am

Re: Controlling 433MHz RF outlets with Android devices

Mon Jul 11, 2016 12:56 pm

Hi guys, anyone in the UK wanting to try this, Maplin are selling a 5 pack of 3kw 240v RF outlets for just £19.99 currently.

http://www.maplin.co.uk/p/remote-contro ... pack-n38hn

sineverba
Posts: 12
Joined: Tue Jul 16, 2013 3:27 pm

Re: Controlling 433MHz RF outlets with Android devices

Tue Jul 26, 2016 10:10 am

Saw this RFs on Amazon.

One question. Is it possible to use them to control wireless a DS18B20?

Surfing for several days on the net I'm at this point:

1) With the attiny85 we could read the Temp Sensor and transmit the data on the air (via the transmitter of this kit)... OK, but how we can setup the attiny85 without Arduino? Cannot find a tutorial to program the Attiny specifically to read a sensor (and transmit)

2) If you did this in past, can you put me in the right way?

Thank you very much

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: Controlling 433MHz RF outlets with Android devices

Thu Jul 28, 2016 9:04 pm

Murphyprecht wrote:Hi guys, anyone in the UK wanting to try this, Maplin are selling a 5 pack of 3kw 240v RF outlets for just £19.99 currently.

http://www.maplin.co.uk/p/remote-contro ... pack-n38hn
I have ordered my set, thanks.

Anyone using the Maplin units with a Pi or an Arduino?

User avatar
ilovemipi
Posts: 161
Joined: Mon Dec 02, 2013 11:52 am
Location: UK + Cyprus
Contact: Website

Re: Controlling 433MHz RF outlets with Android devices

Thu Aug 25, 2016 6:53 am

A Maplins 5 pack RF socket set was brought to me, from the UK, by a friend yesterday.

Pleased to say that even without putting the 12V battery in the remote control unit my microprocessor can control the 5 sockets independently.

The coding was done whilst I was waiting for the sockets to arrive from the UK and they worked first time.

Plus points:
  • They don't forget their channels and button assignments when they lose power like the Status sockets do
    They remember their ON / OFF condition for a few seconds if they lose power
    16 (4 buttons x 4 channels) independent appliances can be controlled with a microprocessor
    Not too large so you can put 5 side by side on a power strip (taking care not to overload the main socket)
    Rated to 3120W
Minus points:
  • There is no manual control of the sockets, so without a remote control or microprocessor they will not work
    The price has now returned to £29.99 so 50% more expensive than the £19.99 offer price
If anyone sees the discount stores selling these 'old hat' RF sockets perhaps they could post in this thread.

Return to “Automation, sensing and robotics”