Averaging Digital input.

The best thing would be to find out why the false readings happen and eliminate the problem.

No need to average the readings. If you cannot prevent the false readings then you could, perhaps, take 100 readings, adding each to a running total and if the total is not zero or 100 then discard that set, otherwise regard the set as valid and record/display the value as wet or dry as appropriate. How often are the readings taken ?