loading

This instructable will cover how to make a simple thermostat using an arduino, and other electronic parts! Before starting this project I had very little experience with an arduino. In a class I was taking, I was given other projects (make an LCD screen work, measure the temperature of a lightbulb, use push button to make an LED light up), and our final project was to somehow incorporate all of these components together in one arduino project.

So given this objective, I set out to learn how to combine not only the components, but the coding that took place in making this project. Originally I wanted to make a thermostat which measured the temperature of a high powered lightbulb because that would be able to get much hotter than a regular LED. The idea was that there would be two threshold temperatures, a low and a high, and the goal was to keep the light bulb's temperature between those two thresholds. This involved turning the lighbulb on until it hit the maximum threshold (tH), turning it off when it went over tH, and turning it on again when it went below the minimum threshold (tL).

Before this project I was very intimidated by the idea of working with circuitry and electronics in general. Even though i had worked with all of these components at some point before (in the class) it was still very daunting putting them all together. This project really pushed me to learn about a lot of different electronic components (I had never heard of a MOFSET before!), and to learn how to write my own code and personalize this! I am so glad that I got the chance to explore just one of the possibilities that Arduino can offer!

This was a great way to incorporate many different types of parts in a circuit and gain experience coding an arduino! This instructable will teach you how to wire push button switches, piezo electric speakers, and give you a more thorough knowledge about thermostats!

Step 1: What Is a Thermostat?

A typical thermostat's function is to regulate temperature within an area. Usually thermostats are connected to some sort of heating or air conditioning unit so that they can turn on one or the other, depending if the area it is regulating is too hot or too cold. Let's say, though, that your room is very hot, but within the "acceptable" range that a thermostat will allow before it activates the air conditioning. You can trick your thermostat into thinking that the area it is regulating (your room) is warmer than it actually is by placing a small heat source directed towards the thermostat in order to simulate a room that is warmer than in reality. Alternatively, place a cool object (refrigerated cheese stick?) on top of the thermostat in the winter to trick the thermostat into thinking it is colder in the area, and consequently activate the heaters!

Another type of thermostat is the bimetal thermostat. A bimetal thermostat uses a bimetallic strip (a strip consisting of two metals). These two metals have different expansion rates, triggered by thermal stimulation. Essentially, when the strip is heated to a certain temperature, one of the metals expands more than the other causing the strip to bend one way, and when it is cooled bends the other way. On a bimetal thermostat, the strip is fixed on one side, and the other side contains an electrical contact. When the strip is cool, it remains in contact with the current. Once the current becomes too hot, however, the bimetallic strip bends away from the contact and stops the circuit until it is cool enough to bend back and make contact once again.

Step 2: Parts

Here's what you will need to make this cool project in full:

1. 1 x LCD screen

A Liquid Crystal Display (or LCD) is used to display information electronically.

2. 1 x 12V lightbulb

The lightbulb is used as our environment for the temperature sensor to detect.

3. 1 x MOFSET Transistor

A metal-oxide-semiconductor field-effect (MOFSET) transistor actuates a 12V 5-Watt light bulb (like the one listed above!).

4. 1 x Piezo-electric buzzer

The purpose of the Piezo electric buzzer is to generate sound. It can generate a range of
frequencies, depending on the frequency of the wave that is sent.

5. 3 x push button switches

The purpose of these switches is to alter the tL and tH values. By pressing the switch on the right, the temperature threshold will increase by 0.5 degrees. By pressing the switch in the middle, the temperature threshold will decrease by 0.5 degrees. By pressing the button on the right along with either the high temperature button or the low temperature button, the threshold will raise or lower by 5 degrees.

6. 1 x Temperature sensor

A temperature sensor is used to detect the temperature of the environment around it, in this case, the light bulb.

7. 3 x 10,000 (10K)-Ohm resistors

8. 1 x 1,000 (1k) - Ohm resistor

9. Arduino Uno

10. Wall outlet plug for Arduino

Because we are using a more powerful lightbulb, your computer's USB port cannot produce enough power to light it up to it's full capacity. You need an adapter to provide adequate power!

10. Breadboard

11. Jumper wires (about 25 or 30 should do. You will need some shorter, some longer ones.)

Step 3: Wiring

Now we get to get our hands dirty (not actually, clean hands are always good when dealing with electronics!). I attached a picture of a flow chart I made to help me better understand the main objectives of this project, and how all of the components will interact! This diagram helped me immensely while wiring components as well as when I was writing the code!

I attached a handy wiring diagram so that you could see where everything goes! I would start by placing the LCD screen in the breadboard off to the side. It takes up the most space, so be sure that you leave enough room for the other components as well!

The pins on the LCD are designated 1-6 (the rightmost set of pins in the picture, right to left), and 11-14 (the leftmost pins in the picture, right to left again). Pins 1 and 5 connect to 5V with pin 2 connecting to ground, while pin 3 controls the contrast level of the LCD, which, in this instance is connected to ground with a 1K-Ohm resistor (another alternative is to connect it to pin 9 of the Arduino and use the “analogueWrite” command in the program to manually control the contrast). Pins 4 and 6 connect to Arduino’s 12 and 11 pins, respectively. Pins 11-14 connect to the 5-2 pins on the Arduino, respectively.

Now go ahead and place the MOFSET transistor next to the LCD screen. The left hand side of the MOFSET is the Gate pin, and should be connected to the Aruino's pin 10. The middle is the Drain pin, and is connected to the light bulb, and the right most pin is the source pin. This is connected to ground on the breadboard.

Now place the lightbulb and temperature sensor. The leftmost pin of the lightbulb is connected to the drain pin of the MOFSET transistor while the rightmost pin is connected to the high voltage output of the Arduino. Be careful when working with voltages, and also take note that when this lightbulb is on for any period of time that it can get extremely hot! Take proper safety precautions and give it some time to cool down when it has been on. When you place the temperature sensor it is important to get an accurate reading, so make sure that it is as close to the lightbulb as possible, but don't let it touch! The lightbulb can actually get hot enough to melt the plastic casing on the sensor! The leftmost pin of the temperature sensor connects to ground, the middle pin connects to the Arduino's A0 pin, and the rightmost pin is connected to power in series with a 1K-Ohm resistor.

Now place the push button switches! I used 2 pin switches, and connected one side to voltage, and the other side to a 10K-Ohm resistor connected to ground, as well as Arduino's 6, 7, and 8 pins (on the same side as the ground). See the photos above for more clarity.

The last step in wiring is the Piezo electric buzzer. It has two wires; the red one is connected to Arduino's pin 9, and the black one is connected to ground.

That's it! Now let's get coding!

Step 4: Programming Your Thermostat!

Now we get to code our thermostat. Open up the Arduino App (if you don't have it, it's free! Download it here: https://www.arduino.cc/en/Main/Software)

I'm going to post the code, and use the photos to explain what is happening at all the stages.

#include

double refV;

double tL=25;

double tH=tL+1;

const int button6 = 6; //this button brings temp up

const int button7 = 7; //this button brings temp down

const int button8 = 8;

int speakerPin=10;

int numTones = 5;

int tones[] = {261, 294, 330, 370, 415};

int button6state = 0;

int button7state = 0;

int button8state = 0;

LiquidCrystal lcd(12,11,5,4,3,2);

void setup()

{

pinMode(button6, INPUT);

pinMode(button7, INPUT);

pinMode(button8, INPUT);

pinMode(10, OUTPUT);

pinMode(13,OUTPUT);

lcd.begin(16,2);

lcd.setCursor(0,0);

lcd.print(tL);

lcd.print(" to ");

lcd.print(tH);

analogReference(DEFAULT);

refV=5;

pinMode(13,OUTPUT);

Serial.begin(9600);

Serial.print("tL is: ");

Serial.print("\t");

Serial.println(tL);

Serial.print("tH is: ");

Serial.print("\t");

Serial.println(tH);

Serial.print("temp(C)");

Serial.print("\t");

Serial.println("status");

Serial.println("________________");

Serial.println("Beginning of Data: ");

}

void loop()

{

int acc=0;

int N=10;

for(int i=0 ; i < N; i++) {

acc +=analogRead(0); delay(10);

}

double voltage= refV*acc/1023./(double(N));

double tempC=(voltage)*100.;

lcd.setCursor(0,1);

lcd.print(tempC);


button6state = digitalRead(button6); //code for button 6

if (button6state == HIGH)

{

tL = tL + 0.5;

tH = tH + 0.5;

lcd.setCursor(0,0);

lcd.print(tL);

lcd.print(" to ");

lcd.print(tH);

for(int i =0; i <numTones; i++)

{

tone(speakerPin, tones[4]);

delay(30)

}

noTone(speakerPin);

}

if(tH > 55)
{

for(int i =0; i<numTones; i++)

{

tone(speakerPin, tones[0]);

delay(100);

}

noTone(speakerPin);

tH = 55;

tL = 54;

for(int i = 0; i < 3 ; i++)

{lcd.setCursor(9,0);

lcd.print(" ")

delay(300)

lcd.setCursor(9,0);

lcd.print(tH);

delay(300);

}

if(tL < 20)

{

for(int i =0; i<numTones; i++)

{

tone(speakerPin, tones[2]);

delay(100);

}

noTone(speakerPin);

tH = 21;

tL = 20;

for(int i = 0; i < 3 ; i++)

{

lcd.setCursor(0,0);

lcd.print(" ");

delay(300);

lcd.setCursor(0,0);

lcd.print(tL);

delay(300);

}

}

if (tempC<tL)

{

digitalWrite(13,HIGH)

}

if(digitalRead(13)==HIGH)

{

Serial.print(tempC);

Serial.print("\t");

Serial.println("1");

}

delay(50);

}

Step 5: That's All!

Once this code is in Arduino, go ahead and click the checkmark in the top left hand corner to verify this code! It should definitely work but those semicolons seem to get you every time. Then, select your Board and Port and click the arrow button to upload it to your Arduino! Your lightbulb should turn on, and off, and on again depending on the temperatures it reaches, and the thresholds you have set for it!

While working on this project i learned a great deal about circuitry and how Arduino's worked! I found a lot of functions that I didn't realize the little guy could do all at once! Hopefully this instructable was able to let you make a cool (heh) thermostat as well!

Thanks, this is a good beginner project for arduino!
<p>Great instructable, looks like a nice introductory Arduino project!</p>

About This Instructable

1,171views

18favorites

License:

Bio: Ashley hails from beautiful, sunny, Idaho--what am I saying? Ashley is actually a potato that has experienced intense genetic modificaiton. Idaho does not exist. I ... More »
More by ash_doge:Cheese Press Decorative Bread $3 Fridge Shelf 
Add instructable to: