I've never tried an LM35 but I've had similar fun time with a TMP36.
Assuming they work on a similar principle, what your actually seeing is fluctuations in the input or reference voltage. This could be caused by any number of things in your hardware setup. Like what type of power supply you are using.
My first guess would be to try decoupling the power fluctuations using small ceramic capacitors. If you had access to a scope you could check just how steady that voltage is at various places. Another thing you can do is take a series of readings and work out the average to take out any freak line fluctuations. I've got a little code i use for getting readings randomly off my analogue pins. I know it's not perfect and it's not fast but it works for me.
class MyAnalogPort { private static object Analog_Lock = new Object(); public static int Read(int port, double ratio = 1023, bool invert = true, int sample_size = 5, bool dispose = true) { lock (Analog_Lock) { SecretLabs.NETMF.Hardware.AnalogInput sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0); if (port == 1) { sample_port.Dispose(); sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A1); } if (port == 2) { sample_port.Dispose(); sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A2); } if (port == 3) { sample_port.Dispose(); sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A3); } if (port == 4) { sample_port.Dispose(); sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A4); } if (port == 5) { sample_port.Dispose(); sample_port = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A5); } int sample = 0; int[] read = new int[sample_size]; for (int Counter = 0; Counter < sample_size; ++Counter) { read[Counter] = sample_port.Read(); Thread.Sleep(Counter); } sample = Convert.ToInt32(AverageElements(read).ToString()); double input = (ratio / 1023) * sample; if (invert) { input = ratio - input; } sample = (int)System.Math.Round(input); sample_port.Dispose(); return sample; } } }public static double AverageElements(int[] arr) { lock (Calc_Lock) { int sum = 0; for (int Counter = 0; Counter < arr.Length; Counter++) { sum += arr[Counter]; } return sum / arr.Length; ; } }
It takes 5 readings by default and not at the same time distance apart. Just in case there is a set frequency of interference.
Hope that helps.
Grant.