loading
In this project we'll use an arduino uno, an LCD and a temperature sensor to control your air conditioning.! Also You can modify the code for a heater. The code is well explained! I show even how I made mine permanent!  
Great your beginners to learn arduino and for hot room that have an old manual a/c. This is a project to try!

Step 1: Prototyping the Test Circuit


This circuit is to test if the thermostat is working or not. The lcd should display a hello,world! sketch, the the current temperature of the room, and below is the ideal temperature or settemp. If the current temperature is off by a little you may need to adjust the code which calculates the 10 bit number read from A0 into a temperature reading in degrees Fahrenheit. If you need Celsius will will also need to change the line of code the calculates the temperature. If you wan to control an a/c,  you can remove the led and replace it with an N-Channel MOSFET ( Metal Oxide Semi-conductor Field Effect Transistor). Then TO USE A PROTECTION DIODE!  I will go over this as well. In the next step. 

Parts list:
12 volt power supply 
7805 5 volt voltage regulator
arduino uno or other arduino dev board
3x 10k ohm resistors
led
jumper wire
solderless breadboard 
arduino ide
10k potentiometer ( or a 1k ohm and a 220 ohm resistor) (or the 3rd pin can go to ground) 
16x2 Hitachi driven hdd44780 LCD
10k thermistor a.k.a. (10k ohm NTC, (Negative Thermal Coefficient)
2x tactile button switches ( or any other button switch)
usb b type connector to program arduino

For use with an a/c:
N-channel MOSFET 
120VAC 20-40A relay
1N4007 - 1N4004 rectifier diode
a/c

To finalize:
perfboard / PCB
Project enclosure
And tool that everyone should have 

Let's get started!
 

<p>How to change max. set temp with 250F to 350F???</p>
<p>How to change the set temp???????</p>
<p>You use the push buttons with a pull down resistor in this configuration to change the set temp. But do change it for your application, this is a rough version that still could use a little tweaking because the subtle temperature changes trigger the a/c on and off a million times. Good luck!</p>
<p>I made it FINALLY after months of problems!!! i reworked the code a bit and added 3 relays total and a toggle switch cause where i live sometimes you just want it off! </p><p>the relays are for</p><p>1. hot</p><p>2. cold</p><p>3. fan</p><p>and my switch is a 4 way switch so it can click to heat, cool, fan, and off</p><p>thanks a bunch!!! if i get a nice sheild made i may do a kickstarter! do you have a way for me to donate some $ to you?</p>
<p>Hi Dylon, </p><p>Your project seems useful so I tried to replicate it but using Grove-LCD RGB Backlight display instead. </p><p>Everything is flowing nicely until I get to the user buttons. Im using a-pushto-off button with only 2 connecting wires. </p><p>So the problem I'm facing is, when I pressed the up button, the temperature (settemp) will go up and not stop. Same goes if I press the down button.</p><p>I'll give you my codes below but Im sure it's similar..</p><p>Please help me if you can. It's giving me sleepless nights... :(</p><p>// Declare variables</p><p>#include &lt;Wire.h&gt;</p><p>#include &lt;EEPROM.h&gt;</p><p>#include &lt;Bounce2.h&gt;</p><p>#include &quot;rgb_lcd.h&quot;</p><p>rgb_lcd lcd;</p><p>const int colorR = 30;</p><p>const int colorG = 30;</p><p>const int colorB = 60;</p><p>float tempC;</p><p>float settemp;</p><p>int tempPin = A0; //temp sensor plugged in pin 0</p><p>int ledPin = 13; //closest to ground</p><p>int fan1 = 2; // fan connected to pin 6</p><p>int swtu = 7;</p><p>int swtd = 6;</p><p>Bounce bouncer = Bounce();</p><p>// Write setup programme</p><p>void setup()</p><p>{</p><p> Serial.begin(9600); //Open serial port to communicate. sets data rate to 9600</p><p> // set up the LCD's number of columns and rows:</p><p> lcd.begin(16, 2);</p><p> // initialize the serial communications:</p><p> lcd.setRGB(colorR, colorG, colorB);</p><p> lcd.print(&quot;Temp = &quot;);</p><p> delay(250);</p><p> pinMode(ledPin, OUTPUT);</p><p> pinMode(fan1, OUTPUT);</p><p> pinMode(swtu, INPUT);</p><p> bouncer.attach (swtu);</p><p> bouncer .interval(5);</p><p> pinMode (swtd, INPUT);</p><p> bouncer.attach (swtd);</p><p> bouncer .interval(5);</p><p> EEPROM.read(1); //make eeprom memory address</p><p>}</p><p>//Write loop that will control the </p><p>void loop()</p><p>{ </p><p> tempC = analogRead(tempPin); // read the analog value from the lm35 sensor.</p><p> tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.</p><p> lcd.setCursor(8,0);</p><p> lcd.print(tempC);</p><p> lcd.print(&quot;'C&quot;);</p><p> Serial.print((byte)tempC); // send the data to the computer.</p><p> settemp = EEPROM.read(1); // read the settemp at memory 1</p><p> delay (250);</p><p> if (digitalRead (swtu)==1)</p><p> {</p><p> (settemp ++);</p><p> EEPROM.write(1, settemp);</p><p> }</p><p> else{</p><p> }</p><p> if (digitalRead(swtd)==1)</p><p> {</p><p> (settemp --);</p><p> EEPROM.write(1, settemp);</p><p> }</p><p> else {</p><p> }</p><p> if (tempC &gt; settemp)</p><p> {</p><p> digitalWrite(ledPin, HIGH);</p><p> digitalWrite(fan1, HIGH);</p><p> }</p><p> else</p><p> {</p><p> digitalWrite(ledPin, LOW);</p><p> digitalWrite(fan1, LOW);</p><p> }</p><p> lcd.setCursor(0,1);</p><p> lcd.print(&quot;Set Temp To: &quot;);</p><p> lcd.print(settemp);</p><p> Serial.print((byte)settemp);</p><p>// EEPROM.write(1, settemp);</p><p> delay(250);</p><p>}</p>
<p>In the code, you have </p><p>if (temp &gt; settemp) // if the temperature exceeds your chosen settemp<br>{<br> digitalWrite (led, 1); // turn on the led<br>}<br>else // if that doesn't happen, then turn the led off<br>{<br> digitalWrite (led,0);<br>}</p><p>I'm guessing that turning on the LED also activates the MOSFET and turns on the A/C, correct?</p><p>My main question is this: For someone who has both a heater and an A/C, could you have it do something like this:</p><p>if (temp &gt; settemp + 2) // if the temperature exceeds your chosen settemp<br>{<br> digitalWrite (led, 1); // turn on the led for the A/C circuit<br>}</p><p>elseif (temp &lt; settemp - 2) //If the temperature exceeds your settemp</p><p>{</p><p>digitalWrite (led, 1); // turn on the LED for the heater circuit</p><p>}<br>else // if that doesn't happen, then turn the led off<br>{<br> digitalWrite (led,0);</p><p>// digitalWrite (ledX,0); //ledX would be the second led for the heater circuit<br>}</p><p>My goal with this is to replace the &quot;heat/cool&quot; switch on a regular thermostat, and have it be a pure climate control system (where it either turns the heat or A/C on to keep the temp at what you want). Also, I added the + 2 and - 2, because most furnaces and A/C's won't start until the temp is 2 degrees above/below your set temp. It might have to be tweaked out to 3 or 4, depending on whether your furnace and/or A/C stops before the actual temp gets more than 2 degrees from your set temp. Otherwise, your heater and a/c will constantly be turning off and on to keep your temp set.</p><p>Have a great day.:)<br>Patrick.</p>
<p>Sorry for the late response. You would need a second output or &quot;led&quot; which yes, is connected to a MOSFET then to a relay. I'm still new to arduino coding, so I really can't give you valuable code. The constant switching on and off is a problem that I have experienced, but you can make the code realize or have a hysteresis or a number/ temperature that will take into account the temperature lag and other stuff. Here is a helpful link because I can't explain stuff right. </p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/j7ceKov1YwQ" width="500"></iframe></p><p>I hope it helps</p><p>Dylon J</p>
<p>Sorry for the late response. You would need a second output or &quot;led&quot; which yes, is connected to a MOSFET then to a relay. I'm still new to arduino coding, so I really can't give you valuable code. The constant switching on and off is a problem that I have experienced, but you can make the code realize or have a hysteresis or a number/ temperature that will take into account the temperature lag and other stuff. Here is a helpful link because I can't explain stuff right. </p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/j7ceKov1YwQ" width="500"></iframe></p><p>I hope it helps</p><p>Dylon J</p>
<p>Sorry for the late response. You would need a second output or &quot;led&quot; which yes, is connected to a MOSFET then to a relay. I'm still new to arduino coding, so I really can't give you valuable code. The constant switching on and off is a problem that I have experienced, but you can make the code realize or have a hysteresis or a number/ temperature that will take into account the temperature lag and other stuff. Here is a helpful link because I can't explain stuff right. </p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/j7ceKov1YwQ" width="500"></iframe></p><p>I hope it helps</p><p>Dylon J</p>
The code is a good beginning but needs revision on the EEPROM.write command being used through every loop. EEPROM has a limited number of write cycles before it wears out. A better idea would be to only write to it periodically or only when the value to be written changes.
I know what you mean. But I used a cheap atmega8 that can be rewriten about 10,000 times before having errors. Plus, I really new to coding up the arduino.
The easiest way to reduce the number of write cycles would be to move the 'EEPROM.write' command to a new line just below each of the <br>'(settemp ++);' and '(settemp --);' lines. This way the EEPROM is only being written to each time a button is being pressed.
thx I'll try and change my code
Add your relay pin control to pin 10-8 or else you will flick to relay on and of rapidly it the start of the code.

About This Instructable

118,401views

94favorites

License:

More by Dylon124:How to make a table rip fence w/ JB weld! How-To Make Custom Project Enclosures By Hand Arduino LCD Thermostat! 
Add instructable to: