This project will show you how you can create your own programmable thermostat with temperature probe, an LED readout and ability to remote control outlets.

The core of this project is actually a driver for a 4 digit seven segment display.

There are lots uses for such a device. You can purchase something called a PID controller for about $120. The parts for this cost me about $66. If you can scrounge some of the parts you can do even better.
I use mine to control hot water baths for cooking meet. See my instructable on cooking perfect steak for why you might want this.

There are probably a dozen ways to do this. This was my way.

This project requires soldering small surface mount components (well one easy one IMHO). There are a lot of wires and it can be hard to debug certian problems. This is probably not a great project for a novice or the easily frustrated.

At this time the instructable isn't as detailed and foolproof as possible. My prototype works and this is my attempt to document the process. However, until I build my sweet new steampunk themed version, the instructable is going to be a little bit raw. You should be confident about these sorts of projects enough to do some minor debugging of the hardware and connections before you dive in. Just in case I got something wrong, you know. The software is solid at least. :)

Recomended Instructables:
Replace the $20 arduino in this project with $8 worth of electronics.
Generic Micro Controller switch outlets. I embedded this idea into this project. You can just build this stand alone version on hook it up to this project.

UPDATE: 2011-July-28 LM335A sensor version, cheaper, no surface mount soldering.

I am experimenting with replacing the thermocouple and booster with an LM335A sensor. It's not as accurate, and it won't go above 100 degrees C. However it's $1.50 compared to $28 for the thermocouple and booster. For souse-vide cooking it should work fine. There is a PCB123 diagram file in the diagram step if you want to see how to hook one up.
I have also gone to using the Atmega168 chip directly with the minimum hardware needed to support and program it. That's also in the PCB123 file along with a circuit board.
I plan to have circuit boards and solder your own kits available on Kickstarter soon. I am planning a run of 500. The kits will be ~$40 shipped. Let me know if you are interested. The Kickstarter never happened. I did another couple Arduino based Kickstarters and documented the projects on Instructables. Stay tuned, more to come I am sure.

Step 1: Gather Materials

1 X Arduino Pro Mini 328 - 5V/16MHz
1 X Thermocouple Type-K Glass Braid Insulated
1 X Thermocouple Amplifier Digital MAX6675
1 X Wall Adapter Power Supply - 5VDC 1A
1 X Outlet from the home store
1 X SOIC to DIP Adapter 8-Pin
1 X 4-Digit 7-Segment Display
1 X plastic outlet box
1 X extension cord or old computer cord.
1 X Relay SPDT Sealed 5v coil T9AS5D12-5
1 X Rotary Potentiometer - Linear COM-09288
1 X Trim potentiometer (optional)
1 X 2n2222 transistor or other similar switching PNP resistor.
1 X 1uf capacitor
5 X 330 ohm resistor (This used to say 470, but that makes the display pretty dim)
1 X 1N4148 diode
4 ft X Aquarium tubing (the bluish kind that might be silicone)
1 X breadboard, perfboard, circuit board or custom enclosure.
Spring Terminals - PCB Mount (2-Pin) (sparkfun PRT-08073)
Various wire.
Pins for mounting the Arduino. I used the legs off resistors and so on from previous projects, but you can buy some headers.

Coming Soon:
I am prototyping circuit boards for these. I got my first one from BatchPCB not long ago and it worked, but needs some changes to be ready for prime time. Hopefully boards with instructions will be done by end of summer 2011. BatchPCB sure is slow. :)

  • Soldering Iron. (Adjustable is highly recomended)
  • Soldering supplies.
  • Basic soldering skills or a willingness to buy replacement parts as you learn. Soldering the Max chip is the hardest part of the project. It's not too hard to solder to the breakout board. Check out these videos and explanation. http://www.sparkfun.com/tutorials/96
  • FTDI basic breakout or other way to interface with your Arduino chip.
  • Computer to program the chip from.

You can use any kind of Arduino you want. If you get the mini like I did, make sure you have the programming chip or cable. You can also get or make an RBB arduino to shave a few dollars off the project. If you are really ambitious you can hack together an Arduino from an Atmeta chips and parts.

You can find everything electronic at Sparkfun.com. Of course you can shave some cost by sourcing some stuff elsewhere. For example, if you can find a wall adapter in the 5v range at the dollar store or second hand. Etc.

Note that the program I have later works with a button control and not a potentiometer. I will update this soon.

Step 2: Test the Components.

Before you solder this all up, it's a good idea to get it working on a bread board. So, go to the next step, but do it once without soldering on your breadboard.

Once you get connections working, you can start soldering them together.

You can modify the program easily to to cycle through different displays. Don't just use 8888 since you might short some wires and not realize it. Each possible segment has an entry in the segments array, you can cycle through them and each digit to get a good test program going. Try replacing loop with this to get a program that will light each segment in turn.

int _digit = 0;
int _segment = 0;
void loop(){
if(_segment > 7) {_segment = 0; _digit++;}
if(_digit > 3) {_digit = 0;}
lightDigit(digit[_digit], segments[_segment]);

Step 3: Solder It All Together

This is a lot of work. Even with the plans I would give yourself plenty of time to do this. Soldering the thermocouple booster to the breakout is the hardest job here. Sparkfun has some great tutorials on soldering surface mounts. There is only one in the whole project and it's was pretty easy for my first surface mount.

The eagle files are attached, but I don't garantee they are 100% correct. They are a post documentation of my prototype.

Wiring Instructions:
1. Go look at Arduino Controller Relay. There is one embedded in this project. You may wish to just make and test on of those before the rest of this project.
1a. Wire up the relay, 2n2222 and 1k resistor according to the diagram or the other project. Test that a 5v signal can activate the relay. (Before you plug it in please.)
2. Wire all the digits anode connection to a 470 resistor then to an ardinuo IO pin. (Software configurable, but keep notes if you change my wiring recomendation).

Arduino -> resistor -> seven seg

14 (A0) -> resistor - >1
15 (A1) -> resistor -> 2
16 (A2) -> resistor -> 6
17 (A3) -> resistor ->8

3. Wire the segment cathodes to IO pins. Don't use the ones for the colon, decimals or indicator dot.
Arduino -> seven seg
3 -> 5
4 -> 3
5 -> 16
6 -> 15
7 -> 14
8 -> 13
9 -> 11

4. Wire pin 2 to the base resistor on the 2n2222.
5. Mount the MAX6675 on the breakout.
6. Solder the breakout to the arduino pins.
7. Solder the filter cap to the breakout board as close as possible.
8. Solder some wires to the K+ and K- on the breakout board. You won't be able to solder the thermocouple to the board, so don't try. You will need a mechanical connection. Alligator clips are ugly but effective.
9. Wire up the indicator LED to pin 2 with a 470 resistor to ground.

At this point you can plug in the arduino and verify you can get temp readings from the thermocouple, and verify that the indicator led goes off and on when the set point is above or below the setting. See the next step for the code.

The eagle files are licensed under a Creative Commons Attribution 4.0 International License.


Step 4: Program the Chip.

Download the program and upload it to the chip. Update 2011-July-28: I have now put the code in source control on Github:  git@github.com:dustinandrews/Arduino-Thermostat.git has the latest code. This project uses the MAX chip version which is tested and known to work.

The LM335a version is still being developed.

Read the program for some helpful tips.

The code reads and scales the control knob to run between 100 and 200 degrees, which is useful for souse-vide cooking.

This program is mostly a seven segment driver with a little bit of serial reader for the MAX chip thrown in. I got the MAX reader code off the innerwebs, so thanks to the author of that.

See the comments for some different test modes you can enable. Comment the regular code and only run one test mode at a time.

Step 5: Waterproof and Calibrate the Thermocouple

If you want to use the thermocouple underwater, you will need to waterproof it. (or buy a more expensive waterproof one in the first place.) In my application I need a waterproof thermocouple but it doesn't have read fast.

Get a length of silicone aquarium tubing about as long as your thermocouple. Plug the ends and soak in hot water for about a minute. While its still warm and pliable, feed the thermocouple in. I found stretching and relaxing the tube helped the last half go in. Leave a couple of inches at the end.

Cut the end with a hot knife, or tie a knot and hit it with a blow torch for about 1 second. When it's cool, suck on the end hard to check the seal.

When the seal is good zip tie the other end of the tubing to your circuit board for strain relief. Connect up to the board and supply power to the board from the computer.

At room temperature the reading will probably be right on. However, I found the MAX booster chip heats up after about 5 minutes and the calibration gets off. Assuming you want to keep water hot, like me, get a bucket and fill it with water at about 140 deg. F. Put the thermocouple in the bath and wait 10 minutes.

Compare the reading with a reference thermometer. Make a note of the delta and make an adjustment to this line in the program. -10 is my calibration which is about 2 deg. F.

int calibration = -10; //temp calibration compensation * .25deg C

Upload the correction value to the arduino with new sketch.

Advanced Tip: You could add a trim pot to one of the leftover analog ports to be able to trim on the fly. My V2 board will have that.

Step 6: Add the Power Supply and Cord.

Run your cord into the project box (Outlet box). Use one of the side holes so it will sit flat. Hook up ground and the white wire to the oulet as per the outlets instructions.

Hook the black wire to the NO (normally open) post on the relay. Hook the switched post up to the outlet. I cable tied the crap out of these wires to prevent them coming loose and causing mahem.

Add a barrel connector to the project or cut the adapter end off the power 5v supply. Plug it in and measure the ends with a meter and label them clearly. UNPLUG it and solder the leads to the board where indicated. I used a 12v relay and power supply. One 12v supply easily runs my relay and my arduino (RAW port used), but test yours to be sure you have enough power. (I'll be testing the parts I recomend soon. You may need two 5v wall warts, but I doubt it.)

Optionally wire the plug ends directly into the power feeds in the box. The black wire should come from the outlet and not the one that went through the relay, of course. Otherwise you will have two plugs coming out of the project. I ran this way for a while with no problems.

At this point, you should be able to plug the project in, the Arduino should fire up, the LED will show the current temperature, the indicator LED will go on and off with the the outlet depending on the set point.

Step 7: Enjoy Some Temperature Controlled Fun

Personally, I use mine to cook steak. You could also cook Eric's famous beef ribs.

Make sure anything you hook up doesn't pull more amps than your relay is rated for. Small fans and aquarium heaters should be no problem. Air conditioners, fridges and larger heaters may or may not be OK.

Note: Amps is not the same as volts or watts. Amps = Wattage / Voltage. I triple checked my heater before I hooked it up. Be safe and get help if you aren't sure.

<p>First off you have some fairly awesome tutorials sous-vide is pretty <br>interesting a pretty trendy subject for the last couple of years have <br>yet to try it as I prefer my steaks in the non perfect fashion well done<br> and seared on the outside to me they are easier to chew and I prefer <br>the flavor and texture but to each their own. I also read your laser <br>printer tutorial a while back still need to come across a cheap laser <br>printer and settle on the method as well as learn how to use board <br>design software I hear you can use a magic marker to cover the areas and<br> draw traces etc just as well dunno have not tried.</p><p>Anyhow<br> this one kind of was a bummer as I read it through until the end and <br>figured out that I wasted a ton of time do to an incorrect title. This <br>is not &quot;programmable&quot; at all as I am looking at doing things in a <br>programmable fashion.</p><p>programmable would mean that it has <br>programmable settings what you have here is not that it is simply a <br>digital thermostat it is important to distinguish the difference! <br>Programmable thermostats have all followed the same standard up until <br>the NEST type devices which are smart or learnable. This standard as <br>programmable was a weekly timer that was included what is important to <br>me is to learn how to setup several daily timers 48 of them to be <br>precise to be user configurable and operate on a weekly schedule. </p><p>So<br> what is missing from this project is huge the entire &quot;programmable <br>portion&quot; carrying the weekly timer lol! What you have is a digital <br>thermostat more or less from what I can tell after skimming through the <br>code looking for timer code. DOH!</p><p>Anyways you should come join us we could use some good instructables over this way <br></p><p><a href="http://www.esp8266.com/viewforum.php?f=38" rel="nofollow">http://www.esp8266.com/viewforum.php?f=38</a></p><p>Aside<br> from that I think you'd like and enjoy playing with the nodemcu if you <br>have not already there is a wealth of possibility in this one little <br>cheap device if nothing else.<br></p>
Could this code and equipment be adjusted to 100-1000 deg C range?
You can use whatever range your thermocouple is rated for, no problem.
As long as the electronics themselves aren't being exposed to those temperatures...
Nice project! I'm working on something similar, but using PID and a solid-state relay. Tuning is a bit annoying, but the end result is pretty nice.<br><br>I'm also using the MAX6675, have you had any issues with it? I'm getting some temperature fluctuations in the output; I'm thinking it's because my current setup doesn't have a decoupling capacitor for the chip.<br><br>http://protofusion.org/wordpress/2011/01/zoncoffee-2-released/<br><br>
I am using the decoupling cap. It's cheap and easier to install that the 6675 itself. If I take readings in isolation, I see a lot of fluctuations. However if I sample about 10 times a second and average I get really solid, accurate readings.
<br> Ok I'm starting to get a grasp on it now. The relay=voltage controlled switch. So the pot isn't in the wiring scheme&nbsp; above right? But it would just be wired to the Vs, ground, and analog pin on the arduino. But does it matter which one, does it change the code?<br> <br> I'm a bit confused on this part (image below) underneath the thermocouple amplifier. From the Vcc connection from the MAX6675 you have a wire running off into a 'little hole' on its way to the arduino. What is this? is this the Vsupply?<br> <br> Now looking at the leftside of the arduino you have two offset connections. One these ports has a wire runt to another hole just to the right of the one I just asked about. What is this?<br> And just to the right of the one I asked about prior there's a liittle square port that runs a wire seemingly over the MAX6675. I'm confused about what this is too.<br> <br> Last question. How would this thing do using a 9v battery? Would it still work fine, and have a decent 'lifetime.'<br> <br> Sorry if I'm asking dumb questions. I'm ordering the parts this week so I can assemble it next week. I hope I get it working! Thx<br>
1. Correct, the control pot is not on pictures. They are out of date. I will try to post updated ones soon. Check the uploaded eagle files. I think they have it. <br> <br>2. MAX6675 the little holes next to the chip on Vcc and Gnd are to place a capacitor across. It evens out the voltage to the chip. The arduino has one built in. <br> <br>3. The two offset connections are A4 and A5 on a pro mini. That diagram is a copy of the layout of the pro mini that I used for my project. <br> <br>4. Should run fine off +5v to +12v. However, since you are controlling an outlet, it's pretty easy to just put a &quot;wall wart&quot; on the power for the outlet and scavenge your 5v there. Why would you want a battery? a $5 wall wart will keep this thing running forever.

About This Instructable




Bio: "If you want to build a ship, don't drum up people to collect wood and don't assign them tasks and work, but rather ... More »
More by dustinandrews:Quick Coffee Grinder Hummus Make a desktop trebuchet Easy solar furnance with Grid Beam 
Add instructable to: