Analog read fluctuation problem.

Hi! I am trying to diy soil meter, i have soil sensor (like a two nails). So i set it up like this:

5v -> 4,7 kOm ->1st nail->(soil)-> 2nd nail ->AnalogPin(1)

And this simple code:

void setup() {
Serial.begin(9600);
}
void loop() {
int data;
data = analogRead(1);
Serial.println(data);
delay(100);
}

And all i get is this fluctuation data, which periodically goes from ~200 to ~400 .

210
205
206
211
213
216
219
224
218
216
224
238
244
259
267
278
282
292
302
312
320
328
339
355
367
378
394
411
424
434
444
454
451
441
434
435
437
438
437
437
437
427
418
412
404
394
387
377
369
359
345
331
322
320
310
300
285
267
250
238
226
220
211
208
204
205
208
209

What is my probem? I was trying to pull down line, but this periodical fluctuation still there.

I think you see main hum...

RastafarienTargaryen: I was trying to pull down line

What's that? You tried using a pull down resistor? I think you need one because you want to create some sort of voltage divider.

What is the value of your pull up resistor? The one connected to +5? "4,7 Om" isn't conventional notation. We can't read it.

septillion: I think you see main hum... What's that? You tried using a pull down resistor? I think you need one because you want to create some sort of voltage divider.

Yes i was trying use pull-down resistor to get rid off noise, but it wont work.

aarg: What is the value of your pull up resistor? The one connected to +5? "4,7 Om" isn't conventional notation. We can't read it.

I dont have a pull-up resistor, its is current limiting resistor. It has 4,7 kOm nominal.

Then you do need a pull down from Analog pin 1 to ground. A value close to the soil resistivity.

RastafarienTargaryen:
Hi! I am trying to diy soil meter, i have soil sensor (like a two nails). So i set it up like this:

5v → 4,7 kOm ->1st nail->(soil)-> 2nd nail ->AnalogPin(1)

Look at the attach picture,

5v ->1st nail->(soil)-> 2nd nail ->AnalogPin(1) → 10 kOm → Ground

Read this for more info

BillHo: Look at the attach picture,

5v ->1st nail->(soil)-> 2nd nail ->AnalogPin(1) -> 10 kOm -> Ground

Read this for more info http://forum.arduino.cc/index.php?topic=37975.0

That doesnt help - i am still have that annoying aplitude fluctuation, but difference it has now lower absolute valu, i mean if it wass 200-400, now it 0-200

BillHo: Look at the attach picture,

5v ->1st nail->(soil)-> 2nd nail ->AnalogPin(1) -> 10 kOm -> Ground

Read this for more info http://forum.arduino.cc/index.php?topic=37975.0

for some reason it starts to work. Thanks for help!

You should have a capacitor between the analog pin and ground. 0.1uf, or 0.01uf is normal there.