Project in progress
Multi Stage Ventilation

Multi Stage Ventilation © GPL3+

Automatic fans act in stages depending on atmospheric conditions with an alert at full capacity.

  • 7 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
IRF520 mosfet module (cheap chinese)
FC22 / MQ2 sensor
Buzzer (generic)
Fan (salvaged from old computers)
12 volt 3 amp external power supply from an old laptop.
11026 02
Jumper wires (generic)

Apps and online services

About this project


OK its been a while and I should have mentioned before now but...The final version has been running for a couple of months now. It took a little tweaking to get the levels I wanted just right but that's why I marked all my variables in the sketch. More pics and the new code to follow

Not many changes in the code though.

This is only a prototype so excuse the wiring. The Idea is to use 3 fans that automatically activate at different levels of room pollution.

Using more or less fans is quite simple as the sketch is pretty modular and easy to follow. Adding fancy extras such as status indicators is also an easy option by taking additional items from the 12 volt outputs of the fan or defining extra pins and including them at the same points as the individual fan activation.

I have a pretty shaky video of it in action here


For my test setup, I mounted my fans on a piece of plywood. It's optional but watch out for wandering fans if you don’t use anything. These fans are about 1 CM above the board to allow air flow.

For the final assembly I will be placing the sensor in the most vulnerable location although adding a second one is again an easy option.

The fans will be mounted on a 3 inch duct at spaced intervals and will be set at an angle to try prevent back-flow of air movement. Fan one will be nearest the main vent outlet and staged back from there so that each fan adds to the air movement.

Setup and Wiring

There are examples for the MQ series sensors on the Internet that use finer calibration methods and libraries than I do, but this had to be easy enough for almost anyone to do.

I did use the digital output on the prototype and will use it in the final version to activate a better small buzzer to let me know when the system is at maximum.

There is some tuning to do with the hysteresis yet but I will deal with that area on the final one.

As a temporary connection for the fans I just used extra-long header pins and bent them to 90 degrees so I didn’t have to cut the plugs off the fans and inserted them into the modules.


Three Part Fan ExtractorArduino
Three Stage fan extractors for soldering or other small hobby fumes.
  // Three stage small extractor fan
  // GAS sensor output pin to Arduino analog A0 pin
  // PWM pins used to drive fans to allow tickover speeds and prevent back flow
  #define F1 5        // Define DIGITAL pin for Fan 1
  #define F2 6        // Define DIGITAL pin for Fan 2
  #define F3 9        // Define DIGITAL pin for Fan 3
  #define MQ2 A0      // Define ANALOG pin for MQ sensor
  #define gasadj A1   // Define trim pot
  #define Alarm 4     // Define DIGITAL pin for buzzer
  int lgl1 = 17;      // lower gas level for Fan 1
  int lgl2 = 19;      // upper gas level for fan 1
  int mgl1 = lgl2;    // lower gas level for fan 2
  int mgl2 = 28;      // upper gas level for fan 2
  int hgl1 = mgl2;    // lower gas level for fan 3
  int hgl2 = 254;     // upper gas level for fan 3
  int gaslevel;       // blank holder
  int settle = 3000;  // Allow settle time to be set here
  int gaschange;      // will be used as a trim adjustment factor
  int tick = 100;     // set tickover speed
  void setup()
  Serial.begin(9600);   // Initialize serial port - 9600 bps
  pinMode(MQ2,INPUT);   // MQ pin set
  pinMode(F1,OUTPUT);   // Fan 1 pin set
  pinMode(F2,OUTPUT);   // Fan 2 pin set
  pinMode(F3,OUTPUT);   // Fan 3 pin set
  pinMode(Alarm,INPUT); // Alarm pin set
  _delay_ms (10000);    // MQ Heater warm up can be changed to suit.

TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00); // Used to reduce motor harmonics
TCCR0B = _BV(CS01); // Used to reduce motor harmonics from PWM
OCR0A = 180;        // Used to reduce motor harmonics from PWM
OCR0B = 180;        // Used to reduce motor harmonics from PWM

    //set up for spreadsheet output
    Serial.println("ClearRange,A,2,d,5000"); // Used to set up PLX-DAQ v2.1
    Serial.println("ROW,SET,2");            //
  void loop()
     //gaschange = (analogRead (gasadj));         // read pot to adjust levels
     //gaschange = map(gasadj,0,1023,-20,20);     // mappedValue = +-20
     //lgl1=lgl1+gaschange;lgl2=lgl2+gaschange;   // add to levels
     //mgl1=mgl1+gaschange;mgl2=mgl2+gaschange;   //
     //hgl1=hgl1+gaschange;                       // Move this to its own routine
    gaslevel = (analogRead(MQ2));           // Get Gass level
    gaslevel = map(gaslevel,0,1023,0,255);  // Map gas range

             Serial.println((String) "DATA,DATE,TIME," + (gaslevel));//+","+(gaschange)); 
   if ( gaslevel > lgl1 && gaslevel <= lgl2 ) 
   {                          // If gaslevel is greater than 20 and less than 30 turn on Fan 1
      analogWrite (F1,tick);  // Fan 1 TICK
      digitalWrite (F2,LOW);  // FAN 2 OFF
      _delay_ms (settle*2);   // Fan settle time extended
      digitalWrite (F3,HIGH); // Fan 3 ON
      _delay_ms (settle);
    else if ( gaslevel > mgl1 && gaslevel <= mgl2 ) 
    {                             // If gaslevel is greater than 30 and less than 60 Turn on Fan 1 and 2
          analogWrite (F1,tick);  // Fan 1 TICK
          _delay_ms (settle*3);   // Fan settle time extended
          digitalWrite (F2,HIGH); // Fan 2 ON
          digitalWrite (F3,HIGH); // Fan 3 ON
         else if (gaslevel > hgl1  && gaslevel <= hgl2 ) 
         {                         // IF gaslevel is greater than 60 and less than 90 turn all fans on   && gaslevel <= hgl2
          digitalWrite (F1,HIGH);  // Fan 3 ON
          digitalWrite (F2,HIGH);  // Fan 2 ON
          digitalWrite (F3,HIGH);  // Fan 1 ON
          _delay_ms (settle * 4);  // Fan settle time extended
         if (gaslevel>=100)  {tone (9,900,1000) ;} // Alarm on 
         if (F3==LOW) {noTone(9);}
           analogWrite (F1,tick);   // Fan 1 TICK
           digitalWrite (F2,LOW);   // Fan 2 OFF
           digitalWrite (F3,LOW);   // Fan 3 OFF
           _delay_ms (settle);      // Fan settle time
Three Stage Fan system
Three stage van ventilation system

Custom parts and enclosures

First duct section ready for fans.
First section of 3" duct. Boxes were made from scrap thin plywood except the end which is MDF. The wiring will be INSIDE the duct and run back to an end cap that will be the mount for the Arduino, MOFSET board and PSU
20170402 174810 d8lcvad1ce


Starting assembly of the duct
Fan boxes attached.
Paint applied.
Wire loom installed in duct
Fans hooked up to loom and mounted.
20170405 103435 0iepqqhtrw
Test fit final board to end cap
Final version will use a Chinese Micro.
The Micro has female headers and the board below has male pins to allow disassembly. Right side of board will take the sensor and power from a voltage dropper and the left side will accept the outputs from the MOSFETS and the higher power needed for the fans.
20170405 112101 8itgfvqe6a
Test fit the voltage regulator below the MINI
The Voltage regulator fits nicely over the resistors using male header pins.
and by using the female headers on the MINI there is enough room to prevent touching the MINI as well.
20170405 120536 kucsfpabwn


Similar projects you might like

Cheap DIY LASER ALARM - Multi Functional!

Project tutorial by Danny van den Brande

  • 12 respects

Multi Temperature Sensor

Project tutorial by WT040

  • 17 respects

Micro Soldering Station

Project tutorial by Paulo Bruckmann

  • 59 respects

Matrix Orbital GTT TFT Thermometer Stage 1

Project tutorial by MatrixOrbital

  • 14 respects

DIY Small Linear Stage

Project showcase by noboyu

  • 8 respects
Add projectSign up / Login