Make: Projects

Smart Remote Control

Build this easy universal remote and command all your entertainment gadgets from your smartphone!


Is your remote control collection getting out of control? With a television, cable box, Blu-ray player, and stereo, not only does each remote take up space, but making them work to turn on the right devices and set the right inputs can be very frustrating! You might consider buying a fancy programmable remote control, but they can be expensive and sometimes don’t offer the control or interface you want. This smart remote control project will show you how to build a device that can send and receive remote control codes from a web page. You can program exactly the functionality that you need from any smart phone or computer!

This project uses the Arduino Yún, which is a special Arduino that’s perfect for network-connected devices. The Yún has two processors, one of which runs the Linux operating system and can connect to wired or wireless networks. The second processor is the same as the one used in the Arduino Leonardo. It therefore has great compatibility with Arduino libraries and hardware.


To send and receive remote control signals, this project uses an infrared LED and receiver. Infrared light is invisible to the human eye but easy for electronic sensors to detect. To make the transmission of signals more reliable, devices typically modulate (flash or flicker) infrared light very quickly, so there’s less chance for stray infrared light (like from sunlight) to interfere. An infrared receiver is a small device that can pick up infrared signals modulated at a particular frequency, commonly 38kHz (38,000 times per second). Using an infrared receiver, an Arduino can detect the bits being sent by a remote control. And to play back a remote control signal, the Arduino can flash an infrared LED at 38kHz!

Taking command of your entertainment center is accomplished through a simple web interface which is run locally on the Yún and accessible to most web browsers. The website facilitates basic infrared device control and even allows for multiple commands to be strung together. For example, a ‘Watch Movie’ button might send the control codes to turn on your TV, Blu-ray player, and set the TV to the Blu-ray player input.

This is a moderately difficult project which will require some experience running Arduino sketches and using command line tools. The electronic components for this project are simple and can be easily assembled on a solderless breadboard.



Step #1: Connect Components

Smart Remote ControlSmart Remote ControlSmart Remote ControlSmart Remote Control
  • Connect the infrared LED to the Yún by running a wire from the LED's anode (longer lead on the LED) to the Yún's digital pin 13.
  • Using a 100 ohm resistor, connect to the infrared LED cathode (shorter lead on the LED) to the IR sensor's ground pin (middle lead on the IR sensor).
  • Connect the IR sensor detection pin (left-most lead when looking at front/rounded part of sensor) to digital pin 11 of the Yún.
  • Connect the IR sensor ground (middle lead) to a ground pin on the Yún.
  • Finally, connect the IR sensor voltage (right-most lead when looking at front/rounded part of sensor) to the 5 volt pin on the Yún.

Step #2: Install Software Dependencies

Smart Remote Control
  • With the MicroSD card inserted in the Yún, power on the Yún by connecting the USB Micro B cable to the Yún and a USB power adapter.
  • Make sure your Yún is already setup and connected to your wireless network. If you need help setting up the Yún, check out the guide here.
  • Connect to the Yún command line using SSH. If you're not familiar with how to do this, check out this guide.
  • After you connect to the Yún's command line, it will show the firmware version. This project has been tested and works with BusyBox v1.19.4 dated 2014-04-10 and later. If you're using an older version, you may need to follow these instructions to update your board.
  • From the command line, execute the following command to update the package manager: opkg update
  • Now install PIP, the Python package manager:opkg install distribute && opkg install python-openssl && opkg install python-expat && easy_install pip This process may take a few minutes. You may see some warnings; they're safe to ignore.
  • Create a directory on the SD card to store Python packages: mkdir /mnt/sda1/python-packages
  • Install the Flask Python web framework: pip install --target /mnt/sda1/python-packages flaskYou may see some warnings; they're safe to ignore.
  • Update Python's package search path: echo "export PYTHONPATH=/mnt/sda1/python-packages" >> /etc/profile
  • Create the directories where the Arduino IDE will upload the web server files: mkdir /mnt/sda1/arduino mkdir /mnt/sda1/arduino/www
  • Restart your Arduino Yún to make sure the Python search path is updated.

Step #3: Load Arduino Sketch

Smart Remote ControlSmart Remote ControlSmart Remote ControlSmart Remote Control
  • Download the the IR library. (This library is a fork I created of the excellent Arduino IRremote library created by Ken Shirriff.)

    Unzip the archive, rename the folder from Arduino_IRremote-master to Arduino_IRremote, and import the Arduino_IRremote folder as a library into your Arduino IDE. Check out this guide for more information on installing libraries.
  • Download the Smart Remote Control Arduino sketch by grabbing the zip file from this location.

    Uncompress the archive and drag the SmartRemoteControl folder into your Arduino sketchbook folder. Open the sketch in the Arduino IDE.
  • Compile the sketch and upload it to the Yún over WiFi by selecting the 'Arduino Yún at ...' option in the port list. Make sure to upload the sketch over WiFi so the necessary python scripts are copied to the Yún! Once the sketch has uploaded, open the Serial Monitor in the Arduino IDE. (Be patient, the first upload can take a few minutes.)
  • Aim a remote control at the IR sensor and press a few buttons on the remote. You should see IR code information displayed in the Serial Monitor. If you don't see codes displayed, double check your sensor wiring.

Step #4: Configure Remote Control Codes

Smart Remote Control
  • You can now configure the activities and remote control codes associated with them by editing an XML configuration file. Using a text editor, open the activities.xml file in the www subdirectory of the sketch's folder on your computer. (From the Arduino IDE, click the Sketch menu and then select "Show Sketch Folder.")
  • Notice the format of the example activities in the file. Each activity node defines a name attribute which will be displayed as a button on the remote web page. Within each activity, the codes node contains a sequence of IR codes to execute. The example activity will first execute a Sony A90 command (power on/off) to turn on the TV, and then a Panasonic command (power on/off) to turn on the Blu-ray player. Each code has a string value which is the direct output of the detected remote code from the Arduino sketch.
  • Add your own activities to the file by copying the example and changing the name and codes. While your remote is aimed at the IR sensor, press buttons and carefully record the detected IR code string. Copy the string into the activity code configuration.
  • Once you're happy with the activity configuration, save the file and upload the sketch to the Yún again using WiFi. Each time you want to update the activity configuration, change the file and upload the sketch over WiFi using the Arduino IDE.

Step #5: Start Web Interface Server

Smart Remote ControlSmart Remote ControlSmart Remote Control
  • To run the server, connect to the Yún over SSH. Execute the following command to start the server:python /mnt/sda1/arduino/www/SmartRemoteControl/
  • If the server starts successfully you should see the following text: * Running on * Restarting with reloader
  • If you see an error, check that all the required dependencies were installed in the previous steps.
  • In a web browser, navigate to the URL http://arduino.local:5000/. If your browser doesn't support mDNS URLs (like Windows, Android, and some Linux distributions) instead access http://arduino_ip_address:5000/ where arduino_ip_address is the IP address of your Arduino Yún. The IP address can be found at the bottom of the Arduino IDE when the Yún is connected (image 2).
  • Once the page is loaded, you should see a list of the configured activities as buttons. If you see an error, check that dependencies were installed properly, the sketch was uploaded, and the server is running without errors.
  • To stop the server, press Ctrl-C in the command window where you started running the server.

Step #6: Use Web Interface

Smart Remote ControlSmart Remote ControlSmart Remote ControlSmart Remote Control
  • To use your smart remote control, aim the LED at your electronic devices and press one of the activity buttons. If you don't see all your expected devices turn on, try moving the LED closer to the devices. The range of the LED can be somewhat small, around 6 feet of distance. You can consider adding a transistor to increase the LED range as well. Check out this post for more information.
  • You can also test IR codes by opening the Yún Serial Monitor in the Arduino IDE and sending the IR code as a command. For example, sending "SONY: C A90" (without quotes) would cause the hardware to send a Sony A90 power command. (The "C" above represents the bit length of the command, 12, converted to hexadecimal.)
  • To make the server automatically start on boot, edit the file /etc/rc.local on the Yún (using a text editor such as nano or vi) and add the following line before the "exit 0" line at the end:PYTHONPATH=/mnt/sda1/python-packages python /mnt/sda1/arduino/www/SmartRemoteControl/
  • To use speech recognition, make sure you're running the Google Chrome web browser. Click the 'Speak' button and Chrome should ask for your permission to listen to the microphone. Once you allow microphone permission, say the name of an activity and wait a moment to see if the activity was recognized. For example, to play the 'Movies' activity, click the 'Speak' button, allow microphone access, and say the word 'Movies'. Phrases like 'Play Movies' or 'Run Movies' unfortunately aren't supported — only the exact activity name will be recognized.
  • Enjoy your smart remote control!
Tony DiCola

Tony DiCola

Tony DiCola is an engineer who works at Adafruit Industries and has a passion for making things that use Arduino, Raspberry Pi, and other embedded platforms.

  • StePhan Mckillen

    Im going to built have some questions Im new to python

    i added a to the activities.xml and i can display it in the HTML page

    by doing a {{ activity.img }} ok happy with that so I thought i should be able to go.

    and that would display the image and yes the image is in the same folder as the index.html what manual should i be reading LOL

  • StePhan Mckillen

    Worked it out had to create a folder call static put them there and them use the url_for() function

  • steve

    hello , thanks for your job. i have tried , following all steps, but , when the ir codes are in RAW , the read works fine but the transmission do not works. any idea? thanks a lot. steve

    • StePhan Mckillen

      Hay steve What i would do first look at the ir with the smart phone camera you should see the ir light that should point you down the right track. I have ordered the hardware waiting for it.

      • steve

        hello StePhan,
        i would to say only that in raw not works, the codes received in RAW not work when are sended , as you can try with the serial monitor, take a RAW code in input and than paste the same code (with the string RAW: included) and you find that not works. thanks

        • StePhan Mckillen
          • steve

            Hello StePhan,

            i had read the site you link, but i do not have found any solution. like showed in this site through the project steps, seems that , resend the raw code that you can receive, is the only thing to do to obtain the infra red signal to command all the devices even those that the protocol is unknown (raw). but do not works. i have tried to consider only the code received and pasting into a buffer in the code , to pass to the sendRaw() function , calculating the number of elements and the buffer (38) , but once again it not works. has anyone tryed to use trasmission with raw data? did it work? can you post me some example code? thanks in advance . steve

    • simin

      ya..Intelligent remote control for human comfort is built by humans and is easilyپارتیشنتست جوشکرکره برقی

  • Corey Wright

    I’m stoked! I’m a novice Maker, but I actually successfully built this project to control my LEGO Power Functions motor for a LEGO train. It appears I can only interface with the Yun if it’s on the same WiFi network as the Web Interface. Does anyone know how to configure the Yun to run on a different WiFi network than the web interface? My goal is to control my LEGO train remotely when I’m away from the house. Any help would be great! Thanks!

    • ibnutri

      I haven’t tried arduino Yun. But the idea of controlling your outside your Wifi is by using additional online server that your Mobile phone access. then setup Yun to periodically fetch status from your online server and act based on the status.

      that’s my two cents as a web developer.

  • Javier Traid

    I know some ir conditioner remote controlls send more than one code for each key, is possible to use this project with that type of remotes?

  • Brad

    I’m getting this error and I’m not having luck fixing it.
    Traceback (most recent call last): File “mnt/sda1/arduino/www/SmartRemoteControl/”, line 4, in from flask import *
    ImportError: No module named flask

    • wokanmike

      you got to install again the python files

  • Ola Karlsson

    Hi makers! This is a really cool project. All my media equipment is placed in a large cabinet where the Smart Remote also is placed. But I would like to control my TV set with the remote as well. Is it possible on the the Yún to have more that one ir transmitter so I could place one transmitter outside of the cabinet and based on the activity in the XML send the signal on different pins?

  • Colin

    Hello Makers: Can I use a Iduino Yun Shield for this project instead of the Arduino yun.

  • Norfeldt

    Hi, really cool project. I made it with success!
    I would like to know if there are a place with some more details regarding what is going on under the hood. Would like to know if it would be possible to record new buttons by the website – instead of having to use a PC and upload the .ino once more..

  • Norfeldt

    I have a really stupid telly (Panasonic TV) that requires a really long press on the power button to power on… How do I simulate a long press. I tried to repeat the code a couple of times but no luck.

    • Henry Amador

      i have found that on my devices a long press will the code for the single press then “NEC: 0 FFFFFFFF” repeatedly until i let go i would imagine this is what you would need to put after the desired function instead of repeating the same thing

  • Henry Amador

    Hey Makers :)
    Can anybody please help me?!?
    I got everything working except…
    I don’t know where to find the file refered to as “file /etc/rc.local” to edit it in order to make the server start automatically on boot

  • Vivek Gr

    Hey guys I have tried it. But am stuck in the part where I login in browser using my arduino yun ip address and press movies or any other activity.
    Also when I start my server in Putty, I get restarting with stat, Is that anything to to with it??

    * Running on (Press CTRL+C to quit)
    * Restarting with stat

    • Henry Amador

      If I rememember correctly i did not receive that exact message but it did not give me an error so i continued on to the next steps and it ended up working properly. if your still having trouble give us a better description of the problem otherwise try emailing the author of the project directly he was a big help when i was first building the project