Electronic – Switching relay on and off affects analog sensor output voltage

analogrelaysensor

I am working on an AVR project that involves measuring tempereture with an analog sensor (TMP36) and switching a heater on and off through relay to keep the temperature at desired level.

However, I've noticed that every time I switch the relay on, it causes the output voltage of the sensor to instantly drop, quite consistently by 0.01V to 0.02V (it's up to 2°C difference, so not negligible). To check whether that's AVR related problem or not I have constructed a simple test circuit, shown below. I simply enable the transistor by pushing down the button and observe voltage readings at sensor pins with a multimeter. It still shows the same behavior as with the AVR – switching on relay causes the same voltage drop.

enter image description here

Max current of my power supply is 5A, so it shouldn't be a power related problem.

Another important fact is that it doesn't matter if there's anything connected to relay's switching pins – this behavior seems only to depend on the relay coil being switched on and off.

Best Answer

There is only one, common ground plane, connected to power supply's ground wire.

This is where your problem is, very likely: a common ground between high-power signal path (inductive relay and 3-A heater), and a sensitive sensor which output is referenced to common ground. The effect frequently happens when power and signal ground are shared and routed improperly. This is called "ground bounce". It is not that the signal changes by 10-20 mV, it is the shift in ground potential between the sensor and MCU due to return current flowing form power part of the design.

To avoid parasitic interference of high-current into sensor readings, the grounding should be done as something along the following lines:

enter image description here

The following ground routing is bad: the MCU will read the actual Vout (which is the true value relative to sensor IC ground) plus the parasitic voltage drop along the power plane.

enter image description here