3d Printer Smoke Detector

1,137

13

1

Posted

Introduction: 3d Printer Smoke Detector

3D printer smoke detector

I built this smoke detector with the hope of feeling more at ease when leaving my printer overnight or going out while its still running. If you had to be around monitoring your printer for every print, you would never leave the house!

The smoke detector is built with an atmega328, LCD display, MQ2 smoke detector and a Photoelectric smoke detector for a secondary option. When the alarm point is reached, a small buzzer will sound and send an output signal to a relay which will ideally be wired into the printers PSU.

The idea is to detect the smoke early and shut the power off to prevent a fire from starting or reaching an uncontrollable state. Just remember,this is not a 100% safeguard to preventing a fire. And leaving your printer alone is done at your own risk.

This PCB has some spare digital and analog pins available for expansion. There's always an option to add an extra mq2 or a temp sensor, larger LCD could be added if you change the case design. Or, the board can be used for any project you wish to use an LCD and atmega328 with a button encoder for control. Gerber files will be available if you wish to get your own PCB made.

I ordered quite a few PCB's, if you want to make this design and don't want to order a batch. Hit me up and I will see if I have any left. You could also make this design on perf board cut to the correct size, I will include the wiring diagram in case anyone wants to go that option.

If you make any changes to improve this device, please let me know and I can include the updates in here.

Instructions

  • There are 11 LCD screen displays available for user control and monitoring
  1. Active: Once the device is powered on you will be at the active screen, which will display when the program is able to react to a smoke detection. There is a 15minute wait time after startup to allow the MQ2 sensor to warm up and stabilise readings. When this time is reached you will hear a series of beeps to indicate the alarms are active. You can skip this and make the program active by pressing the encoder button.
  2. Active alarms: Displays active alarm, press the encoder button to clear.
  3. MQ2 RT Value: Displays the current value received from the MQ2 smoke sensor
  4. Min Max Run: Displays the min and max sensor reading since the device was powered on, press the encoder button to reset to zero. I suggest monitoring this screen for a few prints to see how much variation you have before connecting the relay up to the circuit.
  5. Min Max EEPROM: As above, will store the value for the lifetime of the device until reset using the encoder button. Keep in mind the values will be high when first powered up, or unplugging the MQ2 sensor when the device is on.
  6. Alarm Point Settings: When using trigger mode, this value set is where the device's alarm will be triggered when reading the MQ2 sensor. To change the value: 1.Press the encoder button once 2.Turned the encoder to the value you wish to use.3.Press the encoder button again to lock that value. 4. To save the value in memory you will need to go to the "Save to EEPROM" screen and save the settings.
  7. Save to EEPROM: Navigate to this screen and press the encoder button to save all values to the EEPROM
  8. Operation Mode: There are 2 modes available in this screen, Normal and Manual. 1. Normal mode will be set when the device is powered on, The device will function as normal in this mode. 2. Manual mode will reset any active alarm and prevent any alarms being triggered.
  9. Trigger Mode: There are 2 options available, setpoint trigger mode auto mode. 1. Auto mode is the default on startup, this uses two adjustable values to automatically compare the difference in mq2 reading and time to determine if smoke is detected. Screen 10 and 11 hold the auto adjustments 2. Setpoint trigger mode will alarm when the predetermined value set on screen 6 is exceeded.
  10. Time Threshold: This value is the time in seconds the deviation of the MQ2 value is checked. Reduce or increase this setting to change the detection tolerance.
  11. Change Threshold: This is the MQ2 value deviation allowed within the time frame set on screen 10. Reduce or increase this setting to change the detection tolerance.

Step 1: BOM - Get All the Parts Ready

All the parts are easy to find, it's just hard to order the quantity you need. I purchased most of the parts through aliexpress. You could even get most of this stuff at your local electronics store.

Hardware/PCB parts:

  1. PCB https://www.pcbway.com/orderonline.aspx (gerber files attached)
  2. 10k Potentiometer https://www.aliexpress.com/item/10Pcs-lot-3296W-1...
  3. PCB connector x 3 https://www.aliexpress.com/item/50-sets-Kit-in-bo...

1x3pin, 2x4pin ---- Optional for debug 1x5pin

  1. button encoder https://www.aliexpress.com/item/Promotion-3Pcs-6m...
  2. 22 pf capacitor x 2 https://www.aliexpress.com/item/200pcs-22PF-50V-2...
  3. l780 voltage reg https://www.aliexpress.com/item/Free-shipping-10p...
  4. .47uf 50v cap x 2 https://www.aliexpress.com/item/50Pcs-50V-47UF-47...
  5. 10uf 50v https://www.aliexpress.com/item/Pengiriman-gratis...
  6. 16mhz crystal https://www.aliexpress.com/item/50pcs-Crystal-16M...
  7. PCB power socket https://www.aliexpress.com/item/10Pcs-PCB-Mount-5...
  8. 220ohm resistor https://www.aliexpress.com/item/100pcs-220-ohm-1-...
  9. 100ohm resistor https://www.aliexpress.com/item/100pcs-100-ohm-1-...
  10. 10k resistor x 4 https://www.aliexpress.com/item/100pcs-10k-ohm-1-...
  11. LCD 1602 https://www.aliexpress.com/item/1602-162-16-2-Cha...
  12. Buzzer https://www.aliexpress.com/item/Black-Plastic-14-...
  13. Atmega328 https://www.aliexpress.com/item/Atmega-328-Chip-w...

Optional: Is an MCU socket for the atmega328 allowing you to remove it, I have added this to my build.

Hardware.....

  1. Mq2 sensor https://www.aliexpress.com/item/Smart-Electronics-...
  2. Wiring https://www.aliexpress.com/item/Free-Shipping-10M...
  3. PSU 9v 1a https://www.aliexpress.com/item/AC-100-240V-Conver..
  4. Relay https://www.aliexpress.com/item/2PCS-LOT-New-5V-2...

You can use a PSU between 12v and 7v. But, if you go the option below you need to run a 9v as the power supply to that port has no regulation. The supply will be regulated by the 9v PSU.

  1. Optional: PE smoke detector https://www.ebay.com.au/itm/Smoke-Sensor-Module-S...

Software:

  1. Arduino IDE

Equipment

  1. Soldering iron
  2. solder
  3. solder flux
  4. 3d Printer (abs or PLA)
  5. Arduino uno or another form of MCU programmer

Step 2: Programing the MCU

I used the arduino uno to upload the sketch to my MCU. I won't go into detail as there is plenty of information out there on how to do this. There is also information on how to install the bootloader if the chip you ordered didn't have one. I will link the page that has all the information.

https://www.arduino.cc/en/Tutorial/ArduinoToBreadb...

You can upload to the chip at this time if you follow the guide linked above, or (assuming you have a bootloader installed) you can wait until the board is assembled and attach a 5pin clip to the ports available on the top/right of the board and wire these up to the arduino to program it this way. This would make it easy to upload new sketches to the board in future.

If you choose to go the below option you will have to jump back once you have the PCB assembled

Pinout of the board to the arduino:

Pinout left to right. Make sure you disconnect you PSU and sensors when connecting the arduino

  1. Reset
  2. RX
  3. TX
  4. Ground
  5. 5v

Once the wiring is correct, remove the MCU from the arduino uno and upload the sketch via the arduino IDE to the PCB as you normally would to a UNO.

https://www.arduino.cc/en/Main/Howto

Make sure you have the following libraries:

  • Wire.h
  • LiquidCrystal.h
  • EEPROM.h
<p>#include <Wire.h><br>#include <LiquidCrystal.h>
#include <EEPROM.h></p><p>#define CH1 8   // Connect Digital Pin 8 on Arduino to CH1 on Relay Module</p><p> int wait = 500; //delay before displaying value on lcd
 int n = 1;
 int d = 1000; //delay
 int count = 0;
 int minutes = 0;// count down tell relay shut off will be active</p><p> // auto mode variables</p><p> 
 int gasPinPrev = 10; // fix lcd when dropping from 3 digits to 2
 int alarmPoint = 0; 
 int tone1 = 1000; // tone var
 int lcdDisplay = 0; // set to start up display switch case
 int displayConsHigh = 9;// leave max the number of displays, contrains max number when turning encoder
 int buttonPressed = 0;
 int pressedValue = 0; 
 int pressedValue1 = 0; 
 int pressedValue2 = 0;</p><p> int dp4 = 4;
 </p><p> int sensorVal;// value or sensor plus alarm threshold
 int runMin = 1000;//resets min max variables
 int runMax = 0;
 
 //stored eeprom adresses
 int addr = 13;
 int addr1 = 3; // eprom min address
 int addr2 = 5; // eprom max address
 int addr3 = 15; // eeprom bool stored as int
 int addr4 = 25; // eeprom bool stored as int
 int addr5 = 50; // eeprom bool stored as int</p><p> int runMinEprom;
 int runMaxEprom;
 int triggerBoolInt; //Stores a number to be refered as a bool</p><p> // auto mode variables
 int timeThresh;// difference in time threshold when checking values
 int valThresh;// diference in sensor value threshold
 
 float alarmPointf = 0.0f;
 
 bool active = false;// bool for start timer
 bool mode = true; // bool for manual or normal operation. Normal operation = true
 bool autoAlarm = false;</p><p> boolean gasDetect = false; // has gas been detected ?
 boolean firstRun = true;
 volatile boolean TurnDetected; // reads encoder input
 volatile boolean up;</p><p> const int gasPin = A0; //GAS sensor output pin to Arduino analog A0 pin
 const int buzzer = 9; // Buzzer to pin 9 wuth 100ohm resistor between
 const int PinCLK=2;                   // Used for generating interrupts using CLK signal
 const int PinDT=3;                    // Used for reading DT signal
 const int PinSW=5;                    // Used for the push button switch
 
 unsigned long autoCount = 0; // auto mode time holder 
 unsigned long previousMillis = 0;// create var to store previous millis
 unsigned long alarmTimmer = 0; 
 unsigned long lastPressed; // store millis for transcoder button</p><p> const int rs = 12, en = 11, d4 = 10, d5 = 13, d6 = 6, d7 = 7;
 LiquidCrystal lcd(rs, en, d4, d5, d6, d7);</p><p> void isr ()  {                    // Interrupt service routine is executed when a HIGH to LOW transition is detected on CLK
    if (digitalRead(PinCLK))
     up = digitalRead(PinDT);
    else
      up = !digitalRead(PinDT);
      TurnDetected = true;
}</p><p>void startNoise()
{
 tone(buzzer, 1000); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
 tone(buzzer, 1500); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
 tone(buzzer, 2000); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
 tone(buzzer, 2500); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
}</p><p>void saveNoise()
{
 tone(buzzer, 2500); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
 tone(buzzer, 1500); // Send 1KHz sound signal...
 delay(100);
 noTone(buzzer);
 tone(buzzer, 900); // Send 1KHz sound signal...
 delay(200);
 noTone(buzzer);
}</p><p> void setup(){</p><p>  lastPressed = millis();</p><p>  lcd.begin (16,2);
  lcd.home ();     
  lcd.print("Loading..");
  lcd.blink();
  //delay(d); //Wait 2 seconds before starting sequence
  lcd.print("..."); 
  lcd.blink();
  Serial.begin(9600); //Initialize serial port</p><p>   pinMode(dp4, INPUT_PULLUP);</p><p>   digitalWrite(CH1,LOW);
   pinMode(CH1, OUTPUT);
   pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
   pinMode(PinCLK,INPUT);
   pinMode(PinDT,INPUT);  
   pinMode(PinSW,INPUT);
   
   previousMillis = millis();
 
   //delay(d); //Wait 2 seconds before starting sequence
   lcd.print(".."); 
   lcd.blink();
   //delay(d);
   lcd.clear();</p><p>   alarmPointf = EEPROM.get(addr, alarmPointf);
   alarmPointf = alarmPointf * 4;
   alarmPoint = (int)(alarmPointf);
   Serial.println (alarmPoint);</p><p> // EEPROM.write(addr4, timeThresh);
  //EEPROM.write(addr5, valThresh);
   timeThresh = EEPROM.read(addr4);
   valThresh = EEPROM.read(addr5);
   runMinEprom = EEPROM.read(addr1);
   runMaxEprom = EEPROM.read(addr2);
   triggerBoolInt = EEPROM.read(addr3);</p><p>   attachInterrupt (0,isr,FALLING);   // interrupt 0 is always connected to pin 2 on Arduino UNO</p><p>   startNoise();
   lcd.noBlink();
   //delay(500);             
 }</p><p> void settings()
 {
       if(firstRun){lcd.clear();firstRun = false;}</p><p>       if(buttonPressed == 1){alarmPoint = pressedValue;Serial.println (alarmPoint);}
       lcd.setCursor ( 0, 0 );
       lcd.print("Settings");
       lcd.setCursor ( 0, 1 );
       lcd.print("Alarm Point: ");
       lcd.setCursor ( 12, 1 );
       lcd.print(alarmPoint);
       //Serial.print ("alarmpoint =");
       //Serial.println (alarmPoint);
 }</p><p> void timeThreshMethod()
 {
       if(firstRun){lcd.clear(); firstRun = false;}</p><p>       if(buttonPressed == 1){timeThresh = pressedValue1;Serial.println (timeThresh);}
       lcd.setCursor ( 0, 0 );
       lcd.print("Time Threshold");
       lcd.setCursor ( 0, 1 );
       lcd.print("Duration: ");
       lcd.setCursor ( 9, 1 );
       lcd.print(timeThresh);
       lcd.setCursor ( 11, 1 );
       lcd.print("Sec");
       
       
       //Serial.print ("alarmpoint =");
       //Serial.println (alarmPoint);
 }</p><p> void valThreshMethod()
 {
       if(firstRun){lcd.clear(); firstRun = false;}</p><p>       if(buttonPressed == 1){valThresh = pressedValue2;Serial.println (valThresh);}
       lcd.setCursor ( 0, 0 );
       lcd.print("Change Threshold");
       lcd.setCursor ( 0, 1 );
       lcd.print("Gas Dev: ");
       lcd.setCursor ( 8, 1 );
       lcd.print(valThresh);
       
       
       //Serial.print ("alarmpoint =");
       //Serial.println (alarmPoint);
 }
 
 void gasLevelDisplay()
  {
    
    
    if(buttonPressed == 1){buttonPressed = 0;}
   if(firstRun)
     {
        firstRun = false;
        lcd.clear();
        lcd.setCursor ( 0, 0 );
        lcd.print("MQ2 RT Vaule");
        lcd.setCursor ( 0, 1 );
        lcd.print("Gas Level=  ");
        lcd.print(analogRead(gasPin));
     }
   
   if(gasPinPrev > 99 && analogRead(gasPin) < 100)
    {
       lcd.clear();
       lcd.setCursor ( 0, 0 );
       lcd.print("Smoke Fail safe");
       lcd.setCursor ( 0, 1 );
       lcd.print("Gas Level=  ");
     
   
    }</p><p>    if(count > wait)
    {
        lcd.setCursor ( 12, 1 );
        lcd.print(analogRead(gasPin));
        //Serial.print ("count greater then wait");
        count = 0;
     Serial.print("auto Count:  ");
     Serial.println (autoCount);
     Serial.print("Current Millis:  ");
     Serial.println (millis());
     Serial.print("Gas Pin + :  ");
     Serial.println (sensorVal);
     Serial.print("Amalog Read:  ");
     Serial.println (analogRead(gasPin));
        
    }
    count++;
    //Serial.println (count);
     gasPinPrev = analogRead(gasPin);</p><p>  }</p><p> void maxMinrun()
 {
    if(firstRun){lcd.clear();firstRun = false;}</p><p>       if(buttonPressed == 1){runMin = 500; runMax = 0;buttonPressed = 0;Serial.println("Button pressed off in minRun");firstRun = true;}  
       lcd.setCursor ( 0, 0 );
       lcd.print("Min Max Run");
       lcd.setCursor ( 0, 1 );
       lcd.print("Min: ");
       lcd.setCursor ( 4, 1 );
       lcd.print(runMin);
       lcd.setCursor ( 7, 1 );
       lcd.print(" Max: ");
       lcd.print(runMax);
 }</p><p> void saveEEPROM()
 {
    if(firstRun){lcd.clear();firstRun = false;lcd.setCursor ( 0, 0 );lcd.print("Save to EEPROM?");lcd.setCursor ( 0, 1 );lcd.print("Press to save..");}</p><p>    if(buttonPressed == 1)
      {
        buttonPressed = 0;
        lcd.clear();
        lcd.setCursor ( 0, 0 );
        lcd.print("Save to EEPROM?");
        lcd.setCursor ( 0, 1 );
        lcd.print("....Saved...");
        saveNoise();
        
        alarmPointf = (float)alarmPoint / 4;
        // possibly only save if number changed, if statement ????
       
        EEPROM.put(addr, alarmPointf);
        EEPROM.update(addr4, timeThresh);
        EEPROM.update(addr5, valThresh);
      }</p><p>    
 }</p><p>  void maxMinrunEprom()
 {
    if(firstRun){lcd.clear();firstRun = false;}</p><p>       if(buttonPressed == 1){runMinEprom =254; runMaxEprom = 0;buttonPressed = 0;Serial.println("Button pressed off in minRun");firstRun = true;}  
       lcd.setCursor ( 0, 0 );
       lcd.print("Min Max Eprom");
       lcd.setCursor ( 0, 1 );
       lcd.print("Min: ");
       lcd.setCursor ( 4, 1 );
       lcd.print(runMinEprom);
       lcd.setCursor ( 7, 1 );
       lcd.print(" Max: ");
       lcd.print(runMaxEprom);
 }</p><p>   void onForTime()
 {
    if(firstRun){lcd.clear();firstRun = false;}</p><p>       if(buttonPressed == 1){active = true;buttonPressed = 0;firstRun == true;lcd.clear();}  </p><p>       
       lcd.setCursor ( 0, 0 );
       lcd.print("Active= ");
       if(active==false){lcd.print(" False");}
       if(active==true){lcd.print(" True");}
       
       if(active==false)
       {
          lcd.setCursor ( 0, 1 );
          lcd.print ("Active in: ");
          lcd.print (minutes);
          lcd.print ("min");
       }</p><p>       if(active==true)
       {
          lcd.setCursor ( 0, 1 );
          lcd.print ("Program Active");
       }
  
 }</p><p> 
   void normalOp()
 {
    if(firstRun){lcd.clear();firstRun = false;}</p><p>       if(buttonPressed == 1){mode = !mode;buttonPressed = 0;autoAlarm = false;digitalWrite(CH1,LOW);}  </p><p>       
       lcd.setCursor ( 0, 0 );
       lcd.print("Operation mode: ");
       lcd.setCursor ( 0, 1 );
       if(mode==true){lcd.print("Normal Operation");}
       if(mode==false){lcd.print("Manual Operation");}
       
  
  
 }</p><p>    void triggerMode()
 {
    if(firstRun){lcd.clear();firstRun = false;}</p><p>      if(buttonPressed == 1)
      {
        buttonPressed = 0;
        if(triggerBoolInt == 1){triggerBoolInt = 0;}else{triggerBoolInt = 1;}
        EEPROM.write(addr3, triggerBoolInt);
      } </p><p>       //EEPROM.write(addr3, 1);
       lcd.setCursor ( 0, 0 );
       lcd.print("Trigger Mode: ");
       lcd.setCursor ( 0, 1 );
       if(triggerBoolInt==1){lcd.print("SetPoint Trigger");}
       if(triggerBoolInt==0){lcd.print("Auto Trigger        ");}
       
  
  
 }
  
 void userInputHandle()
 {
    volatile static long virtualPosition=0;
    if (!(digitalRead(PinSW)) && lastPressed < millis()) 
           {      // check if pushbutton is pressed
               lastPressed = millis() +1000;// if YES, then reset counter to ZERO
               if(buttonPressed == 0)
               {
                  buttonPressed++;
                  pressedValue = alarmPoint;
                  pressedValue1 = timeThresh;
                  pressedValue2 = valThresh;
                  Serial.println("buttonPressed on");
                 
               }
               else if(buttonPressed == 1)
               {
                  buttonPressed--;
                  //timeThresh = timeThresh * 1000;
                  Serial.println("Button pressed off");
               }</p><p>             tone(buzzer, 1000); // Send 1KHz sound signal...
             delay(100);
                      
           }  
 
 if (TurnDetected)  { // do this only if rotation was detected
  tone(buzzer,1000,150);
   if (up){
     virtualPosition++;
     if(buttonPressed != 1){lcdDisplay++;}
    // Serial.print ("value up by 1");
     pressedValue = pressedValue + 1;pressedValue1 = pressedValue1 + 1;;pressedValue2 = pressedValue2 + 1;}
     
   else{
     virtualPosition--;
      if(buttonPressed != 1){lcdDisplay--;}
     //Serial.print ("value down by 1");
     pressedValue = pressedValue - 1;pressedValue1 = pressedValue1 - 1;pressedValue2 = pressedValue2 - 1;}
     
     
   TurnDetected = false;          // do NOT repeat IF loop until new rotation detected
   Serial.print ("Count = ");  
   Serial.println (virtualPosition);
   
   if(buttonPressed != 1)
   {
    
    if (lcdDisplay > displayConsHigh){lcdDisplay = displayConsHigh;}
    if (lcdDisplay <= 0){lcdDisplay =  0;}
   }
   firstRun = true;
   //Serial.print ("LCD Display Number = ");
   //Serial.println (lcdDisplay);
 }
 }
 </p><p>  void BuzAlarm(int interval, int freq1, int freq2)
    {    
         unsigned long currentMillis = millis();
         </p><p>         if(currentMillis - previousMillis >= interval)
         {
           previousMillis = currentMillis;</p><p>            if(tone1 == freq1)
            {
                tone1 = freq2;
               noTone(buzzer);
            }else
                {
                   tone1 = freq1;;
                 }
                 
         tone(buzzer, tone1);
        }
  }</p><p> void SmokeDetector()
  {
      int sensorVal = digitalRead(dp4);
      Serial.println(sensorVal);
      if(sensorVal == 0 && active == true && mode == true && triggerBoolInt == 0)
      {
        autoAlarm = true; 
       }
  
  }</p><p>  void autoMode()
  {
     int timeNew = timeThresh * 1000;
     
     if (millis() > autoCount) {autoCount = millis() + timeNew; sensorVal = analogRead(gasPin);}
     if(analogRead(gasPin) > sensorVal + valThresh && active == true && mode == true && triggerBoolInt == 0 ){autoAlarm = true;}</p><p>     if(timeNew <= 0){autoAlarm = true;}
     //delay(1000);
     // Serial.println(valThresh); 
      //Serial.println(timeNew); 
  }
    
 void loop()
 {
   //Serial.print ("alarmPointf");
  // Serial.println (alarmPointf);
   
   //Serial.print ("alarmP");
   //Serial.println (alarmPoint);
   //delay(200);
  
  userInputHandle();</p><p>        if(analogRead(gasPin) > runMax){runMax = analogRead(gasPin);}
        if(analogRead(gasPin) < runMin){runMin = analogRead(gasPin);}
        if(analogRead(gasPin) < runMinEprom){runMinEprom = analogRead(gasPin);EEPROM.write(addr1, runMinEprom);}
        if(analogRead(gasPin) > runMaxEprom){runMaxEprom = analogRead(gasPin);EEPROM.write(addr2, runMaxEprom);}
        
        autoMode();
        SmokeDetector();
        
        
        if (analogRead(gasPin) > alarmPoint && buttonPressed != 1)
        {
          alarmTimmer = millis() + 4000;
        }
        if(alarmTimmer > millis()&& active == true && mode == true && triggerBoolInt == 1)
        {
          
          digitalWrite(CH1, HIGH);  //turn off relay
          BuzAlarm(120, 2500, 1000);
        }
        if(autoAlarm)
        {
          digitalWrite(CH1, HIGH);  //turn off relay
          BuzAlarm(120, 2500, 1000);
          Serial.println ("auto alarm triggered");
        }else
          {   
             noTone(buzzer);
          } </p><p>    if(active == false){minutes = millis()/60000;minutes = 1 - minutes;if(minutes == 0){active = true; firstRun = true; tone(buzzer, 1500);delay(100);noTone(buzzer);tone(buzzer, 1500);delay(100);noTone(buzzer);tone(buzzer, 1500);delay(100);noTone(buzzer);tone(buzzer, 1500);delay(100);noTone(buzzer);}}
     if(active == false){int seconds = millis()/1000.0;seconds = 60 - seconds; if(seconds < 0){seconds = 60;} }
   
   
    //if(!mode){Serial.println("false");} 
    // LCD Display decider below
    //Serial.print("TimeThresh:  ");
    //Serial.println(timeThresh);
    //Serial.print("valThresh:  ");
    //Serial.println(gasPin);
  </p><p>    switch (lcdDisplay)
    {
      case 0:   
        onForTime();
        break;
      case 1:
      {
        gasLevelDisplay();
        break;
      }
      case 2:
      {
        maxMinrun();
        break;
      }
            case 3:
      {
        maxMinrunEprom();
        break;
      }   
           case 4:
      {
         settings();// also displays manual alarm value change
         break;
      }
          case 5:
       {   
          saveEEPROM();// posible delete and have this save to eeprom once changed
          break;
      }
         case 6:
       {  
         normalOp();
         break; 
      }
         case 7:
         {
         triggerMode();
         break; 
      }
               
         case 8:
         {
         timeThreshMethod();
         break; 
      }
        case 9:
        valThreshMethod();
        break;
    }
  </p><p>      
  
 }</p>

Step 3: PCB Assembly and Clip Wiring

The board is pretty simple to assemble, If you get the board made with the supplied gerber files the part locations will be labelled. There are a few capacitors and the buzzer that doesn't have the polarity labelled. I've added some markings on the image attached to this step.

Clip pinout:

I will start from left to right (circled green):

  1. Clip1: MQ2
    1. VCC
    2. GND
    3. A0
  2. Clip 2: Optional smoke detector
    1. K
    2. DC9
    3. G
    4. GND
  3. Relay output: The board has an output for 2 relays for expansion with the software. If using a single relay just wire it to the in1 to switch the relay.
    1. IN1
    2. IN2
    3. VCC
    4. GND

Relay Wiring Mains:

As it is dangerous to work with mains power I won't be explaining how this side of the relay is connected. Please consult with an electrician to wire this up.

If you chose to use a perf board, please see the attached schematics diagram.

Step 4: Print the Case

The STL files for printing are located on the Thingiverse link supplied below. The design was made to be quickly and easily printed, not many areas required for infill (only screw areas).

https://www.thingiverse.com/thing:2835521

I printed in ABS and used a brim.

1.2mm top and bottom layers

1mm wall thickness.

50% infill make the mounting points strong

Step 5: Assemble - Complete

All you have to basically do now is screw the PCB into the case, and screw it all together and power it up.

Where you mount the MQ2 is up to you, I have mine at the top of the printer, If you take a look on Thingiverse there are some great cases already made for the sensor.

As mentioned earlier, I recommend running it for a few prints without printer power supply hooked up to the relay, clear the min max run screen after the MQ2 has warmed and stabilized. You can monitor the change when normally printing and experiment changing the auto-configuration numbers.

You would want it to be responsive as possible to reduce the chance of a fire getting out of control.

If you need any assistance, just comment and I will see if I can help. I you make one, please share on here or thingyverse. Thanks

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments