Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

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.

http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/

share|improve this answer
1  
Today I wrote a new blog post describing the schematic (and parts I purchased) to build a RaspberryPi IR transceiver. alexba.in/blog/2013/03/09/raspberrypi-ir-schematic-for-lirc –  Alex Bain Mar 10 '13 at 1:43
add comment

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

share|improve this answer
    
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 '12 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 '12 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 '12 at 0:32
add comment

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.

share|improve this answer
add comment

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.

Example:

toggleLight.sh

#!/bin/bash
irsend SEND_ONCE HyundaiFan lightOnOff

RunBash.java

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) {
            e.printStackTrace();
        }
    }
}

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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