Introduction: Transform Basic Bathroom Fan to Advanced

This is my first instructable !!

After i moving with my girlfriend into our new rent house, our new bathroom is equipped of a fan evacuator with a PIR sensor to evacuate humidity, every time we switched ON the light of the bathroom, the FAN switch ON and made a lot of noise !!

I like every time my girlfirend goes to bathroom at night ...

Requirements:

FAN would be power ON if the humidity is higher than 75%

OR

The door is closed (go for a dump)

Step 1: What Inside This Silent Fan ?

+ No transformator => Problem: i cannot extract safe 5V out of the box.

+ No Relay.

Step 2: Add Switch With Snubber Filter

I choosen to drive the FAN with dual relay with optocoupler input protection, the easy way to drive any thing from a µC

I'm very lucky that this dual relay go inside (i cut a litle bit the eges to fit it perfectly)

snubber filter :

Every time the relayes are cut off, one phenomenon is produced:

> µc reset alone.

The snubber filter (Capacitor in serial with Resistor) is wired in parallel with the FAN.

From Wiki:

Snubbers are frequently used in electrical systems with an inductive load where the sudden interruption of current flow leads to a sharp rise in voltage across the current switching device, in accordance with Faraday's law. This transient can be a source ofelectromagnetic interference (EMI) in other circuits.

Step 3: Add 5V Power Supply

I recovered an old LG Cell Phone charger to use as a power supply (230V => 5V 0.5A)

Step 4: Remaining Space

Take measures of remaining space where the PCB will be placed.

Step 5: Cut Useless Brace

I cutted useless brace to win a little bit more spaces.

Step 6: Schematic Μc/Sensor

I chose the Atmega 328p because I had several at home ^^

AM2302: The hygrometer/temperature sensor (1-wire bus)

Step 7: LED Driver

NPN Transistors working in saturation mode drived by µc.

Step 8: Door Detection

Infrared Proximity Sensor was built with an TCRT5000 and a LM324, the LM324 is aop used as a voltage comparator.

When the infrared light (from the IR LED) reflect a surface (bathroom door), the phototransistor leave the current to flow, The input 5 of LM324 is at +IRV and compare the voltage with the input 6 (bridge voltage divider), if the value is higher, the output 7 give 3.5V (5V - 1.5V).

N.B. IRV depend the amount of infrared light coming back to to IR receiver

Step 9: Lets Go to Disign the PCB

I designed the PCB with Fritzing and took into account the space available in the box.

Step 10: Test and Reshape the PCB

I reshape the PCB to avoid useful brace.

Step 11: Let's Go to Solder Components

When i soldered the components, I realized that I forgoten to place the Quartz ! ... I improvised by soldered it above the µc.

I test with 5V power supply, I held my breath before I switched it ON ... poiouff, this time, all work fine for first time.

RED light: No communication with hygrometer sensor.

GREEN light: humidity < 75%

BLUE light >= 75%

N.B. All light color are bliking to say me, "i'am alive"

Step 12: Test FAN Drived by Μc + Close the Case

Everything seems fit perfectly

Step 13: Mount the Proximity Sensor Near the Door

I made a hole on the ceiling for passing the wires.

Step 14: Final Test

After calibrated the poximity sensor (set the potentiometer to detect the door presence)

While i took my shower, i noticed that the sensor takes a long time before it detect moisture > 75% ... may be i must move the AM2302 near the hole where come the power.