Raspberry Pi interface for 433MHz outlets
A lot of tutorials deal with connecting a 433MHz transmitter to your Pi. However, opening a terminal on your phone to use the command line to switch on a lamp is no fun. What I wanted was to have an app or something on my iPhone to make my phone behave as a remote.
In order to be as generic as possible i decided to use php to create an interface.
What do you need; a working raspberry pi with WiringPi, 433Utils and Apache installed. Other webservers undoubtebly will work too but i didnāt test this on those servers.
The basics for a remote are simple, you need a way to run ācodesendā (433Utils) from a webpage. I use PHP to do this using the PHP shell_exec command like this:
shell_exec(āsudo /home/pi/433Utils/RPi_utils/codesend 123456ā);
a working example:
<?php if ( isset($_POST['remote']) ) { Ā Ā shell_exec('sudo /opt/433Utils/RPi_utils/codesend '.$_POST["remote"].'> /var/tmp/remote.log'); Ā Ā } ?> <!DOCTYPE HTML> <html> <body> Ā Ā <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Ā Ā Ā <button type="submit" name="remote" value="4128960" />on</button> Ā Ā Ā <button type="submit" name="remote" value="4128768" />off</button> Ā Ā </form> </body>
What this does is draw the buttons on the screen. If one of the buttons is pressed the form calls itself but with the parameters. If $_POST has the value āremoteā it will execute the codesendĀ program with the value as defined in the pressed button.Ā
note:
due to the fact that access to the gpio pins requires root privileges you have either to grant apache root privileges or you will have to add codesend to the /etc/sudoers file (more).













