/ IoT

Arduino thermostat for a 'passive' 24VAC HVAC system, Part 2

So How are We Going to Build This Thing?

It was time to start building my thermostat. As I mentioned in part 1, I had purchased the Ardunio Starter Kit, which contained the Arduino Uno -- an Arduino which is pretty ideal for this project -- a healthy number of input and outputs to deal with the temperature readings, plus room to grow for things that will be needed for the final build such as damper control, user interface buttons, a display screen, etc. So I ripped apart all of my experiments, and got to work laying out the new circuitry.

Now, before I could complete all of the wiring, I was missing one critical piece -- a relay. As described in part 1, I needed to control a damper -- basically, a shutter that sits inside the duct and can be opened or closed by rotating an axel.
Duct dampers
The controller for the damper -- i.e., the motor which rotates it open or closed -- has three connectors: Mc1 (common/ground), Ro2 (open) and Rc3 (close).
Damper controller
This controller is driven by 24V AC. When electricity is applied to Ro, it opens the damper. When applied to Rc, it closes the damper. Now, it turns out, trying to drive something this large directly from an Arduino (using the GPIOs) is generally a 'bad idea', but, in this case, it was essentially impossible because the controller uses AC and Arduinos are DC. Hence the need for a relay -- an electronic switch which can be turned on and off by the Arduino's low current, 5V DC, yet which can switch larger loads and handle AC. The two electric systems (the Arduino on one side and the 24VAC on the other) remain electrically isolated.

Now, as a novice reading the Arduino Starter Kit's guide, it was tempting to solve this problem using an opto-isolator. Heck, the kit even includes some! Stated simply, an opto-isolator uses a light source (generally, an LED) on one side and a photoreceptor on the other to make an optical switch -- when the LED is on, that activates the photoreceptor, closing the switch on the other side. Therefore, the opto-isolator is a switch with the two sides electrically separated from one another.

opto-isolator

But my gut was that this wasn't a 'safe' thing to do, especially with the cheap opto-isolators in the kit. Most electronic thermostats I have owned contained relays -- you could hear them 'click' when they turned on -- so I figured there was a reason for that. (Although the magic thermostat I was replacing did not making a clicking sound...more on that later.) A quick jump over to some Ardunio forums and, sure enough, people told me to use relays for various reasons of load, isolation, etc.

It was at this point that I got myself into a little bit of trouble because I didn't doing a full investigation of how the damper controller works. Well, not so much 'trouble' as simply wasted effort. The first thing I did was apply, by hand, 24VAC to Rc (with Mc connected to ground, of course), to see what would happen. Sure enough, I heard the damper closing (remember, all of these parts are already installed in the duct in the ceiling, so I cannot easily just take them out and look at them). Doing the same to Ro, I could hear it opening. But I assumed that I needed to only apply voltage to Rc or Ro long enough for the damper to open or close. I was worried that if I kept applying the voltage, the motor would burn out, struggling to close or open a damper which was already fully closed or open. So I sat there, alternatively applying 24 VAC to the two inputs, and counting how long it took the damper to open and close. My plan was then to use that logic within my Arduino code -- when it was time to open the damper, turn on the 'open' relay, do so for however long it took (I counted about 45 seconds), and then turn off the relay, thereby stopping the motor.

This was an utter waste of time.

The damper controller that I had was smart enough to deal with this all on its own. If want the damper open, apply 24VAC to Ro and "walk away." You can apply the voltage for 45 seconds or 45 minutes or 45 years -- it really doesn't matter. The controller knows when to turn off the motor (probably by detecting the mechanical resistance in the rotation).

If you read the past few paragraphs carefully, you'll may have noticed the 2nd rookie misunderstanding that I had. I made reference to the Ro relay, suggesting that there is also an Rc relay in my design.

Relays and My Lack of Understanding

Conceptually, relays are very simply. In actuality, there are still pretty simple. But I still made mistakes. My first mistake was assuming that I needed two relays -- one to drive Ro to open the damper, and another to drive Rc to close the damper. I also had some ideas for enhancements to my project which would require at least one more switch, so I decided that I needed at least 3 relays.

I ended up selecting the J-Deal 4 Channel 5V Relay Module shield. It had 4 relays, so I was covered for the 3 I needed, and the current needs of the 4 relays was low enough that an Arduino Uno can switch all 4 relays on at the same time.
J-Deal® 4-channel 5V Relay Module Shield with Optocoupler for Arduino UNO
I liked the fact that the relays were themselves driven by opto-isolators -- so the electric isolation between the 24VAC and my Arduino was about as good as it was going to get.

But notice the blue, screw-type wire connectors on the output side of the relay -- there are 12 of them. 3 per relay. Hun? An electrical switch only needs two wires. Why three? And here's where I had one of my 'ah ha' moments. Each of these relays has two outputs, plus ground. One output is the 'normally open' state and the other is the 'normally closed' state. When the relay is 'off' (no input voltage is applied), the normally closed connection is hot. Turn on the relay and it switches to the 'normally open' connection. So, one relay can drive two things, provided those two things are always in the opposite state (on and off).

Which is exactly what the damper controller needs -- you either power Ro to open the damper, or Rc to close it. There is no need to ever power both at the same time (in fact, I'm guessing that would be a bad idea). So instead of needing 2 relays to controller the damper, I only need 1. And given my desire to have 1 extra relay for expansion, I could have gotten away with a 2 relay module. Oh well, live and learn.

Remember when I said the magic thermostat I was replacing never made a clicking noise? That's because there are solid state relays which do not have mechanical parts. I actually identified it within the magic box, but I was confused because looking up that part online suggested to me that it did not have enough outputs. Now I know why I was confused -- I assumed you needed two outputs to drive Rc and Ro, but I now realize you only need one. Maybe at some point in the future I'll remove that relay from the magic box and use it in a future revision of this project.

Okay, I was finally in a place to start the initial construction and write some code. I had all of the necessary temperature readings. I could open and close the damper. Nothing left but the doing. More on that in part 3.