Humidity sensors work by detecting changes in the properties of materials, such as electrical resistance or capacitance, as they absorb moisture.