loading

Remotes are everywhere. They are the interface to your TVs, music systems and what-not. You probably have a few spare ones lying around, devastated at the demise of their better halves. Cheer them up and put them back into use! (Skynet approves...)

Here are some reasons why you should implement or emulate remotes in your projects (there is really no need to write down any reasons, but the things is, I really like lists):

  • if you need to hide your project someplace and need to operate it covertly like spy devices.
  • if project will be installed in some inaccessible or high reaching place like DIY overhead projector, bird house water supply, etc...
  • if you need to remove all those ugly buttons on your project enclosure.
  • if you want to control your remote-controlled devices like TV with an Arduino or Raspberry Pi.
  • if you want to survive the singularity (earn brownie points with Skynet while you still have a chance)
  • because remotes are cool

In this instructable, I'll show you how to: (Warning: Another list follows)

  • Using Arduino:
    • read remote signals using interrupts, so you can do other stuff on your Arduino while waiting for someone to press that button. Also interrupts will get the most accurate timing data.
    • decode remote codes to identify individual buttons without overflowing your memory. Usually saving a few button's IR codes will fill up your Arduino's memory...
    • recreate IR signals for any of your remote's button super easily. Control your TV with an Arduino!
  • Using Raspberry Pi:
    • read IR signals and implement it in your Python scripts. Play games with remotes!
    • recreate IR signal using Raspberry Pi. Make a universal remote control.

Note: Since posting this instructable, I've discovered Shirriff's IR library for Arduino and I suggest that for the Arduino part of this instructable as it's extremely easy to use. But if you want to understand how IR really works on those remotes, the instructable will provide a good read. Maybe if I get some free time, I'll add steps for Shirriff's IR library: https://github.com/shirriff/Arduino-IRremote

Step 1: Go Get Stuff

What you need depends on what all you want to do. Still the list is quite short:

  • IR sensor (adafruit link)
  • IR LED (adafruit link)
  • Arduino or Raspberry Pi
  • NPN Transistor PN2222
  • 1K ohm resistors
  • 220 ohm resistor
  • Some connecting wires
  • Of course, a remote control
<p>Hello, I am following the tutorial and I have managed to put the codes of two controls in the same file, but I have an air conditioner that I can not record the codes, it is a daitsu DS-18UIM, can you help me?</p>
<p>You will have to be a bit more specific why you are unable to record it. Are you able to get any pulse-space readings with <strong>mode2 -d /dev/lirc0</strong>?</p>
<p>Hello, sorry for being so brief, with the command you say, I read the impulses just like with the television remote, when I have problems is when I save it in the configuration file, apparently, at that time does not read well , I have read for other websites that the controls of the arie conditioning works differently to the televisions for example</p>
<p>AC remotes send values like temperature, fan speed etc. which is encoded into the signal which might be causing LIRC irrecord to find any pattern.</p><p>You can set LIRC for reading specific settings(like 25 degrees) which I'm pretty sure it will be able to record. Before recording, set temperature to 24 degrees on remote. Then during recording, increase it to 25 degrees. When it asks for multiple key presses during recording, just cover the remote's IR led and set temperature back to 24 degrees (so LIRC doesn't detect the code for 24 degrees). Then uncover the LED and increase it to 25 degrees again.</p><p>That's a laborious process but I think it should work and you can record IR code for a few commonly used values.</p><p>You can also try out this instructable specifically for decoding AC remotes using LIRC: <a href="https://www.instructables.com/id/Reverse-engineering-of-an-Air-Conditioning-control/">https://www.instructables.com/id/Reverse-engineeri...</a></p><p>It's a bit technical and decodes the pulse-space pair values to get the IR codes similar to what I did with the Arduino version.</p>
<p>Hello! I was amazed by your tutorial, I&acute;ve found it after several days of research.</p><p>Now I am concern because for some reason the IR signals are not save at the lircd.conf file. I mean, I finish the process of recording, and the final leyend is &quot;sucessfully written config file&quot;, </p><p>but, I have this message just before finishing recording. </p><p>&quot;checking for toggle bit mask, and then No toggle bit mask found&quot; (please see the attached image)</p><p>when I open the file there are no codes.. </p><p>Do you have any idea? Maybe I am missing something, please if anybody could help me I will really thankfull!</p>
<p>Hi, remember to press different buttons and no more than one second each</p>
<p>A few remotes toggle a few bits of data every time you push a button. So if in the first push it sends 01110110 and it toggles the last 2 bits on every push, in the next button press it will send 01110101 and again 01110110 for pushing that same button again. So toggle bit mask is used to just check for those bits by making you press the same button multiple times. That is nothing to worry about if no toggle mask is found.</p><p>It has been a long time since I used LIRC last and I might be wrong, but as far as I can remember, it takes only valid button names during irrecord. Your button names seem to be non-valid as valid ones I used were in all CAPS. You can generate a list of all valid buttons using(given in step-9):<br><em>irrecord --list-namespace</em></p>
<p>thank you very much Antsy! It finally works Now I am dealing with lirc_web.. </p>
<p>Amazing instructable! I could do everything really easily until step 9 were I got stuck every time I write mode2 -d /dev/lirc0 it comes up with</p><p>mode2: could not get file information for /dev/lirc0</p><p>mode2: default_init(): No such file or directory</p><p>Do you know how I could fix this?</p><p>Thanks</p>
<p>Which Raspberry Pi are you using? If using Raspberry Pi 2 or 3, use buda.suyasa's tip I've mention at the bottom of Step-8 and edit /boot/config.txt.</p>
<p>The best ir tutorial i have found. Thank you so much! <br>i only tested the raspberry part. But this is very great.<br><br>P.S. there exists ir transmitter and ir receiver which already contain the transistors and resistors. For beginners i can recommend this ones.<br><br></p><p>https://www.amazon.de/gp/product/B01FSY62UE/ref=oh_aui_detailpage_o02_s00?ie=UTF8&amp;psc=1</p>
<p>Hey! I&acute;ve got a question I bought the same package as you but it seems that the range is somehow only a few meters? Can you confirm that? For me it does not make any sense as in my understanding the light would travel further anyways... And I mean the signal length does not change over a longer distance otherwise my remote for the lightbulb would not work either..... <br><br>Maybe you have some insight for me?<br><br>Thanks in advance!</p>
<p>The circuit could be same as Sword_xx's but components could be different. Some IR LEDs throw light in all directions (like a light bulb) so you can aim a bit off target and it would still wor,k but don't work for long distance. Another kind has a focused beam and you have to aim it at the receiver to work, but since all light is concentrated in one direction, it will work from farther away.<br>There could be other reasons as well such as transmitting power, ambient IR light, receiver sensitivity etc. If you want to increase distance, replace the IR LED with one that has a better specs or use multiple IR LEDs.</p>
<p>Hey! I know the problem now. It seems that the lightbulb&acute;s light is interfering with the signal! When I have my bulb on the lowest mode it works a treat! I have to play with the angles..</p><p>Thanks, though!<br><br>Bests from Germany</p>
<p>That is a great find. Using those ready-made boards certainly saves a lot of time and trouble in putting together the circuit, especially for beginners.</p>
<p>Thanks. I got the ir send working using your code but it did not repeat every minute as you stated above:&quot;This code will send the IR signal on reset and then after every minute.&quot;. Looking thru the code I cant see this kind of code either? I want the IR to send every day at same time roughly for 5 days. Could I adjust such a delay from one minute to 24 hours? Where or what is the code? I can only spot a 1000ms dely in code?</p>
<p>For scheduling tasks, you should use cron to run the IR code. You can start off from here:</p><p>https://www.raspberrypi.org/documentation/linux/usage/cron.md</p>
<p>I'm getting an error saying <br><br>'File &quot;slidepuzzle.py&quot;, line 9, in &lt;module&gt;</p><p> import lirc</p><p>ImportError: No module named lirc'<br><br>Have gone through the set up. Unsure what could be wrong. :(</p>
<p>There are 2 versions of Python (2 and 3) on Raspi. Try with both. Will probably work with one of them.</p>
<p>I used this and it worked. <br><br>sudo apt-get install python-lirc</p>
<p>Thanks a lot for this instructable, using the IR_Reading.ino sketch <br>provided and some others info form other website, I succesfully decode <br>my Panasonic AC (without heater, for Indonesia market).</p><p>I have to <br>increase the number of pules pair in the sketch to 240, because it turns<br> out my Panasonic AC use 216-bit protocol, for total around 220 pulse <br>pairs, to be able to record the complete signal.</p>
<p>Hey guys. I have some weird situation. Everything seems to be working fine but when I do mode2 -d /dev/lirc0 I get lots of vaues even though I'm not pressing any buttons on any remote. Do you have any idea why that happens?</p><p>Thanks!</p>
<p>Check if the connections are proper. Could be a fluctuating voltage level due to a loose connection. Also try covering the receiver to see if the random values stop(could be another source in the room).</p>
<p>Your tutorials are very noob friendly. Thanks for that. Instant follow. </p>
<p>Hi Antzy,</p><p>congratulations to this great tutorial! </p><p>I wanted to control my python prog on a RPi with a remote control. LIRC worked fine so far, with &quot;irw&quot; I could see all my button presses as output on the screen. </p><p>For use with python I also had to install python-lirc, right?</p><p>But whenever I start my python prog I get this error:</p><blockquote>lirc.InitError: Unable to load default config ~/.lircrc or /etc/lirc/lircrc</blockquote><p>although there is a lircrc file in /etc/lirc/</p><p>This now looks like this (for a first test)</p><p>/etc/lirc/lircrc:</p><blockquote>begin<br> button = KEY_CHANNELDOWN<br> prog = lcdtest2<br> config = CHdown<br> end</blockquote>
<p>That's peculiar. Did you put the spaces or tabs exactly as the format in the default lircrc file? You can see the spacing demo under the &quot;The <em>lircrc</em> file format&quot; section on this page:</p><p>http://www.lirc.org/html/configure.html</p>
<p>Solved it </p><p>and yes, it was something stupid as I expected:</p><p>I created the lircrc on a windows machine and copied it to the raspberry. So there was the problem with the different text file formats. After running </p><p><em>dos2unix /etc/lirc/lircrc</em></p><p>it worked!</p><p>Cheers,</p><p>humpri</p>
<p>Many thanks for your quick response! And for the link. Unfortunately it didn'thelp, neither with tabs nor with spaces. I guess its probalby something really stupid. I will let you know when I have solved it!</p>
<p>Hi Antzy,</p><p>I made this using Raspberry Pi, its amazing. Very excellent tutorial and keep post such kind of tutorials. Also I've used different component for this experiment and its works fine. The lists are followed.</p><p>1) 2N2222 Transistor</p><p>2) 220 ohm resister</p><p>3) 1K resister</p>
<p>Great! I had recommended the same values to buda.suyasa in the comments below. I used the proper values while experimenting(zoomin into the image shows that) but somehow got the incorrect resistor values in the instructable. I've fixed it now everywhere in the instructable,<br><br>Thanks for trying it out and pointing out corrections... :)</p>
<p>Hey Anzty and Ravicmca, i have tried with 220 ohm and 1k resistor. Works like a charm! Thanks!</p><p>But in my case, irrsend ONCE doesn't seem sending any signal (even IR Led lighted up). I tried with irrsend START and it's successfully transmit the signal. Do you have any idea why irrsend ONCE not working? </p>
<p>Glad it worked out for you! :)<br>The reason </p><p><em>irsend SEND_ONCE samsungTV KEY_VOLUMEUP</em><br>isn't working is maybe because your receiver(TV?) is expecting the signal to be repeated twice or more to detect. SEND_START keeps sending the IR signal repeatedly till SEND_STOP is sent. So that's why that was working. Try using sending the signal multiple times:</p><p><em>irsend --count=2 SEND_ONCE samsungTV KEY_VOLUMEUP<br><br>It will send the same IR signal twice. Try experimenting by increasing to --count=3 if 2 doesn't work.</em></p>
<p>Great! Thanks Antzy.<br>While i tried your tutorial, I face some another problems. It's because of different version of Raspberry Pi. I use Raspberry Pi 2. So some configurations need to change and i need to run rpi-update to make it work. Luckly, i found some links that solve my problem. Please take a look to links bellow. Maybe you need to add this to your tutorial and help someone later.</p><p><a href="https://disqus.com/home/discussion/alexbain/setting_up_lirc_on_the_raspberrypi_alexbain/" rel="nofollow">https://disqus.com/home/discussion/alexbain/settin...</a><br><a href="https://www.raspberrypi.org/forums/viewtopic.php?t=103320&p=714687" rel="nofollow">https://www.raspberrypi.org/forums/viewtopic.php?t...</a></p><p><a href="http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i%C2%B2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f/27074#27074" rel="nofollow">http://raspberrypi.stackexchange.com/questions/270...</a><br></p><p>Thank you very much Antzy, you've helped me a lot!</p>
<p>Really happy it worked out for you. I'd like to add the solution for RPi2. The links you posted have multiple questions and multiple solutions. Can you please explain what was the problem you faced and the solution you took for it?</p>
<p>To make it works, i did the following.<br>1. Upgrade RPi2 firmware to newest version &gt;&gt; sudo apt-get update, sudo apt-get upgrade, sudo rpi-update, sudo reboot (need to upgrade the firmware to make transmit/irsend function work)<br>2. Because of newer firmware make lirc break, in /boot/config.txt, add &quot;dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17,gpio_in_pull=up&quot; ( IR receiver/sensor won't work without &quot;gpio_in_pull=up&quot;<br><br>That's all. :D<br></p>
<p>I also found the /boot/config.txt change was needed. Would be great if it was added to the instructions!</p>
<p>@<a href="https://www.instructables.com/member/marcinzukowski" style="">marcinzukowski</a>, as far as I remember, there was no need for any change in the /boot/config.txt file. That file contains mostly display related stuff related to HDMI output and overscan values. Where and what did you need to put in there related to LIRC?</p>
<p>I had to add what @buda.suyasa mentions above, in my case:</p><p> dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17</p><p>If I didn't have it, lirc-rpi module wouldn't load.</p><p>I have Raspberry Pi2 model B, hope that helps.</p>
<p>Ah thanks for reminding me to add that. I've added the instructions to step-8.</p>
<p>Hi buda.suysa</p><p>Have you got any error message while you try with SEND_ONCE?</p>
<p>Hi Ravijmca, thanks for fast reply.<br>No, i have no error while try with SEND_ONCE. I tried to transmit the signal to a TV. </p>
<p>Thank you guys. I've just bought 220 resistor, it will arrive tomorrow. I will try it tomorrow. I will let you know when it works.</p>
<p>Hi, is it possible to emit signals from pi and receive it in arduino ? has anyone tried ?</p>
<p>Haven't tried it but I think that should work without much problem. </p>
<p>Hi, I followed the steps until recreating the signals by using Arduino, I am able to received the C array and IR sent decoded value in the serial monitor, but yet the TV isn't being control ? Did you all face the similar issues ?</p>
<p>To control a TV, you have to follow the instruction in step-7 after getting the values from the remote. You can check if anything is being sent by looking at the IR LED using a camera.</p>
<p>Ya, I followed the instruction in Step-7, is it only using 1 set of formatted C-array? Or I have to get different set of C-array for respective buttons?<br>Thank you for your reply anyway.</p>
<p>Every button will have different values for the array. Usually only a few values will change and most of the other values will remain the same. If you have the need to emulate multiple remotes, you will need to go through steps 4-6 and understand which all values are changing and how to decode them to write a code which will send signals for different buttons. You could also use Shirriff's IR library which is very easy to use if it reads your remote.</p>
<p>Thanks to your sketch and tutorial I managed to get feedback from the arduino, however I noticed that i do not get the same values even though I am pressing the same button of the remote controller.....is it normal?</p>
<p>That shouldn't happen. Try looking for patterns in your values and match them. How many different types of values do you get? Some remotes send the pattern once and then send the complement of the bits the next time.</p>

About This Instructable

120,726views

183favorites

License:

Bio: I'm programmer and an electronics hobbyist. I try to find that point where software meets hardware meets art. "Necessity is the mother of all ... More »
More by Antzy Carmasaic:IoT Time Warp Dali Clock Pure White Background Photography Using Smartphone Rainbow Roller 
Add instructable to: