There is a new version of the Climaduino and the Climaduino Controller with some very significant changes.
For more information, visit the develop branch of both projects Git in the git repo:
Not everyone lives somewhere with central air, or is willing to pay for a Nest or similar "smart" thermostat. The Climaduino is a DIY Arduino-based thermostat designed to control a wall unit A/C. I incorporated both temperature and humidity sensors in order to optimize comfort and reduce energy usage. I then developed a Raspberry Pi-based web interface to control the Climaduino from my phone.
This is still a work in progress, but is definitely functional. I am posting this instructable so others can both build their own smart thermostats, and hopefully build on this project with their Climaduino improvements.
Here are the features so far:
Why did I want to build this? Mainly because it was fun to do and I've always been very interested in climate control. (I know that sounds weird, but it's true.) It's also because humidity is a huge issue in my area, South Florida. I designed the Climaduino Thermostat to take this into account. The A/C will stay on just a little bit longer when it's humid to wring more moisture out of the air. I also added a humidity control mode. It can save a significant amount of power and prevent coming home to a mold-infested house. Humidity control mode ignores temperature and only runs the A/C when things get too humid. It's useful when going out of town or when the house is empty (of people and pets).
If you perform any of the steps in this instructable, you assume all risk for the outcome. Working with high voltage can be extremely dangerous. Improperly altering your A/C unit could lead it to malfunction or completely break. Please be careful.
Electrical Safety: Safety and Health for Electrical Trades Student Manual
Step 1: Supplies
The following will be needed to complete this project.
1 x 4.7K ohms
1 x 220 ohms (only required if LCD is used)
Step 2: Thermostat: Building and Installing the Relay
Note: Make sure to use a power cord that can handle the current your A/C draws and has the right plug type.
Another option is to subvert the A/C's built in controls and install the relay inside the A/C. (Has serious potential to break your A/C, and can be dangerous if not insulated properly from the chassis.)
I originally planned on creating a power cable for the unit with the relay inline. Unfortunately, this unit's built-in thermostat was cycling it off prematurely. I looked up the unit's wiring diagram and found a way to wire in the relay so the old built-in thermostat could still be used in the future. I then set the built-in thermostat to its hottest setting giving the Climaduino Thermostat full control.
Step 3: Thermostat: Wiring it all up
GND to - rail on the breadboard
CTRL to pin 10 on the Arduino
5V to + rail on the breadboard
I recommend orienting the Arduino so pins 0-13 are next to the the breadboard. This makes the wiring for the LCD a lot neater.
The resistor used for the LCD is 220 ohms, and the one used as a pull-up for the DHT22 sensor's data line is 4.7K ohms.
Step 4: Thermostat: Loading the Code and Testing
If it fails to upload, this may be because you do not have the DHT library installed in your Arduino/libraries folder.
Once uploaded, the LCD should display the current temperature/humidity settings and readings. The temperature setting can be changed using the two buttons on the Thermostat. One button raises the temperature by a degree at a time and the other lowers it. Hold the button down until the setpoint changes to the desired value. It will not be very responsive. Earlier attempts at using interrupts to allow immediate reactions to button presses caused problems.
The thermostat outputs current readings, parameters, and other operational details as JSON over the serial port. To test this, open the serial monitor (right-most button in Arduino IDE). You should see JSON data being sent from the Arduino to your computer. This data includes the operational parameters, the current settings, and readings.
To test changing the settings, open the serial monitor. Click the drop-down menu at the bottom of the window that says Newline and select No line ending. Type the desired temperature followed by an F (case sensitive) and press Send to change the temperature setpoint. 77F and then Send would change the temperature to 77 degrees fahrenheit. Type the desired humidity followed by a % and press Send to change the humidity setpoint. 55% and then Send would change the humidity setpoint to 55 degrees of relative humidity. Finally, the mode can be changed by typing the desired mode number followed by M (case sensitive) and pressing Send.
Valid values for mode are:
Step 5: Controller: Installing Pre-requisites
This assumes you already have a Raspberry Pi running the Adafruit Occidentalis Distribution (based on Raspbian). It also assumes you have network connectivity either by connecting directly over Ethernet, or by setting up and using a USB WiFi adapter.
Here are some resources to help those new to the Raspberry Pi:
The Occidentalis distribution advertises itself as raspberrypi.local using Avahi (Bonjour). This means that Macs, and iPhones will be able to access the Raspberry Pi using this rather than IP address. If unable to use raspberrypi.local, it may be advisable to configure a static ip. If you decide not to configure a static IP, and can not use raspberrypi.local, you can find the IP address assigned to the device from your router or by logging on to the Raspberry Pi using a monitor and keyboard and typing ifconfig. You will use the account pi to log in. The default password for the pi account is raspberry.
Change the default password (optional)
Install Python Setuptools
Python Setuptools makes it easier to download, install, and configure Python packages. It provides the easy_install command I'm going to use a lot in these steps.
sudo apt-get install libcairo2-dev libpango1.0-dev libxml2-dev rrdtool librrd-dev
Installing Git (optional)
Install Python virtualenv (optional)
Python virtualenv allows creating a isolated install of Python. The advantage of doing this is that it keeps any modifications you make to Python compartmentalized in that one virtual environment. This is a bit overkill for what we are doing with the Climaduino Controller, but I like to leave things in a good state for future projects. Here is a quote from https://pypi.python.org/pypi/virtualenv that explains it well:
"The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded."
Creating a Virtualenv (optional)
We're now going to create a Python virtualenv at /home/pi. Since we are logged in as pi, ~ expands to /home/pi. If you choose to create your virtualenv somewhere else, then the steps and examples in the rest of this instructable will need to be adjusted accordingly.
Using a Virtualenv
There are two ways to use your virtualenv. You can either directly use the activate script (installed with the virtualenv) to update your path, or directly reference the executable in the virtualenv.
Using the activate script to use the virtualenv is the option I chose as it is less error-prone. When choosing this option, no special considerations need to be made as the right executables will be used. This has to be repeated each time you log in and want to use your virtualenv.
If you choose not to use the activate script, then care must be taken when running Python programs or using easy_install. When the activate script is not used, then the system-wide versions are used unless you specify the path of the executable you want to use. To run a python program you would need to type ~/bin/python program_name.py and to use easy_install, you would need to type ~/bin/easy_install package_name.
Note: The rest of the commands in this instructable will assume a virtualenv was created and the activate script was used to update the path. If no virtualenv was created, the easy_install commands will need sudo prepended to them. If a virtualenv was created and the activate script was not used, ~/bin/ will need to be prepended to some commands.
Step 6: Controller: Initial Setup
Connect the Arduino
Installing Needed Python Packages
Get the Climaduino Controller source code
The code can either be:
Set Up the Climaduino controller
Test Initial Setup
Step 7: Controller: Polishing the setup
The setup as we left it is not very polished. The following are optional steps that can be taken to make the Climaduino Controller's installation more polished.
Change the hostname so it can be accessed using climaduino.local
This will change it so we connect to the controller at climaduino.local rather than raspberrypi.local.
The Climaduino Controller should now be accessible at http://climaduino.local:8000.
Start Automatically at Boot and use Port 80
I have already created a startup script that can be used. If any details of your implementation differ from the steps in this instructable, the script may need some tweaking.
After reboot, the Climaduino Controller should start automatically. It should now be accessible without adding a port number since port 80 is the default for http. http://climaduino.local (or http://raspberrypi.local if the hostname was not changed).
Step 8: Thermostat: Advanced tweakingMost people are probably going to want to ignore this step. It is just extra information about parameters in the Climaduino Thermostat that can be tweaked and what they do.
There are many variables that are not currently able to be adjusted without changing them in the code. While some may be exposed using the serial interface in the future, for now the following variables can be changed in the source code. The sketch can then be re-uploaded to the Arduino.
Step 9: Contribute backIf you use this project and improve it or fix any bugs, please contribute your changes back. Comment on this instructable or contact me through instructables.
Thanks and hope you enjoy this project!