I'm using these items:
- Receivers ON-OFF to control my lights (you typically put a device in the walloutlet or instead of the walloutlet). They work in the 433 MHz band (ISM).
Out of the box you have a remote control which sends a signal to the receiving device and switch it on or off.
In my case, I created this situation:
- Created an HTML site on my Raspberry Pi (
- I call that page on my smartphone
- On the page are four buttons (I control four devices / lights)
- When I click a button, it asynchronously fires a call to
/switch.php (the .php is on the Raspberry Pi)
switch.php calls a
switch.py program which controls the 433 MHz
sender (see below)
- The 433 MHz sender does the same thing as the out of the box remote
This is the sender, that is, the replacement for the standard remote control:
433 MHz Wireless Transmitter Module Superregeneration for Arduino
I also created a scenario for out-of-house use.
I didn't want to connect my Raspberry Pi via my homerouter directly to the Internet, so I built myself another webpage (at my own domain) which does not control the Raspberry Pi directly, but it sends an email to a (known only to me) email (Gmail) address.
The Raspberry Pi checks that email account every 10 minutes to see if there is any email. In that email I for instance say A on or B off.
So when we get home late and the lights are already off, we navigate to the site on my mobile (plans are to make it an Android app), click the button, the page gets posted and at the server an email gets sent, and in the next 0-10 minutes the Raspberry Pi checks the email, sees four new emails (A on, B on, C on and D on) and switches the lights on.
How to get started
So, to get started, these are the things I've done to get it all working.
In my case, I programmed the control of the 433 MHz sender in Python (which is an easy language if you already know how to program).
First you install the
This library is used to control the little pins on your Raspberry Pi from your Python script. See Install RPi.GPIO Python Library.
Then you can optionally read the article Tutorial: How to use your Raspberry Pi like an Arduino, it's about what you can do with the
rpi.gpio library, for instance blinking LEDs.
It's not mandatory for the Elro light switching however.
Then you get the awesome code for the Elro commanding by HeikoHeiko, at http://pastebin.com/aRipYrZ6. You paste that code in a file named '
You then change the string on line 94 to your own jumper settings (as you have set in your remote control and the walloutlet device. Check wether the combination remote-walloutlet device works before trying it with the Raspberry Pi. If it doesn't work with the standard components, it will probably fail with the Raspberry Pi too).
You then change the number of the pin your sender is attached to on line 97.
The pin number can be gotten from RPi Low-level peripherals and in File:RPi P1 header.png.
You have to use the 1..26 count (the black image), not the GPIO34, GPIO24, etc. (green image).
Then you type this on the command prompt:
sudo python switchelro.py 2 1
which means 'turn on B' (following this schema:
A = 1, B = 2, C = 4, D = 8, E = 16 for the first number, and 1=on, 0=off for the second).
I changed the
repeat = 10 on
line 30 to
repeat = 20 in the beginning (I don't remember why) and that works. I never retried it with the setting '10'.