In what principle does water sensor work?
Basicall both sensors for liquid water and for moisture work on the same principle: the electric resistance of the liquid water or of a semiconductor layer that has absorbed water vapor from the atmosphere is lowered.
While for detecting liquid water one only need two electrical contacts in an circuit that closes when the water has reached the level where the electrical contacts are located, when it comes to detecting moisture in the air things are a bit complicated. Basically in this case a semiconductor (like `SnO_2` which is used for the detection of many gases) absorbs on its surface the water vapor. Because of the absorption the chemical bonds of the semiconductor at the surface are changed, and because of this the structure (shape) of valence and conduction bands at the surface of the crystal are also changed. Thus electrical resistance of the semiconductor modifies proportionally. This in turn becomes an indication of the degree of moisture that has been absorbed.