Periodically seeing voltage on analog pins

I am trying to make a simple water level sensor for my Arduino, by using just a few wires and Resistors. You can see how I connected everything below. Now, When the wires are not in water, I am periodically seeing some voltage readings, and this happens once in every 3 seconds or so. Readings are very low (Only going up to 60 or so) but the problem is that this sensor works in a very clean water, so the water does not produce huge readings as well. So my question is, does anyone know why I am seeing this periodic spikes in voltage readings? Readings look something like this for the 2 analogReads.

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
2 0
0 9
23 9
0 9
27 9
33 9
0 23
4 23
0 23
28 23
0 23
32 0
21 0
0 0
20 0
19 0
15 26
18 26
35 26
0 26
24 26
0 6
31 6
34 6
17 6
12 6
0 0
0 0
29 0
18 0
0 0
0 33
0 33
0 33
0 33
27 33
5 18
29 18
0 18
3 18
35 18
0 0
0 0
0 0
6 0
0 0
1 24
3 24
0 24
19 24
23 24
35 26
0 26
36 26
34 26
0 26
0 15
0 15
0 15
10 15
30 15
28 0
31 0
26 0
27 0
3 0
0 24
0 24
13 24
0 24
24 24
0 0
30 0
8 0
0 0
15 0
0 0
16 0
33 0
0 0
0 0
0 28
0 28
0 28
9 28
26 28
30 0
3 0
0 0
0 0
14 0
0 32
0 32
0 32
23 32
0 32
13 0
18 0
24 0
33 0
0 0
19 21
2 21
0 21
0 21
3 21
0 2
0 2
0 2
0 2
0 2
0 0
0 0

So they go up and then it shows solid 0`s again for few seconds, and then it spikes again.

The wires on the analogue pins are acting as an antenna, picking up hash.
Add 100n capacitors from the analogue pins to ground, to reduce interference.
Leo..

So do I add both a capacitor and a resistor correct?

also when you say 100n capacitor, do you mean 100 NanoFarad ?

Yes.
Common practice to add a 100 nanoFarad capacitor from analogue pin to ground to stop interference.
Leo..

Yep, it works. I currently only have 1000 microFarad ones, and it cleaned the signal but it takes some time to discharge the capacitor. Switching it to 100 nanoFarad should solve the issue completely. Thank you very much.

Make sure you get a ceramic type of capacitor as that will work, other types might not.

By the way 100nF is the same as 0.1uF

Yeah, I I got that part :slight_smile: By the way, could someone please explain how this actually clears the signal from external noises?

The noise is absorbed by the capacitor. That is for very high frequencies the capacitor looks like a short circuit, so the noise is shorted out but lower frequencies, those you want to measure are not.

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

and

http://www.thebox.myzen.co.uk/Tutorial/Protection.html

Hmm, fascinating stuff. I am a computer scientist and not an electrical engineer, but I have to do a lot of electrical engineering stuff nowadays :slight_smile: Thank you guys for all this good info. My signal cables are about 12 feet long and they run along 2 other cables which transmit data, and this data was somehow caught in my signal as well. By installing the capacitor, it completely eliminated the noise from signal carrying cables.

and this data was somehow caught in my signal as well.

The "somehow" is called inductive coupling.

Or capacitative? Could be either or both.

Allan

Saikedo:
Hmm, fascinating stuff. I am a computer scientist and not an electrical engineer, but I have to do a lot of electrical engineering stuff nowadays :slight_smile: Thank you guys for all this good info. My signal cables are about 12 feet long and they run along 2 other cables which transmit data, and this data was somehow caught in my signal as well. By installing the capacitor, it completely eliminated the noise from signal carrying cables.

That would have been useful information to include in the first problem statement.