analogRead floating pin

Hi,

I am trying to use analogRead with floating pin to generate somehow random numners. The issue is that I always read 0. I am using the arduino Nano board.

The basic thing I am doing is reading the value to the seed function:

val = analogRead(0)
randomSeed(val);

Am I missing something?

Thx

I suppose that although the pin is floating and so susceptible to noise, there might not be any noise so the pin isn't disturbed. What happens if you bring your hand near it, or touch it?

Unfortunately using the analogRead() is not a reliable way to gather entropy (randomness), it has been discussed many times and the only way to get "real"randomness is to use an external circuit.

something like - http://www.cryogenius.com/hardware/rng/ -

analogRead() is not a reliable way to gather entropy (randomness)

Yeah well that's what I meant 8)

I read about the entropy altough I am not sure that for me it is that important.

I've tried to touch the pin but there wasn't any change.

I assume that if th epin is floating I must get some noise, right? Can it be that there is some PU / PD that prevents this noise?

So what you are really hoping for, is to generate enough static electricity by dragging your feet around on the carpet, for the analog pin to detect, but not enough static electricity to blow up the chip. Static electricity really doesn't work that way, it's a fundamentally stupid idea. Try putting on some plastic Crocs shoes, see if that works better for you.

I read about the entropy altough I am not sure that for me it is that important.

If you want to seed a random number then yes it is important to you.

I've tried to touch the pin but there wasn't any change.

That does surprise me are you sure you are doing things right?

I assume that if the pin is floating I must get some noise, right?

It depends if there is noise around, most of the noise is from mains.

Can it be that there is some PU / PD that prevents this noise?

If you find that there is then run to the patent office you are on a winner.

Write a routine that just prints values to the serial port and see.