Thermostat Relay Feedback Problem

Description I'm working on my first arduino project. It's a web-based thermostat. I'm using the ethernet shield to serve a website that I can use to adjust the temperature. I also have physical buttons to operate the unit locally.

For temperature sensing i'm using the DS18B20. The relay has a 5v coil voltage and is rated for 120AC @ 1A. Radioshack 04P09 275-0240 SPDT Micromini

The assembly went well, and I have just about everything working. There is one problem I can't seem to solve. When the propane heater ignites and sparks the propane some kind of feedback is messing with the display. Interference seems to show up on the LCD screen. At that point I unplug it.

I suspect the relay isn't wired properly for the 24ac the heater thermostat uses. Currently I have the relay coil driven from the +5v arduino through a transistor. There are diodes connected in both directions one with a 1K resistor in one direction and the other across the coil in the opposing direction.

I've got this far and I'm not sure what to do next, any ideas would be appreciated.

Photos: http://imgur.com/a/xljhl

Videos: Description of project

Video of the problem

Code: Current arduino code

Other: Website I used for relay wiring

I suspect your protection diode is not well connect with the breadboard. Does it happens with the relay contacts disconnected?

It's possible the diode is not firm in the breadboard. I'll check that. It does not happen with the relay contacts disconnected. It successfully turns the heater on to start the cycle. The problem occurs when the heater gets to the step of firing the propane igniters.

If it doesn't happen with the relay contacts disconnected the diode it's ok. It might be the high voltage pulse from the igniter. The wires you have there are like aerials and the pulse is took to arduino and lcd.

You might try to add additional filters (100n capacitors) to each board and to have a longer distance between arduino and the sparks.

Good luck

Sometimes this sort of thing is caused by mains-borne interference from the device being controlled to the Arduino. Do you still get the problem if the Arduino is powered from a 9v battery instead of a wall wart?

Also worth checking is whether it is just the display that is not working or the whole system. If you leave it running after the display has become garbled and warm the temp sensor, does it turn the heater off?

I'll definitely try a 9v battery this weekend, but i'll need it to run off the wart eventually.

I do believe the arduino continues to process after the interference happens. I'm still able to interact with the website it is serving.

Should I be looking at an opto isolator? Someone mentioned that on the reddit post i did. http://bit.ly/AEhCzJ

Your relay already provides isolation. I don't think an opto isolator would help.

Do you clear the display at the start of each update, or do you only rewrite the areas that may have changed?

I redraw the LCD every loop() cycle.

I haven’t been able to check if a 9v battery helps yet. If it does stop the feedback, will i need to power the relay coil (5v nominal) with a separate power supply?

Thanks

projectstew:
I redraw the LCD every loop() cycle.

What exactly do you mean by “redraw”? Do you mean you clear the screen and redraw everything, or just parts? Does the corruption remain in the part you redraw, or does it get overwritten with the right characters when the redraw happens?

projectstew:
I haven’t been able to check if a 9v battery helps yet. If it does stop the feedback, will i need to power the relay coil (5v nominal) with a separate power supply?

No, it should be possible to filter the mains and/or power supply output to resolve the problem. But testing with a battery is the easiest way of telling whether this is the cause.

What exactly do you mean by "redraw"? Do you mean you clear the screen and redraw everything, or just parts? Does the corruption remain in the part you redraw, or does it get overwritten with the right characters when the redraw happens?

My program calls a function that outputs text to the LCD on every loop cycle. Here's part of the code:

   lcd.setCursor(0, 0);     
   lcd.print((int)temperatureF);   lcd.print("F/");     
   lcd.print(DesiredTemp); lcd.print("F ");
   lcd.print(" Hits: ");lcd.print(hit_counter);

This part writes out the top line of the 16x2 display. I writes all 16 characters every time, so i'm considering that a full redraw. Once the igniters have fired all characters on the LCD at gibberish. They remain that way even after I turn the heater off. The arduino does continue to function. Even though the screen is garbled I can still access the website, and use the buttons to change my target temperature. The LCD display never returns to normal until I do a full power cycle on the arduino.

No, it should be possible to filter the mains and/or power supply output to resolve the problem. But testing with a battery is the easiest way of telling whether this is the cause.

I connected a 9v battery to the arduino and started it up. When the igniters started, I experienced the same issue, garbled LCD characters. Does that eliminate the mains-borne interference theory? Any other ideas on what I should be looking at?

OK, it looks like it is the LCD that is picking up interference, and that interference is not mains-borne. Perhaps the wiring between the lcd and the Arduino is picking up RF interference. Try twisting all the wires between the LCD and the Arduino into a bundle (the backlight wires probably don't matter). The idea is to minimise the area of the loop formed by the path from the Arduino output pins to the LCD data/control pins and back through the ground wire to the Arduino. The bigger that area, the more easily the wires pick up interference.

[EDIT: I also recall that somebody with a similar problem reported that adding a 10uF capacitor between Vss and Vdd pins of the LCD solved his problem.]

I tried shortening the lines and twisting them. The issue remained. I bought some capacitors today but im confused. If I put a 10uOhm cap between Vcc and Vdd won't I short out the circuit?

Another new development: When I was looking at the new capacitors I had the arduino thermostat on but not plugged into the heater. The old thermostat kicked the heater on, and when the igniters fired the lcd went garbled. So, its happening with the arduino not even plugged into the heater. Could there be enough emi from the igniters to interfere with the arduino across the room? If so, what should I be looking at for sheilding?

Thanks

projectstew: I tried shortening the lines and twisting them. The issue remained. I bought some capacitors today but im confused. If I put a 10uOhm cap between Vcc and Vdd won't I short out the circuit?

A 10uF capacitor between Vcc and Vdd (i.e. between LCD +5v and ground) is fine provided that you have the + and - terminals the right way round.

projectstew: Another new development: When I was looking at the new capacitors I had the arduino thermostat on but not plugged into the heater. The old thermostat kicked the heater on, and when the igniters fired the lcd went garbled. So, its happening with the arduino not even plugged into the heater. Could there be enough emi from the igniters to interfere with the arduino across the room? If so, what should I be looking at for sheilding?

It's worth repeating this experiment with no connection at all between Arduino and mains power or anything else, i.e. Arduino running from a battery, no Ethernet or USB connection, power supply to relay unplugged. If the LCD still gets garbled, it's EMI. If it doesn't, it's mains-borne interference. If it is EMI then twisting the wires in a bundle is important, and after that I would try putting a metal plate or metal foil just under the LCD circuit board, connected to LCD ground and insulated from the circuit board.

projectstew: IAnother new development: When I was looking at the new capacitors I had the arduino thermostat on but not plugged into the heater. The old thermostat kicked the heater on, and when the igniters fired the lcd went garbled. So, its happening with the arduino not even plugged into the heater. Could there be enough emi from the igniters to interfere with the arduino across the room? If so, what should I be looking at for sheilding?

Make sure your heater is properly shielded (the coil and the igniter). You may try to connect the heater ground to AC ground.

dc42: It's worth repeating this experiment with no connection at all between Arduino and mains power or anything else, i.e. Arduino running from a battery, no Ethernet or USB connection, power supply to relay unplugged. If the LCD still gets garbled, it's EMI. If it doesn't, it's mains-borne interference. If it is EMI then twisting the wires in a bundle is important, and after that I would try putting a metal plate or metal foil just under the LCD circuit board, connected to LCD ground and insulated from the circuit board.

Good thinking. I did the test again, with the arduino completely isolated and powered by the 9v battery. When the heater, driven by the old thermostat, started it's igniters there was no interference on my LCD.

So that leads me to conclude the mains-borne is through the signal line to the heater. I just did some googling for a filtering mechanism, but only found a few items for sale ~90usd. I'm going to put the capacitor on now and see how that goes.

Might be worth trying one of those "surge protected" socket strips to power the Arduino and its power supplies and any PCs, network switches etc. that are connected to it.

Also, you could try to find out what has to be connected to the Arduino to make the problem occur.

I did a couple more rounds of testing:

Any time the heater wires are connected to the arduino, the interference occurs. Powering it by battery and disconnecting the ethernet has no effect on the interference. Just for kicks i plugged the wall wart into a surge protector with no positive result.

You mean the the heater wires connected to the relay, right? Maybe its time for a schematic so we can make specific recommendations...

AndrewStone: You mean the the heater wires connected to the relay, right? Maybe its time for a schematic so we can make specific recommendations...

Here's the schematic. This is my first attempt at drawing a circuit and using TinyCAD. Let me know if anything is not clear.

There are a couple of things wrong with your schematic:

  • Push buttons won't work as drawn
  • NPN transistor marked "therm" shorts +5v to ground when the pin it is connected to is driven high (but I'm guessing it's really a temp sensor chip)

From your previous post, I gather that the LCD is OK if you don't connect the Arduino to anything else, even when the original thermostat fires the heater up. However, from that starting position, if you connect the 24v wires from the relay to the heating system, then the problem occurs even though it is the original thermostat that is turning the heater on. Is that correct? If so, I suggest the following:

  • Make sure that the wires to the relay contacts are not shorting against anything else, i.e. the relay really is providing electrical isolation
  • Keep those wires well away from the LCD. It may be worthwhile relocating the relay some distance from the rest of the system, then you can keep the wires running to the relay contacts further away from everything else.
  • Consider using shielded cable for the wires between the relay contacts and the heater, but make sure it is rated to carry the current.