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.

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 documentation 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 an admin.
  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.

Some of the best software already available for any Linux machine that can interface with an IR port or an RF transmitter:

  • lirc
  • irrecord
  • irsend
  • lircrc
  • lirc_web
  • irexec
  • rfsniffer
  • rcswitch
  • send
  • codesend
  • nodejs

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. This, once again, allowed me to test the transmitter and receiver. Range was limited due to antenna length, so i found the optimum antenna length, which is 17.3cm. Codesend and send which are packaged with 433Utils aided significantly while attempting to send commands. RFSniffer also did wonders for receiving.

First Prototype, autostart, and Macros

After the circuits were working on the breadboard 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 know 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.

3. Software Software Software!

Out 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) signals. This was useful for me for a number of reasons. I have 7 remote controlled outlets, one that controls the power of a small entertainment system, one that controls the power of a larger entertainment system, 1 controlling a stereo in the garage, 3 that control aspects of my saltwater aquarium, and 1 connected to a light. By cutting all of the power to the main entertainment systems, nothing is running in standby mode, literally no power is being consumed. I can only imagine that the electricity bill is being reduced. It is also really annoying to have to turn ALL of that equipment on EVERY time you want to watch something. If I could control the outlets with RF using lirc_web, then I could create a macro that turns the RF outlets on, powers on the receiver, turns the TV on, changes the receiver to the correct source, and then changes the TV to the correct source. It is much easier to have this automated than to do it every time manually.

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 and 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 inconvenient 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 RF outlets for $35 on amazon. I connected 3 of them to the tank, one for the protein 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!

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.

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 on lirc and  lirc_web, 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.