This is the code for my air filtration control system. It is designed to integrate with a Bambu printer and control an air filtration system, e.g. a Bento Box air filter
It uses two sensors, one for air temperature and humidity, and one for VOCs. The temperature/humidity sensor is used to calibrate the VOC sensor.
It is designed to allow you to to integrate with the MQTT server built into Bambu printers.
It also has a JSON based HTTP api which lets you configure thresholds for when the air filter will run (which is controlled by MOSFETs)
Run idf.py menuconfig and set the variables in the fan controller config
section.
E.g.
WiFI SSID: <your wifi SSID>
WiFI Password: <your wifi password>
Maximum WiFI Retry Count: 10
Broker URI: mqtts://bblp:<password>@192.168.0.186:8883
Device Serial Number: <your serial number> (can be obtained from the printer itself)
Build the project and flash it to the board, then run the monitor tool to view the serial output:
Run idf.py -p PORT flash monitor to build, flash and monitor the project.
(To exit the serial monitor, type Ctrl-].)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
- esp32 development board (any of them will do, but the pinout varies between them so you have to figure that out yourself)
- sht-30 temperature and humidity sensor from here
- sgp40 air quality sensor from here
- DC-DC converter that takes the 24v from the printer power supply and drops it down to 12v, from here
- Fans like these which run on 12v from the above regulator.
- For powering the microcontroller you need another buck converter which will connect to the larger one and drop it down to 3v. E.g. any of these would work. Make sure to tune it with the trimpot and once you're happy glue the trimpot adjustor with some silicone glue to keep it from changing due to vibration from the printer.
- For controlling the fans you can use any MOSFETs that have a suitable gate threshold voltage (VGS) of 3v and can handle the amount of voltage and current needed to run the fans.


