Unstable analog reading

Hi all

I am fighting a problem of unstable readings on an analog input for more than a year now… I am measuring the resistance of a light sensitive resistor. The reading is changing a lot, what reasons could there be?

The Arduino is running a solar steam system (http://www.cocinasolarmexico.com.mx/crbst_6.html), it measures illumination, a pT1000, the battery voltage, a potentiometer and a few switches, pilots a motor and a pump (via MOSFETs) and indicates temperature and voltage by a LED bar.

I guessed it was some voltage coming back from the motor when it stops and put a diode between + and - of the motor voltage and another one in the power line to protect from that. → no change.
I measure 10 times and wait 100ms in between. → not much change.

Can it be too much current flowing from the Arduino or would that just blow a fuse?

Please give me ideas where to look at…

Thanks a lot, Papillonsoleil

Very nice: a solar powered taco cart! Oaxaca is a lovely city, but I missed that attraction.

The changing readings could be due to either changing light levels, changing temperatures of the LDR sensor, or changing voltages in the power supply for the sensor and microcomputer.

The power supply should be well regulated, and from your suggestion that a motor may be causing trouble, it may not be. Motors should, if possible, be powered from separate power supplies. If not, you will need good filtering and additional regulation for the microprocessor.

Other suggestions will be possible if you would post a circuit diagram.

Thanks jremington! I run the motors on 12V from a battery which is solar powered. Before, the solar charge controller was integrated into the Arduino as well, now it is a independant commercial solar charge controller.

I run the Arduinos power supply on the same battery (directly 12V) or on the computer's USB, in both cases it is unstable...

If I put a 10k resistor instead of the illumination detector and nothing else connected, it is stable.

I guess I must do a more strategic game of connecting and disconnecting items and see what happens..

You may have a bad sensor, or bad connection to it.

I don't think the sensor is bad, with a multimeter I read 6k in the shade and 9k in the sun (stable). This should be clear enough to distinguish.

I did a run this morning, with nice sunshine. The system worked fine for 20 minutes (both motor and pump running many times), then the illumination reading switched to 'wrong' all of a sudden. When I disconnected the motor, it read OK, when I reconnected the motor to the Arduino (even BEFORE it was actually running), the reading went wrong (and kept being wrong until I disconnected the motor again). So some charge from the motor is still my personal favorite 'bad guy'.

How could I better protect the arduino from the motor?

PS By the way, yes, Oaxaca is a great place and unluckily, the taquero isn't in the lonely planet guide! I'll write them as soon as the thing is working again...

The way how motor and illumination detector are connected now.

I don’t see anything wrong with your circuit, although I do not think that the diode in series with the motor lead (closest to the motor in your schematic) does anything useful.

The motor might be injecting electrical noise into the power supply. If you are using the same 12V power supply for the motor and the Arduino, an extra 9V regulator (7809) between the two might help a lot. You could also add a resistor/capacitor low pass filter for power supply decoupling, say 100 ohms and 1000 uF (see attached). The resistor will drop 3 volts if the Arduino draws 30 mA, so if it draws more, reduce the resistor value.