I originally built my thermostat back in 2013 when I lived in CA. It worked fine for a few years. Since buying my house here in MN in March, I have had nothing but problems with the system freezing. Often with the heat stuck on.
The furnace in CA was just a wall furnace. I don't think it was even hooked up to a power source. I have no idea what voltage was on the thermostat wire. Just shorting them together turned the heat on. It's the same at my house now, but its a forced air furnace with a control board.
I have racked my brains trying track down the source of the hanging from completely revamping the code, micromanaging memory, replacing the entire protoshield, switching from a mega2560 with ethernet to a Yun shield on the mega, adding a flyback diode to the relay, pullup resistors on the I2C bus, driving the relay from a transistor instead of from a digital pin.
My question is can the 24vac from the furnace cause RF interference ?
There are 2-relay boards like that. I have one next to my furnace and twisted-pair wire from my Arduino to the optical-isolated input. I use it to turn the heat up before I get home..
Basic test: if you disconnect the 24VAC wiring does the system work reliably?
You might want to step back a minute before you have to buy another control board for the furnace.
There are some micro-volt heaters that use a wall switch to turn ON/OFF, which is just shorting the two wires together.
Forced air furnaces are a different ballgame. and the 24VAC is used to power the relays on the control board. To further complicate things, there are different types of wiring for various furnaces controlling heat pumps, AC, emergency heating, main heat
Perhaps you should include a schematic on how you have this wired up
The current in the 24VAC circuit is probably only 15 to 20 mA (to pick up a relay in the furnace controller) and shouldn't be enough to cause EMI, as @aarg said, you should have an off delay that would prevent a heat pump compressor from restarting before head pressure has enough time to bleed away, also a fuel fired burner should have enough time to cool before trying to restart. I would put a TVS diode or MOV of proper voltage rating across the relay contacts.
Thank you for all the replies. I'm downloading some schematic software right now and I hope to have a schematic for you all soon.
Until then, here is my sketch as a zip file.
An interesting thing occurred this morning. While the relay was closed (heat on), I plugged in the thermostat wire to its socket on the protoshield and the system froze. Instantly. However, I could not replicate this issue by trying it again.
It's an improvement. You still don't have Gigs of RAM to play with like on a PC. You could put the String idea on the back burner and focus on hardware because you said you witnessed a wiring related crash.
How often does it crash? A simple attempt to suppress EMI might do it. Have you tried a 0.1uF capacitor across the relay contacts?