Humidity Sensor controlled Bathroom Fan
A bathroom fan should always be switched ON when a predetermined level of humidity is reached, always.
Some months ago, I built a controller to fulfill this requirement using a microcontroller, a humidity sensor and a solid state relay. In these lines, I will expose my selection process for the sensor.
There are a lot available, but rarely above 10$. I decided to try a capacitive humidity sensor: HS1101 from Humirel. This is the cheapest I found (from Digikey), but it requires a special circuit to convert the capacitive output to something a MCU can read.
I followed the recommendations found in the HS1101’s datasheet, a frequency output circuit:
It’s a simple 555 timer that transform the sensor’s output to a frequency that any normal MCU can use. I connected this frequency output to the MCU’s external timer input and programmed the reversed polynomial function.
The result was good but not perfect since I used normal precision discrete components around the 555. The biggest problem was a really not linear response over different temperatures. So my fan wouldn’t turning ON during summer with the winter’s calibration… Bad..
At this point, I had two choices: To order the right discrete components or to try another kind of sensor. I decided to try a sensor that outputs a linear voltage vs %RH. I choose the HIH-4030-003S :
Connected directly to an MCU’s analog input, the RH value is calculated using the factory data provided with each sensor:
Vout=Vsupply(0.176 to 0.759) RH=(Vout-0.819)/31.488
If we have Vsupply = 5 and the analog value readout (val) from 0 to 1023, then Vout = (val*5)/1024. RH is then calculated with (Arduino Code here) :
val = analogRead(rhPin); rh = (((val * 5) / 1024) - 0.84 ) / 31.488;
With this sensor, the system is stable at different temperatures.
I plan to use this kind of sensor for my home meteorological station. For now, my conclusion is simple: Use smarter sensor and save time !



