David A. Antler

Apartment A/C Upgrade


My apartment is dated. It’s got beige everything, which arguably includes the person living inside it. But as a renter I’m not about to spend any money changing things; this place is cheap and that’s why I’m here. I wouldn’t want to upset this balance in our relationship, though I do long to modernize at least a little.

One thing that bugs me is the A/C. It’s a very noisy window unit and my choices are either to run it all the time and have the built-in thermostat regulate the temperature, or to be too hot. If there was some non-destructive way to connect an off-the-shelf smart thermostat to it then I could probably set up some complicated rules which would solve this problem for me.

Instead, back in 2016, I opted to fix the system myself. The high-level idea was to control the A/C unit through its infrared port and build my own (practical) control system around it. Below is a description of that system.


High level architecture

Send commands to Arduino using Bluetooth LE for monitoring and control. Receive and handle BLE commands from PC to (1) Fetch temperature data, or (2) Blast infrared codes. Wait for infrared codes. Use compressor and fan to cool air in apartment.

Note: These high-level ingredients are scattered all over my apartment so I made everything wireless. Only power is required.

Note 2: the link between the Arduino and the A/C is an infrared remote port and therefore simplex.

Bill of materials

The total cost of the hardware was less than $60 USD since I get most things from Ali Express, but this requires lots of patience.

Ingredient PC Arduino101 A/C
Added HW BthLE Transciever Thermistor, IR LED & Resistor Unmodified
Base SW Windows 10 Arduino101 core libs N/A
Added SW Custom monitoring program Custom sketch Unmodified

My custom monitoring software runs as a service, every 15 minutes. It isn’t open source, but send me an email and I can share parts of it. It’s a NodeJS program that uses the Windows 10 WinRT APIs for interacting with Bluetooth, instead of that Noble library that asks you to uninstall your OS’s Bluetooth stack.

Algorithm & Policy

The algorithm I use runs on the PC and reads the temperature from the Arduino. It then decides whether or not to turn on or off the A/C. I have defined two temperature thresholds that I use in my algorithm.

By default the policy assumes that the A/C should be turned off, unless one of the following conditions is met:

  1. The temperature is too high to possibly be comfortable (temperature > HighThreshold)
  2. The system thinks I’m away or asleep and wants to keep things extra cool. (userIsAway && temperature > AwayAsleepThreshold)

The combination of the two above policies ensures that the noise I hear, as the tenant, is down to a minimum. I’ve programmed my work and sleep schedule into my custom monitoring program so #2 is achievable most of the time. Thank goodness my life is so predictable!

I also collect temperature data in a Google spreadsheet so I can check out my the temperature history remotely. One time it got interesting when my landlord turned up the heat without my knowledge.

Development Notes

A few notes on how I got things working. I’m not going to turn this into a how-to article, but if you have some questions, please shoot me an email.

Software

  1. Visual Studio 2015
  2. WinLIRC
  3. Arduino IDE v1.6.7 or higher.

Hardware

  1. Arduino101
  2. IRToy v2
  3. Windows 10 PC
  4. IR LEDs
  5. 75 Ohm resistor
  6. Temperature sensor (TMP36)
  7. Some IR remotes

I found out that the extremely popular Arduino infrared library doesn’t work on the Arduino101, so I had to write my own.

I found a way to connect my HW components directly to the Arduino headers and was able to avoid putting together a separate board. I soldered the 75 Ohm resistor in series with the IR LED at the leads. I was able to extend the thermistor’s leads as well. This is a fragile setup but it has worked for more than a year.

More details

Home