3D Printer Enclosure Guard: Heat and Fume Monitor with Auto Shut-Off
Watch temperature and VOC levels inside your printer enclosure and cut power through a certified smart plug if something goes wrong.
Enclosures help ABS and ASA prints, but they trap heat and fumes. A BME280 and an SGP30 inside the box report to Home Assistant over MQTT, and an automation switches off the printer's smart plug when temperature or VOC readings cross your limits.
This adds a layer of protection; it does not replace one. Keep a working smoke alarm near the printer, make sure thermal runaway protection is enabled in the firmware, use a UL/ETL-listed smart plug rated for the printer's power, and never leave a print running unattended for long periods.
Mission steps
Mount the sensors
Place the BME280 and SGP30 high inside the enclosure, away from the hotend and heated bed, wired to the Pi's I2C pins.
Install libraries
In a venv run pip install adafruit-blinka adafruit-circuitpython-bme280 adafruit-circuitpython-sgp30 paho-mqtt.
Publish readings
The script reads every second (the SGP30 needs that rhythm) and publishes to MQTT; it sends an alarm message over the limits.
Add the shut-off
In Home Assistant, an automation on the alarm topic turns off the printer's smart plug and notifies your phone.
Test safely
Lower the temperature limit below room temperature for a minute and confirm the plug switches off.
Code
import time, json, board
import paho.mqtt.client as mqtt
import adafruit_sgp30
from adafruit_bme280 import basic as adafruit_bme280
i2c = board.I2C()
bme = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)
sgp = adafruit_sgp30.Adafruit_SGP30(i2c)
sgp.iaq_init()
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
client.username_pw_set('printer', 'change-me')
client.connect('homeassistant.local', 1883)
client.loop_start()
MAX_C, MAX_TVOC = 55, 2000 # tune for your printer and filament
while True:
t, tvoc = bme.temperature, sgp.TVOC
client.publish('enclosure/state', json.dumps({'temp': round(t, 1), 'tvoc': tvoc}))
if t > MAX_C or tvoc > MAX_TVOC:
client.publish('enclosure/alarm', 'ON')
time.sleep(1)alias: Printer enclosure emergency off
triggers:
- trigger: mqtt
topic: enclosure/alarm
payload: "ON"
actions:
- action: switch.turn_off
target:
entity_id: switch.printer_plug
- action: notify.notify
data:
message: "Printer power cut: enclosure too hot or fumes too high."
mode: singleTip: test every script on the bench before installing it in a moving machine.
Questions
Does the SGP30 measure styrene or specific chemicals?
No. It gives a total VOC trend, useful for spotting changes but not for exact exposure levels. Ventilate to the outside when printing ABS or ASA.