Introduction: Arduino Thermostat for Window AC Unit (On the Cheap)

About: Follow me in Instagram:

Do you get sick of your cheap piece of crap AC unit making things too cold, like I do?--but when you turn it off, the room gets too hot; dumb thing doesn't have a decent thermostat.

In this tutorial I will show you how to make a device that automatically regulates temperature, or that activates a device when the temperature reaches a certain point. This could be any device, but for example, I will be using an air conditioner in an upstairs bedroom.

Step 1: Gathering Supplies

First things first. You will need some parts to get this project going, so head to your favorite electronics website and purchase the following:

1. Arduino--Doesn't need to be an Uno, but if you use a different board, some of the pins may change; I will cover that later.

2. Cheap arduino-compatible relay module--almost any type will work.

3. DS18B20 Temperature Sensor--A cheap ebay version will work just fine!

4. Rotary Encoder

5..96" i2C 128X64 OLED display (optional)--Make sure it is i2C and not SPI serial

// Not used -->> 6.C945 NPN transistor (Depending on the relay module used)

Step 2: Time to Wire Things Up

This is the tricky part, I will do my best to explain how everything is connected in the list below.

If this list is not clear, please let me know and I will change it.

Let's start with the encoder:

  1. Connect center encoder pin to ground
  2. Connect right encoder pin to arduino pin 2
  3. Connect left encoder pin to arduino pin 3

Next is the relay module:

  1. Connect ground to ground
  2. Connect trigger pin to ground (depending on the type you buy)
  3. connect 5V pin to arduino pin 10

Next is the DS18B20 sensor:

  1. Look at the schematic for the sensor you bought and find what the 3 pins are (wire color my change depending on manufacturer)
  2. Connect Vcc to arduino 5V out
  3. Connect ground to ground
  4. Connect data pin to arduino pin 11

Last is the is the i2C display (optional)

  1. Connect Vcc to Arduino 5V out
  2. Connect ground to ground
  3. Note that the next two pins will change depending on the arduino board you choose. Look at the arduino website to find SDA and SCL pins for each board respectively. For the arduino uno,
  4. Connect SDA pin to Arduino ANALOG pin 4
  5. Connect SCL pin to Arduino ANALOG pin 5

You should be good to go!

Step 3: Upload Sketch to Arduino

Now that you've got the supplies you need, download my sketch (code) from this link:

You can find plenty of tutorials regarding uploading code to an arduino on the web, so I won't explain that here.

For the sketch to work, you will need to install 4 libraries:

  1. OneWire (To communicate with temp sensor)
  2. DallasTemperature (To understand temp sensor)
  3. u8Glib (To write text on i2C display)
  4. Encoder (To understand encoder input)

If you don't know how to install libraries, check out this instructable

If you have any troubles or questions, please ask in the comments below so that I, and others, can help you!

Step 4: Pop That Switch!

STOP! Unplug your air conditioner, then turn the switch to the ON position, the back to the OFF position before proceeding. The wires shown in this tutorial carry 120V AC current that will kill you until you're dead. Now is a good time to say that I am not responsible for any stupidity on your part. If you feel that you might kill yourself, please do some research on how to be safe with electricity before proceeding.

Now that's out of the way,

  1. Remove switch with screwdriver or other tool
  2. lengthen writes if necessary (using proper insulated crimp connections)
  3. clean and strip wires enough to connect the normally open side of the relay.

Step 5: All Done!

And now you're finished! Check out the video to see my setup in action. Also if you've followed the tutorial and tried it, please let me know and show me your end result!