signal issue from LM35

Proper analog signals are presented on two ports (ground is separate from all other in/outputs): 0 to 5V on port 6, output from an LM35 on port 0. When the signal on port 6 changes, then the signal measured from port 0 increases as well.

When I disconnect the input (on 0) from the LM35 and connect port 0 to ground or to 5V the read input signal from 0 does not change after altering input 6.

Power supply is from USB.

I have the same issue with different LM35's.

Code for the LM35:

int temp1value = analogRead(0); // temp1 transformer
float mv1 = (temp1value / 1024.0) * 5000;
float temp1 = mv1 / 10;

What could be the issue?

Edit note: I corrected 2x when I wrote "2" which should be "0" for port 0

Which board are you using - port6 analog or digital ?

Does the Lm35 work ok, if port 6 is disconnected ?

What is the actual circuit for port 6, it sounds like it might be affecting the supply rails.

When you have the LM35 disconnected from port 0 and connected port 0 (an input at this time) to 0 or 5 Volts, was that a direct connection to the power rails or through a resistor?

This is on a AT168pro mini.

Ports used are analog.

LM35 works ok when port 6 disconnected, or on another analog input.

Port 6 is connected directly to eiher analog ground or +5V.

LM35 output also connected directly on port 0.

LM35 works fine otherwise.

Edit: corrected typo

Make two readings of the same analogue pin, use the second reading you get.

If that does not work then put a small delay between the two readings.

The LM35 output is low enough dynamic impedance (500 ohms or so), its likely not that.

I suspect you are not using star-grounding, so that when you change the input on pin (not port) A6
it is causing a current to change in the ground wire to the LM35? The LM35 wiring should go from
the arduino to the LM35 without sharing with anything else.

Other possibilities are parasitic oscillation or noise/EMI pickup. Try a small capacitor to ground
at A0 (1 -- 100nF)

The LM35 wiring should go from
the arduino to the LM35 without sharing with anything else.

+1

You do not say which board you use: UNO, Mega, DUE ?.
This is difficult to answer.
I well know only UNO (and nano).

For the UNO:
The analog inputs are connected to the same pin as digital input port C.
To protect analog inputs from digital switching disturbances, digital inputs C0 to C3 are connected to a special protected supply.

Inputs A4 and A5, which also serve to I2C, are connected to the global digital power supply.

Is the problem persists if you only use the inputs A0 to A3?

As Grumpy said, Atmel datasheet states that whenever there has been a change in the analog network (reference change, change in the converter input multiplexer, and so on) NEVER keep the first measure because change could occur during conversion.

There is no "port 6"

A "port" is a group of 8 inputs/outputs.

A GPIO pin or analog pin is not called a "port". It's called an "I/O pin" or "GPIO pin" or simply "D6".

The "AT168" (ATmega168) has four ports (A,B, C & D).

See page 16 of datasheet

raschemmel:
There is no "port 6"

A "port" is a group of 8 inputs/outputs.

A GPIO pin or analog pin is not called a "port". It's called an "I/O pin" or "GPIO pin" or simply "D6".

The "AT168" (ATmega168) has four ports (A,B, C & D).

See page 16 of datasheet

Sorry you are right, instead of "ports" I have meant "analog input number".

MarkT:
The LM35 output is low enough dynamic impedance (500 ohms or so), its likely not that.

I suspect you are not using star-grounding, so that when you change the input on pin (not port) A6
it is causing a current to change in the ground wire to the LM35? The LM35 wiring should go from
the arduino to the LM35 without sharing with anything else.

Other possibilities are parasitic oscillation or noise/EMI pickup. Try a small capacitor to ground
at A0 (1 -- 100nF)

On the AT168 pro mini I have two GND pins. One is used for digital I/O and the other for analog I/O. So in a strict sense I consider the AT as my star "point".

Tomorrow (it is late night here now) I will experiment with a small capacitor on A0 and report back.

Draw a picture of the layout showing the ground wire routing.

After inserting a 47nF cap between analog GND and output LM35, and after reinserting the pins on the breadboard, the output stabilised to a correct value independent of any other analog input.

The setup is made on a breadboard and apparently some bad connections were present also.

Conclusion: breadboard setups need very carefull attention to correct wiring and stray capacitances are probably more present then I thought.

brice3010:
Conclusion: breadboard setups need very carefull attention to correct wiring and stray capacitances are probably more present then I thought.

very true ... though always much better to develop / solder on strip board or similar.

Conclusion: breadboard setups need very carefull attention to correct wiring and stray capacitances are probably more present then I thought.

I think it has less to do with that and more to do with having some capacitance on the output of the LM35. I would have chosen 100 nF to 330 nF.

The setup is made on a breadboard and apparently some bad connections were present also.

This is why people advising newcomers to use them are doing people a disservice. I would never recommend using them.

This is why people advising newcomers to use them are doing people a disservice. I would never recommend using them.

I must be lucky then because I have had very little problem with breadboard intermittents. I think sometimes this is mistaken for a breadboard issue when the problem is really caused by using solid copper wire or jumpers that are too small a guage. I use 20 or 22 guage solid copper hookup wire and never have any problem. The arduino type factory made jumpers with the plastic sleeves are too small in my opinion but I still use them.

I think it has less to do with that and more to do with having some capacitance on the output of the LM35. I would have chosen 100 nF to 330 nF.

Without a serial resistor this may be a bad idea.
LM35 does not like capacitive loads.
See extract of National Semiconductor datasheet :

@Grumpy

This is why people advising newcomers to use them are doing people a disservice. I would never recommend using them.

For total beginner you are right.
However I think LM35 is a very good candidate to learn the basics of analog electronics.

It's true that it's not easy but we must not forget that as soon as the wiring lengths become large compared with the wavelength, these are the basics of analog electronics that apply.

With micro avr 16 MHz is still easy, but with micro with system frequency more than 100 MHz, as we see more and more, it will admit that if the processing of signals is digital electronics the conveyance of "digital" signals will become more and more analog electronics.
Acquire a good notion of what is gnd and know that the perfect gnd does not exist is essential.
For those who want to efforts the LM35 is a very good tool.

but with micro with system frequency more than 100 MHz, as we see more and more, it will admit that if the processing of signals is digital electronics the conveyance of "digital" signals will become more and more analog electronics.

Even on the Raspberry Pi that runs at around 1GHz the I/O can only be toggled at something approaching 27MHz. So that is often not a limiting factor.

I have seen people at exhibitions with a mass of parts on a bread board frantically rocking components back and forth in an attempt to make their circuit work. Many times their exhibit is abandoned half way through the show if indeed they get it working at all.

I have seen people at exhibitions with a mass of parts on a bread board frantically rocking components back and forth in an attempt to make their circuit work. Many times their exhibit is abandoned half way through the show if indeed they get it working at all.

Honestly, I would think twice about taking a breadboarded circuit to an exhibition. I assume you are not referring to a contest where people make circuits from scratch on a time deadline.