This article covers the development of an Arduino controlled air conditioning system. It converts an old school, in-window, air conditioner (AC) which was in a very hard to reach spot to an automatic system which can be activated and monitored from MegunoLink Pro at your desk. The system consists of an Arduino Uno, a servo driven mechanism to active the AC, a DS18B20 temperature sensor, and MegunoLink Pro to plot the temperature and control the set points.



Mechanical Components

Being an old-school air conditioner, there was no clear way of controlling the system digitally. Instead, a mechanical actuator was designed which simply fit over the rotary switch and a simple servo controls the switches position. Either off, in fan mode, or in low or high power cooling.

The structure for the actuator was printed on and UP! Plus 3D printer using ABS plastic. The design is fairly custom, but if you think it will work on your system then grab the STL files below.


Mechanical interface used to actuate the switch on the AC system. Servo manually adjusts the setting knob depending on the current temperature.

STL file for servo bracket to control air-conditioner.

The Brain (Arduino Uno)


This project is controlled by an Arduino Uno microcontroller. The temperature is measured using a DS18B20 temperature probe and the actuator is driven using a Tower Pro MG995 servo. Because the servo draws a significant amount of current when starting up a 4700uF capacitor was placed on the power bus to help reduce the voltage drop and keep the microcontroller running smoothly.

The DS18B20 temperature probe’s signal line is connected to pin 10 on the Arduino UNO. It also requires a connection to ground and 5V with a 4.7K pull up resistor between the signal line and 5V. The servo is also connected to the 5V and ground lines but the control signal is connected to pin 9 of the Arduino.


Left: Circuit layout including the DS18B20 temperature sensor and servo. 4700uF capacitor was used to smooth out the power supply when the servo is activated. Right: Actual hardware used in this project.


The program which runs on the Arduino UNO is fairly simple. The temperature sensor is read and if the current temperature is above the target set-point (plus a hysteresis value) then the servo is adjusted to the on (low) position. Once the temperature falls below the set-point (minus a hysteresis value) then the servo is adjusted to the off position. The hysteresis values are used to prevent noise in the temperature value from falsely changing the controllers state and repeatedly adjusting the servo.

As well as the basic temperature controlling functionality a command handler is used to receive commands and arguments (numbers etc) from MegunoLink. These commands are used to configure various settings such as the temperature set points, hysteresis, servo locations, and servo delay. These settings are saved in the EEPROM of the Arduino so it remembers it’s state even when the power is disrupted.


To configure the temperature controllers set points and servo positions a custom interface was built using MegunoLink’s Interface Panel visualiser. The figure below shows the interface early in its development (left) and the completed version on the right. Each button is configured to set a specific message to the Arduino changing one of its settings.

For example: if you click the Set Temperature button in the current interface it will send, over the serial channel, !SetTemperature 23\r\n. The Arduino will receive this command and allow you to use the arguement (23) to set a new target temperature.

As well as controlling and configuring the Arduino, MegunoLink can respond to commands it receives. An example of this is the play and pause symbols. These indicate if the controller is enabled or not. If the controller is enabled then the Arduino will send MegunoLink a message like this:


These commands will make the DisabledIndicatorPicture (pause symbol) disappear and the EnabledIndicatorPicture (play symbol) appear.


Left: Custom interface under construction using MegunoLink’s Interface Panel. Right: Finished interface for controlling the temperature.

Setting Servo Positions

Before the controller will operate correctly the servo positions need to be configured. On the second tab in the interface panel we have a number of buttons and number controls which allow you to set the servo position for each of the AC systems settings. Clicking each of the set buttons also moves to that position. This makes it easy to fine tune and when you’re done these settings are stored in the Arduino’s EEPROM. The AC system used in this project had four settings each with a different button position, Off, Fan, Low, and High.

The last setting is the list is Servo Delay, this setting adds a delay between each step in the servo so that it smoothly and more importantly quietly shifts states. Without this delay the servo makes a very loud noise and quickly shifts to the new set point.


Advanced page for configuring the switch positions.

Temperature Data

The final component to the system is some feedback on how the temperature controller is going. For this the controller uses MegunoLinks Time Plot and Table visualisers to display the current and historical temperature values as well as the current set points. This is achieved by sending targeted messages over the serial port which MegunoLink detects and responds to. For example to send a value to the table a message like this is sent:

{TABLE|SET|Target Temperature|23.00|}

For plotting data the messages look like this:

{TIMEPLOT|data|Current Temperature|T|24.000}

Of course we have a library for the Arduino which makes sending these messages easy.


Left: Table visualiser showing the current, target, and hysteresis temperatures. Right: Time Plot visualiser showing two heating and cooling cycles for the Arduino controlled AC system.

Download and Get Started

Grab all of the files you need from our Github repository. The download also includes the required Arduino libraries needed to make the program run. These are:

If you need help installing Arduino libraries check out this guide.
STL file for servo bracket to control air-conditioner.

Do you have an old air conditioner you would like to modernizse? If you decide to give it a go let us know how it goes.

Leave a comment down below! or if you need help jump over to our forums.

Thanks for reading.

Recommended Posts
Showing 11 comments
  • lew

    great project but would you be able to help me adapt this for a special use ? I would like to control a flap on an air cooled vw engine and use this as the thermostat . the original thermostats are no longer available .
    I just need a Ds18b20 temperature to control a servo and be able to manually input the opening voltages and servo degrees in a sketch .

    thanks for your help

    • Philip Rowe

      Hi Lew, happy to help if you ask specific questions. I suggest you jump over to our forums (use the support menu above) and we can talk more about your project.


  • Bill

    Is the STL still available? The only download links I saw were for the GitHub project files and “SetupMegunoLinkPro.exe”

    • Philip Rowe

      Hi Bill, sorry the link was set up incorrectly. It should be fixed now.

      • Bill

        Thank you! Very much appreciated 🙂

    • Kevin Miranda

      is the STL download link already fixed?

      • Philip Rowe

        Hi, the link seems to be working for me. Cheers

      • Nexxusty

        I think it would be a MUCH better idea to replace the low/medium/high switch/relay in this with Arduino controlled one.

        Doubt it would even be that hard either…. This just seems way, way over-engineered.

        • Philip Rowe

          Ha you could be right. This was a solution for an AC unit at work so I didn’t want to add any lasting modifications.

  • Hugh

    I have recently had a project where I bypassed the AC’s internal relay and am switching it directly. The purpose of this to control the temperature in a test chamber for materials testing.

pingbacks / trackbacks

Leave a Comment

Start typing and press Enter to search