Karnataka KSEAB II PUC Electronics and Hardware (Vocational) study materials
Karnataka KSEAB II PUC Electronics and Hardware (Vocational) study resources

LM35 Reading Jumps 7 °C When the Heater Relay Clicks

Karnataka KSEAB II PUC Electronics and Hardware (Vocational) · Put your knowledge to work in context.

All case studies

LM35 Reading Jumps 7 °C When the Heater Relay Clicks

A team builds a greenhouse temperature logger with an LM35 sensor, a 10-bit ADC, and a 5.0 V reference. The LM35 output is 10 mV/°C and is connected to the ADC through 1 m of unshielded cable. The sensor ground and the relay that switches a heater share the same return wire near the microcontroller board. With the heater off, the display reads 25.0 °C. When the relay energizes, the reading jumps to 32 °C and sometimes falls to 23 °C; averaging eight samples reduces the jump but does not remove it. The ADC code at 25.0 °C is 51. The team has 100 nF and 10 µF capacitors, 1 kΩ and 10 kΩ resistors, a twisted pair cable, and an oscilloscope. The teacher asks them to decide whether the fault is the sensor, the ADC, or the wiring, and to propose changes that keep the error below 1 °C without changing the sensor.

1. Calculate the ADC resolution in °C and the code change corresponding to 7 °C. Decide whether the jump is more likely sensor self-heating, ADC drift, or wiring/ground noise.

Read the worked answer

Resolution = 5.0/1023 = 4.89 mV per count. At 10 mV/°C, that is 0.489 °C per count. A 7 °C jump is 0.070 V, or about 14 counts.

LM35 self-heating is 5 V × 60 µA = 0.3 mW; with θJA ≈ 200 °C/W, the rise is only 0.06 °C, so it is not self-heating. ADC drift with a stable 5 V reference is also too small. The jump coincides with the relay and remains after averaging, so it is a coherent ground offset or inductive pick-up on the shared return and unshielded cable. Use the oscilloscope between sensor GND and board GND while switching the relay; a pulse confirms the wiring.

2. Propose hardware changes and calculate an RC filter. Use 1 kΩ and 100 nF. What cutoff do you get, and what error does the filter introduce?

Read the worked answer

Separate the sensor ground from the relay return and connect it at one star point at the board. Use twisted pair, with the shield grounded at the board only, and keep the cable away from the relay.

Add a 1 kΩ series resistor and 100 nF from the ADC input to ground: fc = 1/(2π × 1 kΩ × 100 nF) = 1.59 kHz. This does not attenuate 50 Hz much, but it clamps fast relay transients; add a 10 µF bulk capacitor at the board entry. If more 50 Hz rejection is needed, use 10 kΩ and 10 µF (fc = 1.59 Hz), but buffer the output with an op-amp, because 10 kΩ may be too high for the ADC. The filter introduces no DC error, but the ADC input bias current times 1 kΩ must be negligible.

3. Describe a software and calibration plan to keep error below 1 °C. Include how to handle the relay-on interval and verify with a reference thermometer.

Read the worked answer

Sample 16 times over 100 ms; discard the highest and lowest four and average the middle eight, or take the median. Ignore samples for 50 ms after the relay switches.

Calibrate at 25 °C with a reference thermometer: Tcorrected = Tmeasured + (Tref − Tmeasured). Check the slope in an ice bath (0 °C) and against a clinical thermometer (37 °C). Compute T = code × 500/1023 for the LM35, with rounding. Keep the 5 V reference stable; a 10-bit ADC has 0.49 °C quantization, so averaging and calibration are needed to stay below 1 °C. If the noise is still too high, use oversampling or a 12-bit ADC.