how to do independent multiple analog read out ?

Today i created a schematic which i've drawn here

(image uploaded from my phone to dropbox public folder)

The problem my analog readings seams to swing up and down with this,
while the light doesnt change.

I would like to use the arduino as a sensor unit, but ... i'm failing to add more then one sensor
I wouldlike to add more sensors (more then 2)
Obviously my wiring diagram is wrong .. but then how should it be ?

I'm a newbie, i hope you can make a simple drawing too so i can understand it better.

Are the +5V and GND the ones on the arduino board?

yes

What is the resistance range of the LDRs?

There is nothing wrong with your diagram. You did leave out some details out about how much the voltage was swinging and whether the LDR's were illuminated by sunlight or fluorescent lighting and how much the swing was. If the readings were artificial light the readings will swing as the light goes off and on 60 times a second. so some filtering might well be necessary, perhaps the easiest method would be to use only the peak voltage to to average the count over 10 20 Ms (the period pf a 60Hz sinewave is 16.6666....7 ms) and your value measured might improve, assuming that you want to measure lighting levels. The other usual method is to 'filter out noise" by placing a .1 uF cap from the input to ground. the reading variations are due to the sampling not being synchronous with the lighting variations caused by a flicker too fast for the human eye to see. and that is the method to extract the correct light value... make your measurements at the crest of the 60Hz wave form used to power the lights... IMO

Doc

However there was no electric light it happened with daylight and the constant swing was very unstable
Now the swing seams a bit more stable, i guess because its darker now here.

I got their values and calculated difference transmited over serial here
pin2 - pin3
174 - 413 dif = 239
174 - 213 dif = 39
175 - 184 dif = 9
415 - 392 dif = 23
417 - 401 dif = 16
392 - 391 dif = 1
380 - 419 dif = 39
393 - 382 dif = 11
370 - 178 dif = 192
250 - 248 dif = 2
252 - 269 dif = 17
289 - 272 dif = 17
268 - 260 dif = 8
250 - 250 dif = 0
255 - 255 dif = 0
113 - 353 dif = 240

The LDR's goes by a cryptic LDR-03-51 it is a can be found here dickbest.nl - This website is for sale! - Elektronika Resources and Information., i bought them just to have some input device, but i couldnt find a datasheet about them, i think dough they are pretty common i've seen them before.
Both LDR's point in the same direction

( its a relief to me that you tell me the diagram isnt wrong btw, i've been thinking a lot why i get these readings, i doubted the diagram).

You really need to know the resistance range of the LDR. A data sheet would tell you, but that site looks worse than useless.

Your 1K resistors are probably completely wrong. You need the resistors to be sized right so that the LDRs give a decent voltage swing in the desired brightness range.

Grab a DMM and measure the resistance in complete darkness and in full light, and if possible in half light (shade it with your hand, but don't black it out). Try using resistors that are around the half-light reading (ish) and see what you get.

Looking at the data you printed above, most likely data from 2 sensors getting swap irregularly. It well known problem, as microprocessor has only 1 ADC multiplexed to many inputs, sometimes switching multiplexer not happening in time, and output of ADC provided is not corresponds to input you expecting. Simplest solution, take two readings in sequence from the same input and use for calculation only second reading. Than switch to next and do 2 reading again. Also, to get stable results make averaging

Two things inmmediately, add a 10 ohm resistor in series with Vcc to the LDR's and place 2 100 uF 6.3V electrolytic capacitors from ground(- Lead of caps) and place 1 plus lead from one capacitor to 5V and the other cap plus lead from the junction of the 10 ohm resistor and the 2 photocells. What I am asking you to do is place a small RC filter in series with the 5V source and the LDR's. This should clean up any noise without materially affecting your intended measurements. Here's the math. Assume 100 ohms LDR min Resistance and 1K ohm for the two LDR load resistors, also ASSUME CLEAN TIGHT CONNECTIONS for all components, you will have 550 ohms of equivalent resistance so the drop will be I = E/R or 11000/2 + 10 = 560 ohms =8.9 mA X 10 ohms = 89mV drop across the 10 ohm filter resistor and you will have a reasonable clean power supply so you can begin to find why you have such divergent from 2 nearly identical LDR's I suspect both noisy (loose or dirty breadboard connections) and a noisy supply somehow.

Doc

Well i tried to do a few things

  • i tried to do double reads but only use the second read
  • above with a delay(50) in between switching different analog read pins
  • two resistor in series and place a condensator on top of each for the 5v input
  • combined above and do like 60 readings and take the average
  • If i use a single LDR its seams all a bit more stable. (but i want to compare 2 light sources)

for the two resitors part i didnt have the right resistors en condensators as adviced here
I used two 470 ohm resistor and a elco 4.uf 25v instead (it seams to have a small impact)

However my readings still variate a lot under daylight conditions
what i also notice that while these LDR's are sensitive to light
there is not that much difference to notice when i put something black in front of single a ldr.
Well there is a difference, but its a bit hard to detect bewteen the chaotic swinging non constant readouts
Statistics might perhaps filter the differences out, but i myself have to look hard to see the difference
It not like :
ldr1 ldr2
100 - 800

Just to be sure this is the schematic i use now

Well I guess i need to buy a DMM to check how these LDR's behave, i put it on my shopping list

Yes, a DMM is one of the basic pieces of equipment that you really require to do any electronics work. You're seriously stunted without it. It's like trying to build a timber framed house with only a shoe to drive the nails in.

Correct your schematics:

Thanks for the schematic drawing !
Its different dough, because i want to use 2 LDR's not 1, i want to compare their analog read out.
However its also interesting to see that smal capicitor there, asume it drains awaysome some noise to ground.

Looking for a multimeter is see lots of them and huge price differences,
I think frequency measuring is a nice thing to not sure might be handy for signaling later.
I ended up with a few http://tinyurl.com/8aylqn5 they can do minimal 10hz to.
well the first has a minimum of 400hz it has got auto ranging.. not sure if thats handy
In contrast to their prices the lowest resistor (only) multimeter i found was 5 euro.
I'm not sure what to do, 5 euro wont hurt but i guess its crap, on the other hand electronics is not my job; i'm into software.
Would someone recomend one of the multimeters of the tiny url, or advice a cheap 5 euro ?

I draw only one channel, as second absolutely identical. Do 2 circuits , for 2 LDR.
Your link is under maintenance.

I'm beginning to think that maybe the Arduino i use is broken.
When i disconnect anolog1 and analog2, it still returns values, that swing like

243 - 227 dif = 16
256 - 228 dif = 28
254 - 229 dif = 25
245 - 226 dif = 19
223 - 239 dif = 16
206 - 244 dif = 38

if nothing is connected i would assume the value to be returned would be 0
and not ( like 1/1024 * 5v * analog1 ) = ~ 1 volt.
Or am i hoping for to much precision here ?

Or should it be handled by electonics to get it down to zero ?...

No, "floating" input can produce any value. For testing, you should connect it to ground, +3.3V and +5V, and read. BTW, it would be nice to try to connect 1 input to +5V and another to +3.3V in order to clear, where instability coming from If it LDR, you would get stable values, if it ADC multiplex -? I already explain above.

correct as far as it has gone I said two large capacitors one on either side of the 10 ohm resistor, one is for the 5V source and wiring from it to the measurement location and the other one is for the sensor, both must be > 100 uF (in my experience) I use 330's to 470uF caps. You reported some success with the changes you made but there were still erratic data return a 5Mv noise pulse riding on the 5V source will change your reading by one count and one other point if you have any wiring more than an inch or three away form the Uno or whatever twist them together... Saves noise coupling to/from the wiring

Doc

Thanks for the past replies, you people got me thinking
Disconected analog input is not ok, at least ground, or +3.3 or 5v is what they require.
I rewired it again (did it a few times now), and made a small change

stabilized voltage in - resistor 1000 ohm - analog input - LDR - ground.

Here its all on one picture my boards and the schematic
PS i use a 10 led-IC as output, who would light up in multiplies of 5v difference
No led lights up because i got a stable output higher then my difference counting (mx = 50)

Also i dont do any averaging here, but i still perform 2 reading and only use the last reading.

Datalog :
599 - 460 dif = 139
598 - 460 dif = 138
599 - 460 dif = 139
598 - 460 dif = 138
597 - 460 dif = 137
599 - 460 dif = 139
598 - 460 dif = 138
598 - 460 dif = 138

Big thanks to all who posted and helped me here, i learned a lot from you.

Here is the code i made for the circuit :

int sensorPin1 = A0;    // select the input pin for the potentiometer
int sensorPin2 = A1;

int leds[]={4,5,6,7,8,9,10,11,12,13};
int redled = 3;

int sens1 = 0;  // variable to store the value coming from the sensor
int sens2 = 0;
int tot =0;
int dif =0;
int i=0; 
int scope =0;
int temp = 0;
String dump = "serial communication string";
void setup() {
  // declare the ledPin as an OUTPUT: 
 for (i=0;i<10;i++){pinMode(leds[i],OUTPUT);}
 pinMode(redled,OUTPUT);
 
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

void loop() {

digitalWrite(redled,HIGH);
// --- for average analog readout
// read the value from the sensor:
// for (i=0;i<4;i++){
//   temp=analogRead(sens1);sens1= sens1 + analogRead(sens1);
//   delay(50);temp=analogRead(sens2);
//   sens2= sens2 + analogRead(sens2);
//delay(50);}
//sens1 = sens1 /4 
//sens2 = sens2 /4

temp=analogRead(sens1);sens1= analogRead(sensorPin1);
temp=analogRead(sens2);sens2= analogRead(sensorPin2);

dump = String(sens1) + " - " + String(sens2) + "   dif = " + String(abs(sens1-sens2));
dif = abs(sens1-sens2)-102;
digitalWrite(redled,LOW);   //to indicate calculation time has finished before displaying results.

scope = 5;    //measurement step size for ledbank
for (i=0;i<10;i++){
  digitalWrite(leds[i],LOW);
  if ((dif > i*scope )&&(dif <(i+1)*scope)){digitalWrite(leds[i],HIGH);}
  }
sens1=0;
sens2=0;
Serial.println(dump);    
delay (40);
  }

thanks for helping me

Fair play, those are some chunky resistors...

Your drawing is wrong. Resistor (470) has to be in each LDR power line separately, otherwise one LDR would affect another. Look again at drawings I posted for one channel. Code should be corrected :

temp=analogRead(sensorPin1); //<<<< here
sens1= analogRead(sensorPin1);
temp=analogRead(sensorPin2); //<<<< and here
sens2= analogRead(sensorPin2);