When I'm on my way back home from somewhere, I want to be able to switch my AC on a few minutes before I arrive at my apartment, probably by using my phone to connect to my Raspberry Pi on my desk which will, in turn, control the AC. The AC is controllable using an infrared remote control. I want the Raspberry Pi to emit the needed signal.

What do I have to buy for the Raspberry Pi to allow it to send the needed signal? Also, I will need something that will allow me to sample the signal sent by the original remote control, so I could tell the Raspberry Pi which signal to send. How do I do that?

Please note that the only programming language I know how to use is Python. If something requires programming in C or something, it's not a good solution to me.

4 Answers 4


As mentioned above, LIRC is a great software package to get your RaspberryPi sending and receiving IR signals. As of December 2012 the latest Raspbian OS now includes ar0n's LIRC driver.

I wrote a guide to get LIRC installed and configured on your RaspberryPi (from the hardware up) as I had to solve this same issue myself. Once you've got LIRC installed and working on the RaspberryPi you can use some of it's included applications to send and receive IR commands from Python / Ruby / your language of choice.



There is somebody that already has written a LIRC kernel driver for the Raspberry Pi, it can be found here: LIRC Raspberry Pi driver. Also the required hardware and connection schematics can be found on this page.

I haven't experimented with LIRC myself, but there are many applications available that use LIRC, I guess they now all work on the Raspberry Pi.

If you want/need, I can dive into this subject a little more deep and come up with some additional information.

For the Python part, there is a Python module to interact with LIRC, called pyLirc and a newer maintained version called pyLirc2

  • Thanks for the answer, but that page lost me at "Recompile the kernel" :) Isn't there something that's more plug-n-play?
    – Ram Rachum
    Oct 1, 2012 at 18:48
  • 1
    For the time being, until this driver finds its way into a distro, I am afraid that it is the only option for LIRC to work. But there is a GPIO module for python, being a Python programmer, you could create your own Python code to do exactly what you want, using only the hardware shown in the linked page. You need to read what IR sequence the AC remote sends, and replay that. That should be possible using this Python GPIO module.
    – ikku
    Oct 1, 2012 at 20:00
  • 1
    my comment ' ...I am afraid that is the only option for LIRC to work...' is only valid within the GPIO context. The serial/USB etc devices should work without any problem.
    – ikku
    Oct 2, 2012 at 0:32

I've found LIRC to be relatively easy way to send IR messages, but really wanted to be able to control LIRC from java. I like programming in java and didn't find any straightforward tutorial for python to convince me work with it instead of java. After several hours of trying to send IR codes from the pi using java I found the next solution to be relatively simple: Make a bash script that contains the irsend message and tell java to run it.



irsend SEND_ONCE HyundaiFan lightOnOff


public class RunBash {
    public static final void main (String args[]) {
        String cmd = "../toggleLight.sh";
        try {
            Runtime runtime = Runtime.getRuntime();
            Process process = runtime.exec(new String[] {"/bin/bash", "-c", cmd});
            int exitValue = process.waitFor();
            System.out.println("exit value: " + exitValue);
        } catch (Exception e) {

You suppose to get exit value: 0. If your exit value is 127 it means that the bash script wasn't found by java.

Some more notes:

  • I've tried jlirc and lircj - java wrappers for LIRC but wasn't able to configure them currectly -> not working.
  • The only downside of this solution is that you can't listen for IR messages. If someone have any idea regarding using similar method to listen for IR messages I would like to know.

Useful resources:

  • Follow Alex Bain instructions for setting up LIRC for the pi. They are really good! One can find more information regarding irsend here. It makes listing your remotes much clearer.
  • Here you can find the more information for running bash scripts from java.

Hope it helps, Tom


I've always found LIRC more unpleasant project to deal with than seems necessary, much like lm-sensors.

So I'd look at this maybe in a slightly more roundabout way: if you could get a microcontroller (or even an actual remote) to send the correct pulse train when triggered, maybe you could use a gpio pin (or uart message) on the RPi to "push the button", more or less, and trigger the send.

It's relatively plug and play, if you find the right transmitter solution.

Let RPi worry about being a server and a hardware (firmware) module worry about the IR action. Maybe you can use a similar trick to monitor the process status as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.