I recently built a circuit to monitor/control the temperature of my beverage dispensing unit. After prototyping and even putting it all together on a board, it works just as I expected. However, when I add the load of the compressor, the negative feedback circuit cycles a few times and then the IC glitches/hangs. The relay I'm using (high trigger) will either remain closed or open when the system hangs leading to either warm or completely frozen beverages. I've used the following components:
Adafruit Trinket 5V
Adafruit MCP9808 (on I2C)
SRD-5VDC-SL-C relay
16x2 backlit LCD with I2C backpack
SparkFun COM-09806 trimpot
I'm supplying power to the trinket5V with USB. The trimpot is used to set the thermostat temp, the setTemp as well as current temperature and relay status are displayed on the LCD, and the relay pin is set HIGH when the temperature reads at least 2degF above the set temp. My first thought is that the relay I'm using is not isolated well enough and is causing a surge to the IC when the compressor is spun up. I am attaching a schematic and a picture of my setup.
Does anyone have any other thoughts? What advice would you give to remedy my problem? Thank you in advance for any help/time you can give!
Please can you provide a schematic showing how everything is connected? What you have provided is not a schematic, it is some components with the connections labelled. We need to see how things are actually wired.
My initial thought is that you seem not to be using opto-isolation on the relay board (most have optos, can't be sure about yours though). That can help reduce interference from the relay switching.
Motors always should have some sort of suppressor or snubber to reduce arcing in the switch or relay - omitting
this will lead to rapid wear or the relay even if the circuit did work.
Another thought is that the layout is not neat and tight - you have loops of wires draped across the relay area, ripe for picking up capacitive or inductive interference spikes. Shielding is often used around low-voltage circuitry to reduce pick-up of EMI, but the first defence is good layout, no loops of wire, separation of low and high voltage areas, star-grounding.