Projects

Fire Prevention

Smoke Detector for 3D Printers

Johann Wyss

Issue 18, December 2018

This article includes additional downloadable resources.
Please log in to access.

Log in

Here’s a simple project that could help prevent your 3D printer (and home!) from going up in smoke should there be an unexpected fault.

WARNING: This device is not intended to replace normal safe operating procedures for your 3D printer. i.e. do not leave your 3D printer unattended and always have a functioning smoke detector in the room where 3D printers are in operation.

BUILD TIME: 5 HOURS
DIFFICULTY RATING: Intermediate

Thanks to mass production and increasing popularity, 3D printers are now much more affordable and an exciting addition to many hobbyist workbenches. Unfortunately, we are now hearing reports of 3D printers catching fire, destroying the printer entirely, causing damage to homes, and sometimes hospitalising people suffering from ABS smoke inhalation!

Whilst it is certainly a very rare occurrence, there is an inherent fire risk with any device that heats up to the temperatures involved with 3D printing i.e. over 200°C+. Improper wiring, poor connections, a poor quality power supply, loose heater cartridge or dislodged thermistor could cause a fire. Some early 3D printer models may not include fire prevention measures in their firmware, such as thermal runaway protection should the thermistor move out of position. Be sure you have the latest firmware for your printer.

Considering the number of moving parts and the heat some of them reach, you should regularly inspect and maintain your printer. Check for any loose components, inspect all wiring, tighten any terminals and look for any heat affected components. For added peace of mind, you could build this smoke detector, designed to cut the power to the printer if smoke is detected.

THE BROAD OVERVIEW

Whilst a smoke detector is designed to save lives, I was pondering a way to save property. Imagine if you combined a smoke detector with an automatic switch, which if it detected smoke would de-energize a circuit. This could hopefully prevent an unexpected fault condition from becoming a house fire.

This circuit is based around the MQ-2 gas sensor. Combined with an Arduino, common electronic components, and some simple code, we’re able to trigger a relay that disconnects power to a DC powered printer.

HOW IT WORKS

The device has two main functions required for successful operation. First, it must be able to detect smoke before the presence of fire. Secondly, it must be able to de-energize a circuit so that the failure state does not cause a cascading failure.

To detect the smoke, I opted to use the MQ range of sensors, which I also used in my LPG gas detector project in issue 17. For this project, I will use the MQ-2 sensor that detects various gasses from smoke to hydrogen.

These sensors are reasonably accurate for their low cost, provided you’re not using the device for life-saving purposes. The sensor essentially is a variable resistor, which automatically varies its resistance when exposed to smoke and specific gasses.

The sensor’s resistance is then placed in series with a fixed value resistor creating a voltage divider. If you take a measurement at the point the two resistors meet and ground, whilst applying a voltage to the circuit, you get a voltage which varies in relation to the level of smoke and or gasses passing the sensor.

This varying voltage can then be read using the analog to digital converter of a microcontroller. Once the microcontroller reads that value, we can simply program it to respond if that value exceeds a pre-determined level.

However, some of the MQ-2 sensors have an operational amplifier comparator circuit built into them with a potentiometer allowing the user to set a threshold limit. You could easily use this to control the gate of a MOSFET, however, I opted to use the microcontroller, as I did not want the circuit to re-energize if the value of smoke dropped back down below the threshold.

You can build a latching circuit with a couple of transistors, which would keep the gate high if triggered, but the added cost and complexity exceeds just using the microcontroller that only costs a couple of bucks.

The Test Jig:

Viability Testing

Parts Required:JaycarAltronicsCore Electronics
1 × Arduino Compatible NanoXC4414Z6372CE05101
1 × Sparkfun OLED Display--LCD-13003
1 × MQ-2 Sensor--SEN0127
1 x 8-Pin Terminal StripHM3211P5430PRT-00116

Parts Required:

A breadboard and prototyping hardware is also required.

You will also need a 12V 40W extruder heater cartridge. I purchased my 84-12v-40w-ceramic-heater-cartridge from Aurarum.

We have all heard the adage “when there’s smoke there’s fire”. For this device to work correctly this adage had to be wrong. The device needs to detect the conditions for fire before a fire has the chance to initiate and propagate. The only way to test this is, of course, to replicate the expected conditions and record the results.

The test is to simulate when the heater cartridge falls out and comes in contact with the 3D printed model or the printer itself, which many believe to be the most likely failure state causing 3D printer fires. If this were to happen and your printer did not have a software failsafe to detect it, the heater cartridge will continue to heat. The thermal sensor attached to the hot end would be recording a lower temp when the heater cartridge falls out.

This condition seemingly could easily cause common 3D printer materials or common 3D printer filaments to heat up past their auto-ignition temperatures and ignite.

Therefore, to test the concept, I created a jig that would simulate this condition. I have included details about my jig if you wanted to build this for yourself.

The jig comprised of a 40W extruder heater cartridge, which is common on many extruders, a third hand to hold it in place, and a power supply. I used my variable power supply set to 12V at 2A.

Using a DMM with thermocouple, my first test was to see how hot the heater cartridge could reach if left unchecked, and if the temperatures it reached were hot enough to cause auto-ignition in common 3D printer materials. Unsurprisingly, the cartridge was able to reach temps exceeding 500°C when provided with the nominal 12 volts at 2 amps. It reached these high temps in less than 60 seconds!

To get an idea of auto-ignition temperatures for filament, we found Material Safety Data Sheets (MSDS) online for Verbatim branded filament. Their datasheet states an auto-ignition temperature of 388°C for PLA and 466°C for their ABS material. Therefore, both materials can easily autoignite by coming into contact with the heater cartridge in an uncontrolled situation, such as the heater cartridge becoming free from the hot end.

The next phase of testing was to see if the MQ-2 sensor was capable of detecting the smoke and gasses emitted when common 3D printer materials come into contact with an uncontrolled heater cartridge. I built a simple breadboard device using the MQ-2 sensor, an Arduino Nano and the Sparkfun micro OLED LCD.

The screen displayed the min, max and average values recorded. I then 3D printed some simple test pieces, which consisted of a small cube with a hole, slightly bigger in diameter of the heater cartridge, in the centre of it.

The test jig was built inside a box of similar volume to the build area of a 3D printer, containing the test rig and the heater cartridge. The test piece was placed on the heater cartridge and power applied to the cartridge until the test piece either melted clear of the heater cartridge or ignited.

The test device could easily detect the smoke and gasses, thus proving its suitability for the task.

Finally, I needed to determine what threshold level was applicable. These gasses are already present when 3D printing, but the sensor still needed to be sensitive to the gasses and smoke present when ABS or PLA materials begin to reach their autoignition temperatures. Therefore, I needed to know what level of gases were present during the normal operation of a 3D printer.

For this, I used the same test rig and simply inserted it inside my 3D printer while it was operating. After a few different prints, using different materials, I was able to ascertain that in normal operation my printer would produce a maximum reading of around 100-180, depending on the material. The threshold must be higher than this value to reduce the impact of false positives.

CONSTRUCTION

When building the test device, set the jumpers on the back of the OLED as follows, which configures the OLED to work with the I2C protocol.

  • D1 and D2 need to be shorted together
  • DC needs to be set to 1
  • BS1 needs to be set to 1 & BS2 needs to be set to 0

You will also need to solder an 8 way terminal strip to the OLED so it can connect to the Breadboard.

Follow the fritzing diagram to complete the circuit. Your MQ-2 sensor may look different from the one in my prototype but they usually have a similar pinout.

THE CODE

Program the Nano with the code on the right. This code will display the minimum, maximum and the average value on the Sparkfun micro OLED screen.

RESULTS FROM VIABILITY TESTING

The viability testing results from my test jig all seemed very positive. This meant the device would, in theory, have no issues in detecting the smoke produced if common 3D printer plastics come into contact with an overheating hot end heater cartridge.

I would, of course, encourage you to do your own testing under your own circumstances, as many variables can come into consideration. The most obvious variable is the volume of air in your build chamber, and whether your 3D printer is enclosed like mine or open frame like the i3’s design. Enclosures with a larger volume may need longer before the smoke reaches the sensor. This extra time could be enough for the material to ignite.

#include <Wire.h>
#include <SFE_MicroOLED.h>
#define PIN_RESET 9
#define DC_JUMPER 1
MicroOLED oled(PIN_RESET, DC_JUMPER);
int sensorPin = 2;
int sensorValue = 0;
int average = 0;
int smokeLevel = 0;
int count = 0;
int loops = 10;
int maximum = 0;
int lower = 1000;
void setup(){
  oled.begin();
  oled.clear(PAGE); oled.clear(ALL);
  oled.display(); 
  delay(500);
  oled.clear(PAGE); oled.clear(ALL);
  oled.display(); 
}
void loop(){
  average = (average + analogRead(sensorPin));
  count ++;
  if(count >= loops){
    smokeLevel = (average / count);
    count = 0;    
    average = 0;  
    if(smokeLevel < lower){
      lower = smokeLevel;
    }  
    if(smokeLevel >= maximum){
      maximum = smokeLevel;
    }
  }
  oled.clear(PAGE);
  oled.setFontType(0);  
  oled.setCursor(15, 2);
  oled.print(analogRead(sensorPin));
  oled.print(" RAW");
  oled.setCursor(17, 11);
  oled.print(lower);
  oled.print(" LOW");
  oled.setCursor(20, 21);
  oled.print(maximum);
  oled.print(" HI");
  oled.setFontType(1);
  oled.setCursor(18, 35);
  oled.print(smokeLevel);
  oled.print(" AVG");  
  oled.display(); 
}

The Fundamental Build:

The Prototype

Additional Parts required:JaycarAltronicsCore Electronics
1 × BuzzerAB3459-ADA1536
1 × IRF1405 N-Chanel-MOSFETZT2468Z1537COM-10213
1 × 1N4001 DiodeZR1004Z0109CE05272
1 × 10KΩ 1/4W Resistor*RR0596R0058PRT-14491
1 × SPDT 12V Automotive RelaySY4070S4335A-

Additional Parts required:

1 × BuzzerAB3459
1 × IRF1405 N-Chanel-MOSFETZT2468
1 × 1N4001 DiodeZR1004
1 × 10KΩ 1/4W Resistor*RR0596
1 × SPDT 12V Automotive RelaySY4070

*Quantity required, may be sold in packs

After successfully proving the concept was viable, I began to build the prototype.

Note: I have used a MOSFET I had on hand, which is overkill for the expected power draw. There is a detailed explanation on how to pick a MOSFET in the USB Soldering Iron project in issue 16 if you wish to find a lower cost option.

ELECTRONICS

There isn’t anything out of the ordinary with this circuit. You pretty much just assemble it as per the fritzing diagram we’ve shown here. However, those new to electronics may not instantly recognise the need for the resistor attached to the MOSFET. This is called a pull-down resistor. Its job is to ensure that the voltage at the gate of the MOSFET stays at zero volts until we want to apply a 5V signal to it.

Without this resistor the MOSFET would sit in an undefined state and constantly switch with noise.

If you purchased the MQ-2 sensor from Core Electronics you will only have 3 pins on your sensor.

  • s = the signal pin going to Analog pin 2.
  • GND going to ground / 0V potential.
  • VCC going to the 5V rail of the Arduino.

If, like me, you had the common 4 pin type you simply ignore the digital output and use the analog, 5V and GND pins.

CONNECTING THE RELAY

I chose an automotive relay because it was easy to wire up, and handles high currents. You can use an alternate relay, providing it handles the current your printer consumes.

If you’re using a standard automotive 12V relay connect it as follows. You want the load i.e. heater cartridge to be connected to the normally closed terminal of the relay usually 87A. 30 and 86 will go to Vcc and 85 will goto the MOSFET drain.

When a positive voltage is applied to the MOSFET gate, current will flow from pin 86 through the coil into the drain of the MOSFET and into ground. This will pull the normally closed connection open, thus preventing current from flowing into the load and stopping the heating process.

FLYBACK/FLYWHEEL DIODE

Inductors (such as a relay coil) store energy as a current flow at a low voltage, but any attempt at disconnecting the inductor from a supply results in a high voltage being generated across the terminals of the inductor. According to Lenz's Law, E = L∂V/∂T, the voltage generated is equal to the Inductance value times the change in current, divided by the change in time. To avoid a very large voltage, a diode is placed in reverse polarity with the inductor. The negative discharge voltage will cause the diode to conduct the collapsing current safely within the inductor and diode.

THE CODE

Setup

const int THRESHOLD = 300;
int sensorPin = 2;
int ledPin = 2;
int sensorValue = 0;
int average = 0;
int smokeLevel = 0;
int count = 0;
int loops = 50;
void setup() {
  pinMode(trigger, OUTPUT);
  pinMode(ledPin, OUTPUT);  
}

Loop

void setup() {
  pinMode(trigger, OUTPUT);
  pinMode(ledPin, OUTPUT);  
}
void loop() {
  average = (average + analogRead(sensorPin));
  count ++;
  if(count >= loops){
    smokeLevel = (average / count);
    count = 0;
    average = 0;
  }
  while(smokeLevel >= THRESHOLD){
    digitalWrite(trigger, HIGH);
  } 
}

With the prototype built and tested, we can now put together a main build for a permanent installation.

The Main Build:

Complete Smoke Detector

ADDITIONAL Parts Required:JaycarAltronicsCore Electronics
1 x Protoboard HP9552--
1 x ATtiny13A or ATtiny85^ ZZ8721Z5105014-9171550
1 x LM7805 5V Regulator ZV1505Z0505CE05291
1 x 10uF Electrolytic Capacitor RE6075R4767CE05274
1 x 100uF Electrolytic Capacitor RE6150R4827CE05258
2 x 10nF Monolythic or Ceramic Capacitors RC5348R2846-
1 x 3-Way Terminal Block HM3173P2029PRT-08235
1 x DC Power Socket PS0520P0621A-
1 × SPDT 12V Automotive Relay SY4070S4335A-
1 x TO220 Heatsink** HH8522H0630PRT-00121

ADDITIONAL Parts Required:

^I used the ATtiny13A. The ATtiny85 should work perfectly fine for this project, however, I have not verified works without needing any modification to the code.

**Refer to the Heatsink section for details on how to pick the correct heatsink for your needs.

The circuit uses an 8-pin ATtiny IC, and uses protoboard, which avoids the need for custom PCB.

I'll run you through how the circuit is powered and whether a heatsink is required depending on your printer's power supply.

Finally, I'll show you how it can be finished in a 3D printed housing.

Linear Power Supply

To power the project, I opted to use an LM7805 linear voltage regulator. They are very cheap and easy to use, however, they are horribly inefficient. Linear (Series) regulators are like a resistor in series with the load that reduces voltage by converting excess voltage into heat. The wattage dissipated by the device can be calculated with the following formula.

P = V × I

P = (Supply Voltage - Regulated Output) × Current

The linear regulator is powering the microcontroller, sensor, MOSFET gate (when triggered), LED and the buzzer.

To add up the total current required, I referred to the supplier’s datasheets for each component.

  • Microcontroller typical = 200µA
  • MQ-2 sensor heater = 200mA
  • MOSFET Gate = Negligible
  • Buzzer = 30mA
  • LED = 15mA

Therefore, the circuit consumes 218.2mA or let’s say 220mA.

To work out the power dissipated by the voltage regulator:

P = V × I

P = (12 - 5) × 0.220

P = 1.54W

Heatsink

To decide if we need a heatsink, we need to calculate how hot we expect the device to get under the expected operating conditions. Our thermal resistance from junction to ambient air for the LM7805 regulator is 65°C per watt. Let’s say at room temperature of 25°C the temperature of the silicon inside the TO220 package will be:

Temp = (R∅JA × PD) + ambient

Temp = (65 × 1.54) + 25

Temp = 125.1°C

Whilst this does not exceed the absolute maximum temperature the device can operate at, operating at this temp for long periods will certainly reduce the life of the component, and risk it failing. Considering the actual environment the device will be operated in we begin to realise we certainly need a heatsink. The device is being operated inside a 3D printer which has many heated components, stepper motors, heater cartridge, heated bed etc all producing heat. It is fairly common for my build chambers to get as hot as 45°C during medium-length prints. As such the temperature of the device would be closer to:

Temp = (R∅JA × PD) + ambient

Temp = (65 × 1.54) + 45

Temp = 145.1°C

This clearly needs a heatsink to pull heat away from the device. I used a small TO220 heatsink and at 24° ambient (airconditioned lab) it would reach about 57°C on the heatsink. As such it would likely benefit from a larger heatsink for long-term usage in a hot environment. However, it is still operating at much less than it's absolute maximum ratings.

CONSTRUCTION

If you have your own PCB making facilities you could make a custom PCB. I made my circuit using 50 x 70mm protoboard that I had available. The case is designed to mount other sizes available at most electronics retailers.

I made the circuit tracks on the underside by bridging the pads together using short pieces of wire from trimmed component legs.

Follow the schematic on the previous page to wire up your circuit. I have included photos of the top and bottom of my board if you need guidance. I should point out that I used an IC socket for my microcontroller and also a header to plug the LED into. You can solder these directly to the board.

Some of the holes need to be drilled to accommodate the larger legs on the terminal blocks.

3D PRINTED ENCLOSURE

The enclosure consists of four parts. The cover is made of two parts which need to be glued together. This was done to reduce the amount of support material needed and thus the amount of cleanup. However, I will also include the one-piece lid/cover for anyone who would rather print fewer components.

The cover then clips into the bottom piece by use of 4 locking tabs. The final part is the mounting bracket, this part is attached to the surface you wish to mount the device too, the rest of the device locks onto this part by aligning two locating lugs and twisting the unit to lock into it.

I designed the enclosure to have 4 large mounting studs, this will allow you to use varying sizes of PCB and make it less crucial to cut and or drill precisely. You can either glue or screw the PCB down these 4 studs.

THE CODE

The final code is very simple, all it is doing is taking a number of readings as defined in the loops variable, in this case, 50. This variable is used to calculate an average reading which reduces the chances of a false reading ruining your 3D print.

The program then takes a reading of the sensor analog output and adds that value to the average variable.

If the program has run 50+ times, as defined in the loops variable, the program then takes the sum of all readings and divides it by the number of samples taken, thus giving an average value.

Setup

const int THRESHOLD = 300;
int sensorPin = 2;
int ledPin = 1; 
int trigger = 0;
int sensorValue = 0;
int average = 0;
int smokeLevel = 0;
int count = 0;
int loops = 50; // number of program loops used to get average
void setup() {
  pinMode(trigger, OUTPUT);
  pinMode(ledPin, OUTPUT);  
      }

The program then checks this value stored in smokeLevel against the predefined constant Threshold value and if the averaged value is higher than the threshold the program pulls the trigger pin high which triggers the relay thus cutting supply to the 3D printer or just the heater cartridge.

Loop

void setup() {
  pinMode(trigger, OUTPUT);
  pinMode(ledPin, OUTPUT);  
}
void loop() {
  average = (average + analogRead(sensorPin));
  count ++;
    if(count >= loops){
    smokeLevel = (average / count);
    count = 0;    
    average = 0;    
  }
  while(smokeLevel >= THRESHOLD){
    digitalWrite(trigger, HIGH);
    }     
}

TESTING

To test the prototype and final build, I made a small PCB using the following components:

  • DC power socket
  • 10A 30VDC PCB mounted relay.
  • 3 pin screw terminal
  • Female pin Header
  • 30W Mini Halogen Bulb

This PCB allowed me to simulate the device operation in a controlled way. I would connect the PCB to a 12V power source and the halogen bulb would instantly illuminate drawing about 2 - 3 Amps (similar to a heater cartridge).

When I applied smoke or other gasses to the MQ-2 sensor the smoke detector would illuminate the LED, sound the buzzer and apply 12V to the coil of the relay. This energises the relay and actuates it from its normally closed position to open circuit. This causes the halogen bulb load to de-energise and proves the correct operation of the device.

LINEAR POWER SUPPLY

The power supply is designed to work with a 12V 3D printer. If you were to use a 24V printer the linear voltage regulator would need a substantially bigger heatsink or perhaps even a separate power supply as the power consumption becomes:

P = V × I P = (24 - 5) × 0.220 P = 4.18W

Therefore, the temperature will reach in expected operation environment:

Temp = (R∅JA × PD) + ambient Temp = (65 x 4.18) + 45 Temp = 316.7°C

The device simply cannot handle this amount of power dissipation and would enter thermal shutdown very quickly.

If you do need to operate at such high input voltages, consider replacing the linear power supply with a cheap off the shelf Switchmode buck converter. The Switchmode type of regulator is vastly more energy efficient than the linear type and will comfortably handle the voltage drop without reaching the melting point of lead.

INSTALLATION

For the best possible chance to detect smoke and shutdown your printer, the detector should be installed in the build chamber. If you are using an open-frame printer, you need to install as close as possible to the print area.

WHERE TO FROM HERE?

There are quite a few ways one could build on and improve this project. My immediate thoughts would be to make it wireless and use an IoT 240V wall socket, so you can turn off multiple devices etc. That could potentially make the device useful for protecting against housefires from Christmas light faults perhaps or other cases where fires are started by overloading of external wiring.

These devices allow you to safely control 240V wall sockets, avoiding any need for you to handle any mains wiring. For example, Jaycar has a 433MHz Remote-Controlled Mains Outlet Controller MS6148. Using the Wireless Power Switch project described on the Jaycar website, you can control the power point using an Arduino, 433MHz controller and some other Arduino gear.

Another option would be to use a device like the Adafruit Huzzah sold by Core Electronics ADA2821. With this module you could have the device send warnings and alerts to your phone in the form of emails or similar which would alert you to the smoke detector triggering.

For a more accurate smoke detection, you could also consider the MAX30105 high-sensitivity optical sensor.