Smart Bambu P1P Enclosure With ESP32, Home Assistant and Grafana

by koMaker in Workshop > 3D Printing

169 Views, 1 Favorites, 0 Comments

Smart Bambu P1P Enclosure With ESP32, Home Assistant and Grafana

IMG_5050.jpeg
IMG_5667.jpeg
Screenshot 2026-05-12 001442.jpg

For one of my projects (DIY robotic actuator), I needed to print components in Polycarbonate (PC). PC places significantly higher demands on enclosure temperature during printing than the materials I normally print with, such as PLA and PETG. Without an enclosure, problems such as warping, layer separation and dimensional inaccuracies occur quickly. Since my Bambu Lab P1P does not include a closed enclosure by default, I decided to design and build one myself.

While designing the enclosure, I also wanted better insight into its thermal behavior. I wanted to monitor temperatures and humidity levels in real time and analyze graphs to optimize the enclosure for the filament types I currently use — and plan to use in the future — including PLA, PETG, TPU and PC.

This eventually evolved into a fully integrated enclosure solution featuring:

  1. temperature and humidity monitoring
  2. ESP32-based control with OLED status display
  3. support for multiple filament profiles
  4. Home Assistant integration
  5. Grafana logging and analysis

Supplies

WhatsApp Image 2026-04-10 at 16.49.20.jpeg
WhatsApp Image 2026-04-10 at 21.11.00.jpeg

3D Printer & Enclosure

  1. Bambu Lab P1P
  2. IKEA Lack table
  3. Black lacquered MDF top panel
  4. Acrylic / plexiglass panels
  5. Printed hinges and mounting parts
  6. Threaded rod M3
  7. CAT6 cable
  8. Assorted screws, nuts and spacers

Electronics

  1. Seeed Studio XIAO ESP32-S3
  2. 2× Adafruit SHT31 temperature/humidity sensors
  3. Adafruit 1.3” OLED display (I²C)
  4. Pushbutton switch
  5. Buck converter power supply (220V => 5V)
  6. STEMMA QT I²C cables/connectors

Software / Platforms

  1. Arduino IDE
  2. Home Assistant
  3. Grafana
  4. InfluxDB

Printed Parts

  1. Adjustable SHT31/SHT41 sensor mounts
  2. Control box enclosure
  3. Filament feed-through
  4. Purge chute / waste outlet parts
  5. Mounting brackets and spacers

ENCLOSURE CONSTRUCTION

WhatsApp Image 2026-04-11 at 14.22.22.jpeg
WhatsApp Image 2026-04-11 at 21.54.20.jpeg
IMG_5828.jpeg
Screenshot 2026-04-19 005904.png
Screenshot 2026-04-19 160656.png
IMG_5653.jpeg
IMG_5827.jpeg
IMG_5552.jpeg

The enclosure is based on an IKEA Lack table and was inspired by the many community examples available on Thingiverse, Printables and Instructables.


For the hinges and mounting components I used parts from: https://www.thingiverse.com/thing:4705780


Instead of using the original Lack tabletop, I installed a black lacquered MDF top panel for additional rigidity.


The enclosure uses transparent acrylic panels so the printer remains visible during printing. I also made several practical modifications:

  1. filament spool relocated from the rear to the top of the enclosure
  2. custom extended filament feed-through
  3. purge outlet routed outside the enclosure (https://www.printables.com/model/658920-bambu-poop-pipe)
  4. external purge waste container


For the temperature and humidity sensors, I designed a height-adjustable sensor mount in Fusion and published it on Printables:

https://www.printables.com/model/1693681-adjustable-sht31-sht41-enclosure-sensor-mount-for


By positioning the sensors at different heights, temperature gradients inside the enclosure can be measured and analyzed accurately. In my current setup, one sensor is positioned near the print zone, while the second sensor is mounted approximately 8 cm below the enclosure roof to measure the warmest air layer inside the chamber.

ELECTRONICS AND CONTROL BOX

IMG_5646.jpeg
IMG_5651.jpeg
IMG_5659.jpeg
IMG_5667.jpeg
IMG_5670.jpeg
IMG_5751.jpeg
IMG_5753.jpeg
IMG_5754.jpeg
IMG_5755.jpeg
Schematic.jpg

The central controller of the system is a compact ESP32 with integrated WiFi (Seeed Studio XIAO ESP32‑S3). I selected the ESP32 because of its compact size, integrated WiFi, processing power and native USB support.


The ESP32 handles:

  1. reading the sensors and pushbutton
  2. OLED display control
  3. integration with Home Assistant (HA)
  4. monitoring and control logic
  5. filament profile management
  6. persistent storage of settings in ESP32 flash memory


For temperature and humidity monitoring I selected two Adafruit SHT31 sensors because of their:

  1. good accuracy and stable measurements
  2. simple I²C integration
  3. compact breakout boards
  4. excellent Arduino/ESPHome library support


Besides the ESP32 and the two SHT31 sensors, the following hardware is used:

  1. Adafruit 1.3” OLED display (I²C)
  2. pushbutton for filament profile selection
  3. STEMMA QT I²C cabling
  4. buck converter power supply


Communication between the ESP32, sensors and OLED display is fully based on I²C communication.


The electronics and mains wiring are housed inside a separate control box mounted on top of the enclosure.


A pushbutton mounted on one of the enclosure panels allows switching between filament profiles locally from the enclosure in addition to HA (app/browser).


The sensors and pushbutton are connected to the control box using CAT6 cable so that power, I²C signals and switch signals are combined neatly into a single cable bundle.


The OLED display shows:

  1. active filament profile
  2. top temperature and humidity
  3. bed temperature and humidity
  4. WiFi status (W+/W−)
  5. MQTT status (M+/M−)
  6. ΔT difference between top and bed sensors
  7. temperature status for the selected filament profile (LOW / OK / HIGH)

CONTROL AND HOME ASSISTANT INTEGRATION

Screenshot 2026-05-11 234159.jpg
Screenshot 2026-05-12 001054.jpg
Screenshot 2026-05-12 000957.jpg

The software for the ESP32 was developed using the Arduino framework. The code handles the control logic, sensor interfacing, pushbutton handling, OLED display control, WiFi connectivity and MQTT communication with the local network and MQTT broker.


To keep the software manageable and easy to maintain, the codebase was split into multiple tabs/modules with separate responsibilities such as sensor handling, MQTT communication, OLED rendering and filament profile management.


The code for this project was developed together with ChatGPT as a collaborative coding and debugging tool.


The enclosure is fully integrated into Home Assistant via WiFi and MQTT.


The ESP32 automatically publishes all sensors and entities through MQTT Auto Discovery. As a result, all entities appear automatically inside HA without requiring manual YAML configuration.


I also created a dedicated HA dashboard showing the same information as displayed on the OLED screen. In addition, the active filament profile can be changed directly from the dashboard, providing the same functionality as the physical pushbutton on the enclosure.


For each filament type (PLA, PETG, TPU and PC), minimum and maximum enclosure temperature limits can be configured directly from HA. Based on these limits, the ESP32 determines the enclosure status for the selected filament profile:

  1. LOW → temperature below desired range
  2. OK → temperature within desired range
  3. HIGH → temperature above desired range


The following MQTT topics are used:

  1. P1P_enclosure/state
  2. P1P_enclosure/availability
  3. P1P_enclosure/cmd/filament
  4. P1P_enclosure/profile/state
  5. P1P_enclosure/cmd/profile/<filament>/<min|max>


All measurement data is forwarded to InfluxDB and visualized in Grafana.

RESULTS AND FUTURE IMPROVEMENTS

Screenshot 2026-05-12 001442.jpg

The enclosure performs thermally stable. Grafana graphs make it possible to analyze temperature curves, warm-up behavior and temperature gradients inside the enclosure.


Average enclosure temperatures measured:

  1. PLA: approximately 34°C
  2. PETG: approximately 38°C
  3. PC: initially approximately 39°C, increasing to approximately 45°C after improving enclosure sealing
  4. TPU: not tested yet


These results match the expected thermal behavior of the enclosure and confirm that the enclosure functions as intended.


Observations:

  1. Stable temperature curves with minimal fluctuations, indicating the enclosure seals well
  2. Fast warm-up behavior, reaching a stable temperature plateau within approximately 10–15 minutes
  3. The print bed is the dominant heat source, while the nozzle contributes relatively little to overall enclosure temperature


The enclosure performs very well for PLA and PETG printing. PC printing also works well, especially for smaller mechanical components such as gears and functional prototypes.


For larger PC prints, further optimization may still be beneficial, especially in situations involving:

  1. warping
  2. layer separation
  3. corner lifting
  4. dimensional inaccuracies


In those situations it is likely beneficial to increase enclosure temperatures towards 45–50°C by:

  1. improving enclosure sealing further
  2. reducing top gaps
  3. reducing heat loss from power supply unit airflow