Analog input value varies when setting digital output to 1

Hi all,

I have an Arduino MEGA reading temperature from LM35. The temperature value is fine and stable until I switch on a digital output. Once the output goes high, the temperature reading increases by 1 °C. Oce the output goes to 0, temperature reading decreases by 1 °C.

Any clues why this happens?

Thanks, Cabbi

Try measuring the voltage at the sensor. The output may be drawing too much current and dropping the available voltage. The sensor is very sensitive to the voltage.

The temperature value is fine and stable until I switch on a digital output.

What is the output connected to? How is it wired. It could be due to ground lift due to current flowing through a common section of ground return wiring.

I use two digital outputs, both connected to a led with a 220 ohm resitance and driving one of those ready assembled Relay boards.

The temperature shift happens even if I set only one output to high.

You still haven’t answered my question. The physical wiring, is there a section of it that takes the ground for the LEDs and the ground for the temperature sensor.

If you are having difficult understanding this then post a picture ( not more than 1000 pixels wide ) of your wiring.

I use two digital outputs, both connected to a led with a 220 ohm resitance and driving one of those ready assembled Relay boards.

Note that relay boards should be powered from a separate DC power source, not the Arduino's 5V source. If it has opto-isolation, then you should take advantage of this by removing the jumper and ensuring that the relay board's GND is not connected to the Arduino.

Thanks, I'll check your suggestion and come to an answer ASAP.

dlloyd: Note that relay boards should be powered from a separate DC power source, not the Arduino's 5V source. If it has opto-isolation, then you should take advantage of this by removing the jumper and ensuring that the relay board's GND is not connected to the Arduino.

Is this a MUST? :roll_eyes: :'(

Yes, as far I see the relay board has opto-isolation.

Grumpy_Mike: You still haven't answered my question. The physical wiring, is there a section of it that takes the ground for the LEDs and the ground for the temperature sensor.

If you are having difficult understanding this then post a picture ( not more than 1000 pixels wide ) of your wiring.

Yes, the ground wire is shared between the relay board and the LM35 temperature sensor.

Should I use different Arduino board ground pins? Aren't they all connected, what would be the difference?

Thanks

The VCC from the Arduino is used on the input side, but not used for the relay power. More specific information on desired connections for your relay board can be found here: http://arduino-info.wikispaces.com/RelayIsolation

cabbi: Yes, the ground wire is shared between the relay board and the LM35 temperature sensor.

Should I use different Arduino board ground pins? Aren't they all connected, what would be the difference?

Thanks

YESSSS, I did connect the two GNDs to different Arduino board ground pins and at a first glance the issue seems gone!

Thanks!

dlloyd: The VCC from the Arduino is used on the input side, but not used for the relay power. More specific information on desired connections for your relay board can be found here: http://arduino-info.wikispaces.com/RelayIsolation

I did change wiring putting grounds to different biard pins and the issue seems gone.

Anyway... GOOD reference thanks.