Electronic – LM35 output varies when connected to microcontroller

atmegasensor

I am using an ATmega16A in my project. I have connected the Vref pin to Vcc (5Volts). I have connected my ADC input pin A1 (ADC1) to output of LM35 IC (output connected to RC damper).

Now the problem I am facing is when I have no microcontroller in place it measures perfect ~0.3 volts (room temperature) at the LM35 output pin but after soldering the microcontroller this pin voltage rises to ~2.5 volts (provided LM35 is at same room temperature). Also the ADC reading read by my software is higher and corresponds to 2.5 V and not 0.3 volts so what could be wrong?

enter image description here

Best Answer

You may have the AVR internal pull-up still enabled, from the ATmega16A Datasheet you can see the following:

If PORTxn is written logic one when the pin is configured as an input pin, the pull-up resistor is activated. To switch the pull-up resistor off, PORTxn has to be written logic zero or the pin has to be configured as an output pin. The port pins are tri-stated when a reset condition becomes active, even if no clocks are running

So try setting the corresponding PORT value to zero to ensure the internal pull-ups are disabled. Often when interfacing with sensors having the pull-ups enabled will cause a higher that expected voltage to appear on the pin. With digital interfacing you will also sometimes see similar symptoms when you have a low and high pin working against each other due to a pin configuration problem.