Hello everyone! Today I purchased my first Arduino components. I haven't really dabbled with DIY electronics for 20 years; when I was a kid I had one of those 200-in-1 radio shack kits and managed to do pretty well with it.

Arduino is something that has always had my attention and I have wanted to play with but never found a reason to use. I'm the kind of person that needs to solve a problem. Last week my fairly new, expensive, programmable HVAC thermostat died. It was hot out so I quickly looked up the wiring diagram, jumped some of the wires and enjoyed cold air. XD - Enter the Arduino!

I dug around amazon and came up with a quick list of stuff available on Prime (Inventory at the bottom)

I know nothing about Arduino, but chose the Uno because it seems to be the most used in projects of this size. Would a nano work for something small like this?

I'm very excited about all of this and look forwarding to keeping this log updated. That's all the data I have for now, I have a ton of research to do. If anyone has comments, thoughts, ideas, or links to existing projects that would be beneficial to me please post them up.

draythomp

I started my adventure with thermostats in much the same way. Things to consider:

You only need three relays and the current that they need to control is pretty low ... think small.You need to power the device, where you gonna put the wall wart?Controlling it locally is nice and traditional, do you want to control it remotely?Suppose you put the electronics with the air handler where the transformer is and only the sensor at the old thermostat location (this probably requires remote control)Once you cobble it together, what are you going to put it in to make it look good? You're going to want to show it off ... aren't you?Light sensor ?? Need to turn it down at night or something?Humidity sensor ?? It would be nice to know, but what do you need it for?How many wires do you have at the control point? Would it be possible to pump power for the board that way?How big a piece of the wall do you want to take up?Remember, you need to be able to read the display at night; LED displays are nice for that. But some of them are really irritating at night (note, red sucks)For a first project, graphic displays take a lot of work. Think letters and numbers. (if you remote it, you can use a web page)Programmable is nice, but remember you have to create the user interface. How are you going to ask for input from the thermostat. Setting temperature can be a real pain if you have to push a button 25 times to do something.

This is just the stuff I came up with on the spur of the moment, the real list is much, much, longer. Shoot, what are you going to do in the case of a power failure? What defaults are you going to have. How do you get the time into the thermostat and how are you going to keep it correct?

I'll stop now. I've been through this and just want to ease the field for you.

Hey! I was partly inspired to do this project after seeing your site earlier this week. It's great to have your feedback.

Nothing super surprising to me in your list but let me go over it for the viewers at home;

* I got the big relay board because it was cheap and I know I'll use it for other projects in the future. For this small project I plan on moving to solid state relays once I've got it stabilized a bit. * Power: My thermostat is directly above a 110 outlet so I can easily power it from that, or run some low voltage wire through the wall to the existing hole where the HVAC cables run. (I'm not sure how the power source from the HVAC works, if it's always on, etc. It's probably enough to run the bits I'm adding. Investigation needed)* It will look good. Don't worry. I take a lot of pride in making these sorts of things look like artwork. * Light and Humidity; Probably not in use for this project. They were a few dollars and I knew I'd have fun with them. There are many days in the spring/fall where the temperature in the house is fine, but it's just a bit muggy and I want to run the AC for 5 minutes to dry it out a little bit. (Thought; maybe I just add a button that runs the AC for 10 minutes... something like that)

* Display. I want to show what modes are in use; AC, HEAT, FAN. I want to show actual temp, and the set/target temp. As far as user input, I'll default to 70f and just have buttons for up/down. I usually never go outside of 68-72 unless I'm gone for long periods of time.* I'm thinking some small toggle switches to select modes.

I would really like to make it controlled by a simple web interface. Not sure what kind of effort that will be.

draythomp

I don't want to monopolize the thread, so I'll keep it short. Build something pretty simple at first, then use it a couple of weeks. When you get some experience, then go completely nuts and make it really cool. A really neat way to show what mode it's in is with a colored led display: red letters for heat, green for only the fans, blue for A/C, and of course, white for idle. If I hadn't taken mine to the web for control, that's exactly what I'd do. Adafruit has that kind of display and remember, serial displays are really easy, parallel ones will drive you nuts with connections. Graphic displays can wait until you understand web controls, do graphics on something you can see like a tablet or phone.

@LVLAaronDisclaimer:Be sure you have a very good understanding of your HVAC system sequence of operation before using this as a controller. There are some very important safeties that must be used. If this is a gas furnace, there are rollout switches and induced draft fan safeties that are in place to keep you from dying in a fire or from CO poisoning. If it's all electric, you need limit switches so your heaters turn off in the event of a blower failure.

Project/funIt sounds like a very interesting project. Draw up a clear objective for your project. What are the features you want? Start small, and work your way up. Once you're confident that the basics are working properly and safely, start adding some bells and whistles. Have fun, be careful.

@LVLAaronDisclaimer:Be sure you have a very good understanding of your HVAC system sequence of operation before using this as a controller. There are some very important safeties that must be used. If this is a gas furnace, there are rollout switches and induced draft fan safeties that are in place to keep you from dying in a fire or from CO poisoning. If it's all electric, you need limit switches so your heaters turn off in the event of a blower failure.

Safety is important, but are these things relevant to a thermostat replacement? On my HVAC at least, such things are encapsulated in its own control boards: the thermostat asks the HVAC to provide heat or cooling - it's up to the HVAC to 'decide' whether it's safe to comply.

draythomp

If you have a heat pump, you'll have a wire for heat/cool, a wire for fan, a wire for compressor, 24vac, and common. Sometimes they don't carry the 24vac to the thermostat, you'll have to check that. Just prowl around the web, find a thermostat schematic, and you're ready to go.

It's a little different if you have a furnace/AC, but the same idea. Find a schematic for the thermostat and steal the ideas.

Action shot #2 - Added code to determine if ambient temperature is above or below a static "target" temp. The LED's have been added to indicate which side of the target the air is at. Also wired in the relay board. Relay 1 and 2 act in concert with the red and yellow leds.

Next steps for me; * User input for target temperature instead of being hard coded. Display this on the LCD.* Work on temperature "swings". In HVAC speak, if you are in AC mode and have your temp set at 72, the swing is usually 1 to 3 degrees. Let's assume our swing is 1 in this case. This means that when the ambient room temp reaches 73 the AC turns on, and runs until it cools the air to 71 degrees. 1 degree of "swing" in either direction of the target temp.

* Further down the road, overrun protection. It's not good to have the compressor turn off and then turn it back on in quick succession. Need something in the code that says if the unit has been running in the last 10 minutes, to not run until 10 minutes has passed.

Some clearer names might be nice. ACledPin is ok, in context, so is HTledPin but you wouldn't have to think about it if it were HeatLedPin. As for Relay_01 and Relay_02 - really! Shouldn't analogValue be Termperature or TemperatureF?

These things don't really matter, especially in such a small sketch but they make it slightly harder to work with and spot bugs. As the sketch gets bigger, that will become more important.

delay(1) doesn't serve any useful purpose now - that delay(2000) is doing its job.

Finally, why do you use DHT11.fahrenheit() to get the temperature for printing to the LCD when you already have it in analogValue?

was hoping that I could have two different things going on; a 1 second delay for the serial output and a 2 second delay for the screen refresh. Not possible?

It's possible, but not using delay. You'll need to use millis instead - the blink without delay example in the IDE shows you how to manage it. You'll need to use millis (or a RTC) when you get to the point of ensuring the compressor doesn't cycle too often. Also, use of delay will make your code unresponsive to the user when trying to change the set point.

draythomp

Nobody ever listens to me when I tell them that the way to handle delays and timers is with the Time and TimeAlarm libraries. You can set a timer to fire every two seconds and update the display. This will run without any delay() calls and leave the processor free to do something else, like check for user input. Doing it for a second is a bit iffy since that's its smallest granularity, but most often, we don't need a second, we need a delay of some kind and we just choose a second. Yes, you can have multiple timers and alarms.

I use this set of libraries extensively to handle changing displays, where I show something for a couple of seconds and something else for a couple of seconds. I also use it to have things report on a schedule; whether they report hourly, daily, every 10 seconds, etc. I have it turn things on at 8 and off at 10. It just works. If you don't need the actual time, just set it to whatever comes to mind, it will keep time and establish timers and alarms from there. I sync my stuff up off a GPS chip, but you certainly don't have to be that extreme.

A very tiny bit hard to understand at first, but once you use it, it turns out to be incredibly easy. You can turn a simple arduino into a multiprocessor pretty easily (albeit, a slow one). But, like I said, no one listens to me when I talk about it.

For temperature readings, I use a moving average of several readings. Temperature sensors can react too quickly to breezes and such for use in a home thermostat, so I slow them down a bunch by sampling a lot and averaging. I don't usually put delays in the read because I want the processor available for other things delay() locks everything out except interrupts.

Here in the desert I use a hysteresis of -2,+1 in the summer and -1,+2 in the winter. That was after trying about a jillion different things that kept the compressor on too long or cycled it too rapidly. This is something you'll have to experiment with, so make it a value you can change on the fly. Of all the weird things I ran into, the proper hysteresis curve was the most annoying.