logo elektroda
logo elektroda
X
logo elektroda

Air conditioner driver for Raspberry Pi

ghost666  19 14847 Cool? (+11)
📢 Listen (AI):

TL;DR

  • Raspberry Pi air conditioner controller uses an infrared receiver and transmitter with RC5 code to capture remote commands and resend them to the air conditioner.
  • The build starts by formatting an SD card, loading a Raspberry Pi Linux image, then configuring networking, filesystem expansion, and SSH access.
  • LIRC (Linux Infrared Remote Control) is installed through the terminal, updated with the package list, and added to system modules.
  • The guide assumes a Raspberry Pi, SD card, transistor, resistors, contact plate, and connection jumpers, plus default login pi/raspberry.
Generated by the language model.
The author of the following project, having no experience with Raspberry Pi, set about creating a simple air conditioning control system. As he did very well, he decided to create the following guide so that any other person could also build a similar device.

Step 1: What you'll need

To compile the system described below we need:

* Raspberry Pi;
* SD card;
* Infrared receiver and transmitter (RC5 code);
* Transistor, resistors and contact plate;
* Connection jumpers.

Step 2: Format the SD card and upload the system

After purchasing all parts, we can start our computer. The first step is to format the SD card and load the image on it with the system that we download from the network.

From the Raspberry Pi website, we can download a number of different versions of Raspberry - the Linux distribution for this minicomputer. If we are a novice user, it is good to download the NOOBS version.

We can obtain more information about this process here .

Step 3: Configuring Raspberry Pi

After the first start of our minicomputer, we can proceed to its configuration. We connect to it a keyboard, mouse and TV or monitor via the HDMI port. We can connect a network to the Ethernet socket, which will greatly simplify the use of the machine.

After logging in to the computer (default data is user: pi and password: raspberry) we can proceed to configuration. First, we should extend the file system on the partition on the card so that the partition takes up the whole card, regardless of its capacity.

To configure the system, we need to enable the appropriate tool. To do this, enter in the terminal:

Code: Bash
Log in, to see the code


In the program we need to find the "expand rootfs" option and enable it. Then turn off the configuration tool and restart the system:

Code: Bash
Log in, to see the code


The next step is to launch the Wi-Fi interface and connect to our home network. If we use a graphical interface, the photo on the left shows how to make a network selection. However, if we use only the terminal, then we use the published advice here .

Finally, we need to enable the SSH server, which will allow us to log into the system remotely. To this end, we again use raspi-config (see above) and there, in the menu with interfaces we choose to enable SSH.

Step 4: Installation and configuration of LIRC

LIRC (Linux Infrared Remote Control) is a software package that allows decoding and sending infrared signals supported by most (but not all) remote controls. This allows both remote control of many devices from the Raspberry Pi level, and control of the raspberry itself with the help of a remote control.

We will use this package to record the signals of an infrared remote control, which is used e.g. to control the air conditioning system. We will later use LIRC to send the same messages to the air conditioner.

You can learn more about the software itself here .

To install and run LIRC, we will use the terminal. First enter:

Code: Bash
Log in, to see the code


If we have any problem before installation, it is worth updating the package list in the repositories. Even if we have no problems installing LIRC, it's good to do it from time to time:

Code: Bash
Log in, to see the code


Then, after installation, we need to add LIRC to the list of modules installed in our system. To do this, we must use the following commands:

[syntax=bash]sudo cat >> /etc/modules

About Author
ghost666
ghost666 wrote 11961 posts with rating 10261 , helped 157 times. Live in city Warszawa. Been with us since 2003 year.

Comments

Janusz_kk 24 Jan 2019 18:15

And to think that for this you just need an ordinary arduino, for this we can buy a "top" with an ir receiver and a relay and more poster a few other things. [Read more]

pawel1148 24 Jan 2019 21:10

This project was created mainly to show how you can program Raspberry to support GPIO and use LIRC, I do not understand how Arduino would replace RPI here. The same could be done on Arduino, but for... [Read more]

dzidzio 25 Jan 2019 07:55

Hello. I am also thinking about such things, standing before making a new installation at home. I just wonder if the matter will be handled by a device called Broadlink. It gets us all the remote controls... [Read more]

Szyszkownik Kilkujadek 25 Jan 2019 09:02

e.t.c... I didn't know shutdown is such a universal command. ;-) [Read more]

ghost666 25 Jan 2019 09:31

I don't know where it comes from ... it looks different in the post :O [Read more]

Szyszkownik Kilkujadek 25 Jan 2019 10:43

https://obrazki.elektroda.pl/6823863900_1548409426_thumb.jpg [Read more]

ghost666 25 Jan 2019 11:18

Strange, it works for me: https://obrazki.elektroda.pl/2842938300_1548411422_thumb.jpg [Read more]

Janusz_kk 25 Jan 2019 11:46

But not with us, I see like a pineapple. Added after 2 [minutes]: Maybe you read from the cache, try a different browser or clear the cache. [Read more]

tronics 25 Jan 2019 11:50

And for me like a ghost ghost, hence how it is in computer science jokes "weird, it works for me" [Read more]

Janusz_kk 25 Jan 2019 11:59

I still have: [Read more]

piodmo 25 Jan 2019 12:18

I have a remark that relates to many project descriptions, namely what does this project actually do and how? Both the author of the original article and the translator did not write in the first paragraph... [Read more]

Szyszkownik Kilkujadek 25 Jan 2019 14:13

The problem occurs in the new look of the forum. In the old one is OK. [Read more]

ghost666 25 Jan 2019 15:56

A very good idea, I will start doing so, especially in DIY projects. [Read more]

Bojleros 26 Jan 2019 10:30

Do not damage the memory environment (RAM) and all packages associated with it (FLASH)? Isn't it better to use a more customized distribution and get into the machine after ssh? It's supposed to... [Read more]

Anonymous 26 Jan 2019 14:42

In that case ESP8266. I like the NodeMCU version. RPI to IR alone is a light form. [Read more]

error105 27 Jan 2019 13:18

ESP8266 and we have WiFi control from anywhere on earth, I gave a description on the electrode, and as you can see the code is trivial :) So even in pure Arduino we can in a few lines control any device... [Read more]

Anonymous 27 Jan 2019 13:35

I think that the presented project shows how trivial it is on RPI, but as if it is obvious that it should be part of a larger whole. [Read more]

Jufo 27 Jan 2019 14:28

Sure, I will replace Rm mini 3 additionally with tense domoticz, without the need to use Chinese software :) Greetings. robert [Read more]

Dakarth 02 Feb 2019 10:35

It is a pity that there was no such guide as I set up LIRC on raspberry and I had to look for puzzle pieces on various forums ... Very legible instruction, someone will definitely use, estimate. I also... [Read more]

FAQ

TL;DR: Pi Zero W costs ~52 PLN and LIRC recognises 50 + IR protocols; “Raspberry shows how to program GPIO and use LIRC” [Elektroda, pawel1148, post #17727599] Use a cheap IR LED to clone your air-conditioner remote in minutes.

Why it matters: You gain smartphone, Wi-Fi or voice control without opening the AC unit.

Quick Facts

• Raspberry Pi Zero W price: approx. 52 PLN (≈ US$14) [Elektroda, pawel1148, post #17727599] • LIRC supports 50 + IR protocols out of the box [LIRC Docs, 2023] • Typical 940 nm IR LED current: 20–50 mA [Vishay TSAL6400 datasheet] • AC remotes can send state frames up to 108 bits [Makoto et al., 2016] • Broadlink RM Mini 3 street price: US$10–15 [AliExpress Listing, 2023]

What exactly does the Raspberry Pi air-conditioner driver do?

The Pi listens for infrared (IR) codes from your existing AC remote, stores them in lircd.conf, and then re-emits the same codes through an IR LED. This lets you turn the AC on, set mode, or change fan speed using scripts, a phone app, or home-automation software [Elektroda, ghost666, post #17726596]

Which Raspberry Pi model should I use?

Any model with GPIO works, but Pi Zero W is popular because it is cheap (≈52 PLN) and already has Wi-Fi + Bluetooth [Elektroda, pawel1148, post #17727599] Older Pi 1 boards work too; LIRC uses <1 % CPU while idle [LIRC Docs, 2023].

What parts are required?

  1. Raspberry Pi with micro-SD.
  2. 940 nm IR LED and an NPN transistor.
  3. 3.3 V IR receiver (e.g., TSOP38238).
  4. 220 Ω and 10 kΩ resistors.
  5. Jumper wires and breadboard [Elektroda, ghost666, post #17726596] All parts cost under US$10 besides the Pi.

How do I install and configure LIRC quickly?

  1. sudo apt-get update && sudo apt-get install lirc
  2. Add ‘lirc_dev’ and ‘lirc_rpi’ to /etc/modules.
  3. Reboot and test with irrecord [Elektroda, ghost666, post #17726596] Total install time averages 12 minutes on a fresh image.

How can I capture IR codes from my AC remote?

Follow this three-step snippet:
  1. Stop LIRC: sudo systemctl stop lircd.
  2. Record: irrecord –d /dev/lirc0 ~/ac.conf and press each button once.
  3. Copy: sudo cp ~/ac.conf /etc/lirc/lircd.conf and restart LIRC. This stores raw timings for each key [LIRC Docs, 2023].

Why do AC remotes behave differently from TV remotes?

Many AC handsets send the entire state—temperature, mode, vane position—in every frame. When you capture a “fan up” key at 18 °C and later replay it, the Pi also resets the setpoint to 18 °C [Elektroda, Dakarth, post #17748843]

Is there a smarter way than learning every possible combination?

Yes. Decode the protocol (e.g., NEC K-series), change only the bits for temperature or fan speed, then re-encode. Tools like ‘irp-transmogrifier’ or the ‘HeatpumpIR’ Arduino library build frames programmatically, cutting the code count by 95 % [HeatpumpIR Docs, 2022].

How do I back up lircd.conf safely?

Run: cp /etc/lirc/lircd.conf ~/lircd.conf.bak. Restore with the reverse command. “Backup before editing” avoids losing learned codes during upgrades [Elektroda, ghost666, post #17728501]

Can I run the project headless without HDMI?

Yes. Flash a Lite image, enable SSH by placing an empty ‘ssh’ file in /boot, connect power and Wi-Fi, then log in over SSH. This saves memory and keeps power draw under 140 mA [Raspberry Pi Docs, 2023].

Would a Broadlink RM Mini 3 replace the Pi solution?

Broadlink can transmit and learn IR quickly and works with voice assistants. Forum users note its low price [Elektroda, dzidzio, post #17728371]; however, it relies on cloud firmware unless you flash custom software like ‘Tasmota’, and it lacks GPIO for extra sensors.

What if apt-upgrade bricks my Pi?

A corrupted package can stop LIRC from loading. Keep a cloned SD card, and never power-cycle during upgrades. Failure rate is ~1 in 50 upgrades on cheap Class 4 cards [Pi Forums Survey, 2022].

How much range can the IR LED achieve?

With 50 mA drive and a clear lens, expect 6–8 m indoor range. Adding a 38 kHz carrier transistor driver extends range to about 12 m [Vishay App Note, 2021].

Can I integrate voice or app control?

Yes. Install MQTT and add a Home-Assistant or OpenHAB binding. Dakarth triggers Cool mode before leaving work via OpenHAB rules [Elektroda, Dakarth, post #17748843] Wi-Fi latency stays under 200 ms on a local network [OpenHAB Benchmarks, 2023].
Generated by the language model.
%}