---
title: 'IR-Remote Control 4.0'
url: 'https://www.niklas-stephan.de/en/blog/ir-remote-control-40'
markdown: 'https://www.niklas-stephan.de/en/blog/ir-remote-control-40.md'
lang: en
date: '2022-12-03'
description: 'IR-Remote Control 4.0 A universal remote control? More 90s than this is not possible! But what if the old infrared remote could switch all lights in the room on and off, control the heating or the blinds, and steer the home cinema at the same time? This post has it all, because in this way every s…'
taxonomy:
  category:
    - smart-home
  tag:
    - ir-remote
    - home-assistant
    - hardware
---

# IR-Remote Control 4.0

   3rd Dec 2022   [ir-remote](https://www.niklas-stephan.de/en/blog/tag:ir-remote#body-wrapper) [home-assistant](https://www.niklas-stephan.de/en/blog/tag:home-assistant#body-wrapper) [hardware](https://www.niklas-stephan.de/en/blog/tag:hardware#body-wrapper)  

![](https://www.niklas-stephan.de/images/5/2/1/9/a/5219a1d98f9f6de96be2acceb94a8159338ed1e4-01-ir-remote-teaser.webp)

A universal remote control? More 90s than this is not possible! But what if the old infrared remote could switch all lights in the room on and off, control the heating or the blinds, and steer the home cinema at the same time? This post has it all, because in this way every somehow readable/connectable device can be integrated into your Alexa, HomeKit, or nearly any other smart home solution! All of this without subscriptions, hidden costs, and – if you want – entirely without the cloud of any big corporation.

![](https://www.niklas-stephan.de/user/pages/blog/ir-remote-control-40/02-ir-overvall.webp)

## Goal

In this small build guide I describe how I assembled an IoT (Internet of Things) scenario from several components. A basic technical understanding helps to follow the individual steps, but an IT degree or a similar education is definitely not required!

The goal is to trigger various actions in a smart home with an ordinary (preferably from the lowest price segment, or even better: electronic waste) infrared remote control. Starting from a simple hardware environment, I want to pass the input values of an infrared signal to my home automation when it arrives.

As hardware we use the little brother of the world-famous Raspberry Pi, the Zero W, and little further accessories. All of it can also be used without effort for other purposes. Thanks to the thousands of available "DIY guides" on the net, a possible new purchase is by no means wasted.

For the software I choose, as always, as exclusively as possible open-source sources, such as Linux and Node-RED. The gigantic community behind it provides us 24/7 support for any kind of problem.

## Hardware

Really nothing more than described in the goal is needed. If you don't have the components lying around, here are first a few purchase recommendations.

![](https://www.niklas-stephan.de/user/pages/blog/ir-remote-control-40/03-pizero-kit.webp)

From around €16 there is the smallest computer, Raspberry Pi Zero W, with matching case, e.g. here: <https://www.berrybase.de/raspberry-pi/raspberry-pi-computer/kits/raspberry-pi-zero-w-zusammenstellung-zero-43-case>. The Zero is particularly well suited for our purpose because, on one hand, we don't need particularly large performance and, on the other, we want to save power – since we plan continuous operation. With a voltage of 2.3 to 5.0 V and a current of 100 to 140 mA, the actual power consumption should lie between 0.23 watts and 0.7 watts. That is less than some television "eats" in standby. That may all sound super "cheap", tiny and weak, but: it is 2021, and this bit of hardware has the same computing power as a top home computer shortly after the turn of the millennium. And we don't want to install Windows XP at all…

For the Raspberry to work, power is still needed, ideally from an old mobile-phone power supply with Micro-USB connection. If none is available just now, you can get such something everywhere for a few euros, e.g. also in the supermarket. In addition there is a Micro-SD card, which perhaps also still lies around somewhere at home. Everything from 8 GB size is OK, it should just have the addition "XD" or "HC" so you are sure not to use a "sluggish duck". It starts at around €3, and here too you will find something in most supermarkets.

A small adapter cable helps us connect devices with a normal-size (type A) USB connection – such as the infrared receiver – to the Raspberry Pi Zero. That again you will rarely find in the supermarket, but e.g. here: <https://www.berrybase.de/raspberry-pi/raspberry-pi-computer/kabel-adapter/usb-kabel-adapter/usb-2.0-hi-speed-otg-adapterkabel-a-buchse-micro-b-stecker-0-15m-wei-223>. And with that you are €1.80 poorer. Anyone who now has none of these components at all can also get a complete set, e.g. here: <https://www.berrybase.de/raspberry-pi/raspberry-pi-computer/kits/raspberry-pi-zero-w-zusammenstellung-full-starter-kit>

To later write the operating system onto the SD card, we still need an SD card reader. Most laptops have one integrated. If not, they are also available cheaply from €5 almost everywhere, e.g. here: <https://www.heise.de/preisvergleich/sandisk-mobilemate-single-slot-cardreader-sddr-b531-gn6nn-a2356696.html>

![](https://www.niklas-stephan.de/user/pages/blog/ir-remote-control-40/04-flirc.webp)

With the remote you have the choice of many options. Really any kind of device that sends an infrared signal comes here into question. Naturally you should not take one that belongs to an actively used device in the same room – but that hopefully goes without saying. I used an old universal remote that I still had left over. With that I made it for myself a little tick harder than necessary, since I now had to preset it to a non-existent receiving device. It would have been simpler to really use a completely "normal" one.

Finally the infrared receiver. That is actually almost the biggest investment in this project. I still had the FLIRC USB receiver, qualitatively high-quality and coming with a clever software solution. You can get it e.g. here: <https://www.heise.de/preisvergleich/flirc-usb-rev-2-flirc-v2-a1621664.html>, from around €24.

All in all, then, an investment between €0 and a maximum of €65.

## Software

Now to the at least for beginners complicated part – but after all: much software is not needed. Actually only an operating system and two additional programs/tools. Since the remote is easiest to configure via a desktop environment, we install this on our SD card. That works nowadays maximally easily. At <https://www.raspberrypi.org/software/> there is the program "Raspberry Pi Imager", which you can download there for your operating system. Before opening the downloaded and installed program, you insert the SD card into your SD card reader or slot. In the program you then select the operating system "Raspberry Pi OS (32-bit)" and as SD card yours. With one click on "WRITE", the operating system is copied onto your card.

Once the process is complete, please do NOT remove the card yet. Because we want to do two things beforehand that make life easier afterwards. If it was already pulled out – out of impatience or whatever reason – that is also no problem: just put it back in. First we create in the root directory of the SD card a file, gladly also empty, named "ssh". Please make sure the file has no hidden extension such as ".txt". That readily happens under the standard settings of Windows. Mac and Linux users usually don't have this problem. For whoever this is described too imprecisely, please look here: <https://www.shellhacks.com/raspberry-pi-enable-ssh-headless-without-monitor/>.

Now we immediately want to provide the connection data for our WLAN so that the network connection is assured from the start. For that we place a second file named "wpa\_supplicant.conf" in the same directory. Windows users watch out again at the file extension. This time, however, the content of the file matters:

```bash
country=DE

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network={
    ssid="DerNameDeinesWLANs"
    psk="DeinWLANPasswort"
    key_mgmt=WPA-PSK
}
```

That is only an example, and we must set the values in the brackets at the lines "ssid" and "psk" to the values of our WLAN.

Now we are done, however, and the card can be removed and put into the Raspberry. Now assemble all components and bring the whole thing to its place of destination. Once you have connected the device to the power supply, you see:

### At first not much.

No reason to panic, that is normal, and you have probably done everything right. We simply continue.

We are now able to log in to the little Raspberry via SSH to set a few things there. To get our fingers dirty briefly at command-line level we unfortunately cannot get around it – and unfortunately, in the case of the Raspberry Pi Zero, Visual Studio Code cannot be used for that either. A terminal must come.

Under MacOS and Linux a terminal application for the command line has always been built in and is called that there too. As far as I know, the SSH command is also available in Windows 10, but unfortunately I cannot test that just now. Google gladly helps anyone not familiar with it. We then establish the connection to our new smallest computer as follows:

```bash
ssh pi@192.168.178.22
```

The IP address naturally has to be adjusted to that of your Pi. You get that fastest via the web interface of your router. The default password, when you are now asked, is "raspberry". If you want to change it right after logging in, that works with the command "passwd". It is advisable to regularly bring the operating system and software up to date. You do that with the commands:

```bash
sudo apt-get update
```

to determine currently available packages; these are then installed in turn with:

```bash
sudo apt-get upgrade
```

Now we install Node-RED with the command:

```bash
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
```

And since we're already at it, we also determine that Node-RED is started automatically at every system start:

```bash
sudo systemctl enable nodered.service
```

Now we best restart the system once. That works with:

```bash
sudo reboot
```

After at most 3–4 minutes everything should be up again, and we should be able to access Node-RED via the browser of any device in your network:

```
https://192.168.178.22:1880
```

Here too: replace the IP address with that of your Pi. If the web interface of Node-RED now opens, we can celebrate our first success. We have made a powerful IoT tool out of our little Pi!

Now we want to set about configuring our remote. For that we must once again trouble the command line and switch to the Pi as described before. First we check whether the desktop of the Pi will be available to us later. How that works is perfectly described here: <https://www.raspberrypi.org/documentation/remote-access/vnc/>. Focus on the section "Enabling VNC Server at the command line" there; the rest we can ignore for the moment.

Also at command-line level we install the graphical interface for our Flirc infrared receiver. That works with (copy & paste):

```bash
curl apt.flirc.tv/install.sh | sudo bash
```

Now we have everything together that we need and can finally begin with the real fun.

## Configuration

Compared with the software installation, the actual configuration is now a "breeze".

In the first step we teach our remote. For that we switch via VNC to the desktop of the Raspberry Pi Zero. There we open the program Flirc, which we find in the start menu. Before it starts, we still switch the view to "Keyboard". Through that, already without key combinations, more than 127 commands (keys) are available to us that we can assign on our remote. Since we will never connect a real keyboard to the Pi, the only thing we must watch out for is that we don't assign special keys. So assigning the "Print" key is not a good idea; all numbers and letters: no problem. To start the assignment, we click in the program on one of the displayed keys, e.g. "F". We are then prompted to hold our remote toward the infrared receiver and also press a button on it. We play through this procedure for all buttons on our remote that we want to back with an action later. Now our remote is "learned", and we can end the VNC session again. The FLIRC program can also be ended beforehand; it continues running in the background, and our commands remain available also after a restart.

From here Node-RED may now show what it can do. And the program makes it maximally easy for us! We again open in the browser of any device of our network the Node-RED GUI:

```
https://192.168.178.22:1880
```

Our flow needs only two nodes from the "standard assortment". First we drag a "rpi – keyboard" node from the left bar into the flow. It does nothing other than – as the name lets one guess – listen for keyboard input at the Pi. Through our configuration of FLIRC it thus automatically also listens for the inputs of our remote. Anyone who wants to test it or simply see whether it works inserts a debug into the flow and connects it with the output of our "rpi – keyboard" node. After one click on "Deploy" top right, after each press on the remote onto a learned button a message should now appear in the debug window. So far, so good.

Now we want to connect with the outside world. For that the most varied possibilities are available for selection. So we can already write the events with Node-RED's built-in means into a file, couple them with a web-service call, or also transmit a message over a websocket. Also MQTT, TCP, UDP and even serial output are open as transmission possibilities in the standard. With that actually every wish should already be covered; but even more comfort for integration into existing smart home networks comes through optionally installable modules. So we make our setup, with the module "node-red-contrib-homekit-bridged", e.g. a HomeKit device according to Apple standard. The same works also with openHAB <https://flows.nodered.org/node/node-red-contrib-openhab3> or even Alexa <https://flows.nodered.org/node/node-red-contrib-virtual-smart-home> – and actually everything that exists on the market and communicates over a network. I personally decided for transmission via websockets without additional module.

---

### Hold on, stop! Why websockets all of a sudden now?

In my first build I had tried to transmit the commands of the remote via a "normal" API. That works just as splendidly, but is too slow! When pressing a button on a remote, everyone expects an immediate reaction or action. 1 second of delay feels unnatural, 2 seconds are already unbearable. Imagine you want to increase, for example, the volume of the television bit by bit. Very quickly I pressed 20 times or more, and the API commands are processed slowly. That way you work successfully on hearing loss. Everyone who is playing mental cinema right now: yes, exactly so it happened to me…

I want to protect you from similar experiences, and therefore we go directly to websockets. Without wanting to go deep into the fundamentals of computer science: websockets are an inter-process communication (IPC) over the HTTP (web) protocol. Formulated differently: with websockets we build a tunnel between two or more devices for real-time communication. Exactly what we need here!

---

The second node we drag into the flow is thus a "Websocket out" from the network area. On that, in turn, a "Websocket in" in my home automation solution listens, which is likewise realized with Node-RED. If you use another system for home automation, the input of the "rpi – keyboard" node would have to be forwarded to the corresponding module. That is exactly how, as announced in the introduction, any other device can be integrated into your IoT.

## Conclusion

In our small experiment we playfully created a useful extension of our smart homes out of an old infrared remote. Since our Pi Zero consumes only little power, theoretically a power supply via a battery or a power bank would also be conceivable, whereby the whole setup would even become mobile.

One or the other "professional" will have railed about why I installed a desktop environment on the small Raspberry Pi Zero instead of foregoing it for the sake of the limited resources. I tried that, and teaching the remote via FLIRC in that way made plentifully little fun. Besides, htop tells us that on the Pi even with running desktop only about 100 of 512 MB of memory are occupied.

I hope the article was interesting and led to one or the other new idea for private or also professional projects!

---

## Navigation

- Parent: [Blog](https://www.niklas-stephan.de/en/blog.md)
- Previous: [Passwordless SSH Login to a Remote Server with Visual Studio Code](https://www.niklas-stephan.de/en/blog/passwordless-ssh-login-to-a-remote-server-with-visual-studio-code.md)
- Next: [🥼 BOINC](https://www.niklas-stephan.de/en/blog/boinc.md)
