Raspberry Pi IR/RF - aka PiIr Box
Creating a Raspberry pi with Infrared or Radio Frequency transmitters is nothing new to the scene. There is a lot of documentation out there for doing all kinds of things with these inexpensive transmitters and receivers. Some of the best resourcesI have come across are:
lirc
irrecord
irsend
lircrc
lirc_web
irexec
rfsniffer
rcswitch
send
codesend
nodejs
The goal of this project was to be able to control a large amount of devices from a single interface. These devices could be IR (infrared) or RF (radio frequency). Now although there is a lot of docmentation out there for each requirement individually, there are few places on the internet that compile all of that information in one place, or use it all in one project. I wanted a place to document this as some of this information took me a long time to compile and understand and I want to share it with anyone that is interested.
So in the long run a couple of things needed to exist on the raspi for this to work:
1. A web server that could allow calling commands as though you are in a terminal window
2. An IR interface for capturing and sending IR commands
3. An RF interface for capturing and sending RF commands
For IR commands, lirc_web interfaces with lirc through a webserver built from Nodejs modules. This allows immediate control of IR devices over the web.
For RF commands I am using codesend, which is typically run from a terminal window.
![]() IR LEDsThis is the mock up for the IR LEDs on the bread board. Very early testing stages. |
---|
![]() RF Transmitter/ReceiverFeeling more confident with the RF setup. |
![]() IR ReceiverThis is the LED that allows the Raspberry Pi to learn codes from remotes. |
![]() LED ResistorThe resistor is for the IR LEDs. At one point I had placed a green LED in series with the other LEDs for testing. |
![]() |
1. Breadboard and initial circuits
This was actually two different steps, they are just so similar I decided to present them together.
This is the initial design of the IR circuit, which includes 2x LEDs for sending and 1 for receiving. This allowed me to test irrecord, irsend, Lirc, and Lirc_Web as well as different configurations of LEDs to see what got me the best range.
We also have the RF circuit as well. This, once again, allowed be to test the transmitter and receiver. Range was limited due to antenna length, so i found the optimum antenna length, which is apparently know to be 17.3cm. Codesend and send which are packaged with 433Utils aided significantly while attempting to send commands. RFSniffer also did wonders for receiving.
![]() IRThe inrared circuit board all soldered. I was testing to make sure that it still worked. |
---|
![]() |
![]() RFThis is the soldered circuit board for the RF transmitter and receiver. |
![]() |
2. Miniturized circuit, autostart, and Macros
After the circuit was working on the breadboad and I had a bit of tinker time, I felt like it was a good time to make the circuit a permanent home. I had a few spare parts lying around that I was able to use to make a much smaller version.
A startup script was installed to make the nodejs app start at boot. Also lirc_web has a pretty decent implementation for macros. So I am able to set the lights and turn on the home theater system and get it ready to play a movie with the click of a button.
Side note: I highly recommend using discrete ir codes when creating macros, as it makes the controller feel more natural. For example, most power buttons are toggles, if a person using this toggle from a macro doesn't know that the A/V receiver is already on, and the macro goes to turn it "on", but really turns it off because it is a toggle, that person will certainly not now how to get the rest of the system back in line with itself. With discrete codes, you send a command to turn the A/V receiver on or off. If you send the on command and the system is already on, nothing will happen. The same goes for a discrete off code or any other discrete code you can find.
You can use pronto2lirc to convert the hex codes on this website into usable codes for lirc.
2. Software Software Software!
Outout of the box Lirc allows you to control other types of things beyond IR. As a matter of fact you can make Lirc run just about any command that you can type into a terminal window. With this, I was able to start sending RF (radio Frequency) signal. This was useful for me for a number of reasons. I have 2 remote controlled outlets, one that contols the power of a small entertainment system, and one that controls the power of a larger entertainment system. It saves me about $20 a month on the large system to cut all of the power to the system, so nothing is running in standby mode. It is also really annoying to have to turn all of that crap on everytime you want to watch something. If I could control the outlets with RF using lirc_web, then I could create a macro that turned the RF outlets on, power on the receiver, turn the tv on, changed the receiver to the correct source, and then change the tv to the correct source. Much easier to have this automated than to do it every time manually.
![]() Home page of lirc_webI have heavily modified the original layout of this page. Macros are in yellow, remote controls are in blue. |
---|
![]() Notifications for button pressesThis is an example of a notification when I pressed a macro button. |
![]() Cable RemoteThis is the remote that I have designed for my cable box. Once again this page is modified from the original version of lirc_web. |
I am a little excited about software, as you may be able to tell. I have modified lirc_web to improve its functionality, and its usability. Check out my fork of alexbains git repo here.
The Home Screen:
-
Better utilization of space for buttons and macros.
-
Labeled sections for macros.
-
Mixing types of macros SIMULATE vs SEND_ONCE.
The Remote Screen:
-
3 column layout for most devices.
-
This gives the ability to create a unique layout for each remote.
Other Improvements:
-
Notifications for button presses and macros in floating window.
-
Notifications fade away.
-
Assists in creating macros that are reliable.
After having achieved my original goal of both RF and IR communication, I wanted to start to automate a couple things even further. If you are reading my site, I'd imagine that you know I have a fish tank, and as of the writing of this, the only thing that has been automated on the tank is the lighting. I have a separate room for all of the electrical connections on the tank, this keeps them dry, which is safe! When doing maintenance on the tank it is terribly inconvienient to run to the other room to switch something off, just to have to go back 10 seconds later and turn it back on. So, I picked up 5 more rf outlets for $35 on amazon. I connected 3 of them to the tank, one for the protien skimmer, one for the return pump, and one for the power heads. Yay! now I have full control of everything from my phone. Of course I couldn't leave it there... introducing scheduling!

Next.... garage door opener???
A few notes:
-
lirc_web is capable of sending commands to lirc.
-
lirc has the capability to call custom defined functions upon button presses.
-
With this you are able to send a command such as 'codesend 5592407' from a SIMULATE event in the application irsend.
-
From my research and digging through lirc_web source, lirc_web was unable to send a SIMULATE command without a little bit of modification. lirc_web did have the correct call in its irsend.js file, but the express node server and corresponding JQUERY ajax post command was missing. A few modifications to index.swig, config.json and lircrc file and I was able to create remotes with buttons that controlled RF devices all working from within lirc_web.
Schedules:
-
Set the thing you want to happen (i.e. TurnOn Light)
-
Set a day (i.e. MON, TUE, WED, etc)
-
Set a time (i.e. 17:00)
-
Watch as shit just happens in front of you
-
Schedule Christmas Lights
-
I scheduled my protien skimmer to turn on and off at certain times of the week
-
If you are going out of town, program a schedule to turn on and off some lights or music.
-

4. PiIr Box Case and Positioning
update