Making a smart enclosure for the Original Prusa MK4

published Feb 04, 2024, last modified Apr 25, 2024

Electronics, ESPHome, and Home Assistant to the rescue.

Making a smart enclosure for the Original Prusa MK4

I recently bought an Original Prusa MK4 with its enclosure (which was quite the labor to put together!).  The printer has turned out to be a fantastic purchase — I couldn't be happier with it.

Prusa MK4 printers are fully compatible with Home Assistant — they have their own built-in integration that allows limited control of prints, and lets the user see the status + a preview of the printout.  On that basis, I've already made a dashboard for myself, so I can monitor printing time and state.

Since I'll be printing filaments that emit styrene and other noxious gases, in addition to the enclosure I also ordered the advanced filtration system (and its requisite base board + power supply).  The base board and supply can also power and control an LED strip (24 volts), and the board includes a two-push-button front panel to turn the light and the fan on and off (not depicted here).

While my LED strip is still not here, I could still have put all of this together, and be ready to print noxious filaments.  However, as you can see, I haven't yet put together the advanced filtration system.  Why?

What does "a smart enclosure" mean?

To me, it means:

  • Things that need to happen must be automatic:
    • I shouldn't have to push a button to run the fan.  If the filament I've set the machine to print with is not one of the known non-toxic filaments, the fan shouldn't run needlessly.
    • However, in any other case, the fan should run for the entire duration of the print, and keep going 15 minutes after the printer.
    • Then, the fan should be quiet.
    • Perhaps the fan should auto-run only when there are contaminants detected in the enclosure, regardless of whether there is a print going on.
  • Functionally and aesthetically, it should remain "stock":
    • "Digital buttons" notwithstanding, the push buttons on the base board (which attaches to the front panel) should operate correctly, allowing me to manually start and stop both enclosure light and filtration fan as I please.
    • Aesthetically, it should look as close to an unmodified Original Prusa enclosure plus the add-ons Prusa Research sells.
  • Stretch goals:
    • Video dashboard!
      • There should be a camera (ideally a device like an ESP32-CAM) filming, that allows me to view what's going on through my Home Assistant office dashboard.
      • When the camera is filming, the enclosure light should automatically come on.  This should be pretty easy to accomplish with Home Assistant, since an automation can turn the light on when the camera begins streaming, and the light can then be turned off when streaming stops.
    • Fan speed control!
      • It should be possible to make the fan spin faster the more contaminants in the enclosure are detected.
      • The fan can be quite noisy at top speed;  it should also be possible for the user to define at what speed the fan should spin.
      • A short, low-speed run of the fan can be used to periodically whiz contaminants past a sensor, and then use this to detect if the air is clean or not.  Dyson filtering fans do this when set to automatic mode.

The technical parts can be done with an ESPHome-programmed ESP32 device.  The aesthetic and functional parts can be done with a little care.

This post explores doing exactly that.

Before we start

You may want to read my series of guides on powering various electric devices using ESPHome and cheap electronics.  This is background knowledge that will help you understand the details of the electronics we'll be building in this post:

  1. How to control a 24 volt LED strip using an ESP32 and ESPHome
  2. Govern an LED strip using a MOSFET, an ESP32 and ESPHome

Many of the components mentioned in those guides will be featured in this guide.

What you'll need

ESP32

I need a circuit that does all of the above.  For that circuit to become real, there are a few items I need to add to my shopping list:

First, I'll need an ESP32.  ESP32s are microcontrollers from Espressif that (1) are very cheap (2) are very versatile (3) consume very little power (4) feature a lot of options for input and output, from GPIO through Bluetooth to Wi-Fi.

For this project, I've chosen the Freenove ESP32-S3-WROOM, which can be found on AliExpress and on Amazon for a few bucks.  This ESP32 comes with a fairly well-sized antenna, and a connector that accepts both OV2640 and OV5640 cameras.

Camera

I'll need a camera for the ESP32 device.  The OV2640 camera that comes with the Freenove ESP32 has decent frame rate, but suffers from bad picture quality.  An OV5640 camera with a 120 degree angle will fit the bill in its stead.

These cameras need thermal dissipation because they can get extremely hot, so you'll have to purchase a copper heat sink and double-sided thermally conductive tapeDo not omit the purchase of the conductive tape, even if the heat sinks appear to ship with it — the tape that ships with these heat sinks is thermally isolating, and therefore would be very bad for your camera.  You may also substitute the tape for self-adhesive thermal pads you can cut to size.

MOSFET power module

I'll need one MOSFET module.  I bought my MOSFET modules from here.  These modules are needed because the LED strip requires 24 volts and over 50 watts of power together (supplied by the power adapter Prusa ships), but the ESP32 device "speaks in 3.3 volts" and can only safely do 20 milliwatts per GPIO pin (before giving up the magic smoke).  The fan will run with 24 volts, but it won't need a MOSFET module — we'll be using using direct-from-ESP32 PWM control to control the state of the fan.

DC-DC converter

I'll also need a MP1584EN / LM2596 step-down DC-DC converter, to take the 24 volts of the power supply and convert them into 3.3 volts that the ESP32 device needs.  The photos below show how the board looks like  almost exactly, but it may arrive with a chip that says 150 instead of 100 — this is fine.

Printed circuit board

I will need a PCB layout.  Download this PCB layout, then order it printed through a PCB printing business like JLCPCB.  To this layout we'll mount all the electronic components.  For reference, this is how the board (as of version 1.2) looks like:

Electronics case

The electronics you'll put together will need a case.

The case consists of three independent friction-fit parts you'll assemble and install within your MK4 enclosure later on.

Download, slice and print this electronics case using your favorite PLA+ filament, at 0.2mm layer height in structural input shaper mode.

The download has a FreeCAD file and a 3MF file directly printable using PrusaSlicer; the 3MF file in the provided download is currently set to print using a Sunlu PLA+ filament, but you can change that before slicing.

Important print settings to double-check in your slicer: support angle threshold at 40 degrees, organic support types, print all parts sitting on their largest flat contiguous surfaces. The most elegant color for the print to be seamless within your enclosure is black.

Screws and nuts

To affix the electronics case to the enclosure, you'll need two M3x4 hex head screws and matching nuts (maximum 3mm thick).  You may get away with using the excess rivets that shipped with your Prusa MK4 enclosure, but since the enclosure also ships with excess M3x4 hex screws and nuts you might as well use the bolts and nuts.  The screws have two key advantages over the rivets: they tighten parts much more snugly than the rivets, and they will look stock in the final build.

If you only have M3x8 screws, and you are careful, you can cut them up to half their length and they will work too.

Lighting

The enclosure needs lighting.  To that effect, you'll need a 24 volts DC LED light.

You can purchase a fully assembled and working LED light, ready to be mounted somewhere within your enclosure, if you so prefer — this will save you a lot of labor.  Just make sure that the LED is 24 volts and consumes less than 1 ampere.  Prusa Research sells an LED strip that can be mounted easily to the enclosure.

For this project, I bought a 5 meter self-adhesive LED strip that works with 24 volts DC and can be cut to size.  This will work perfectly with the power supply sent by Prusa Research, and will illuminate the printed parts from above.

I will not be using the entire roll!  Rather, I'll cut as much of the power strip I think it's necessary to illuminate the enclosure well for the camera to work at night, and then strategically place the segments (interconnected in series) on the roof of the enclosure to illuminate the printout.

For the record, at 24 volts supplied, the roll consumes about 2 amperes — just this load alone would overwhelm the power supply that came with the base board.  Whichever LED lighting you choose, be sure not to exceed 1 ampere at its final sizing.

Never power the strip while on its roll for more than a few seconds at a time — you can overheat and burn it that way.

Wiring

Some wiring will be necessary as well.  To wit:

  • Get some insulated two-lead 22AWG wire to bring power to the lighting.  One of the sides will need to be soldered (or crimped) into the input wiring of the lighting; the other side will hook up to the PCB using a JST XH connector (see below).
  • Get insulated ribbon cabling to attach the other, non-power-demanding components.  I bought this 10-lead ribbon wire from Amazon.  This cabling does not need to be thick-gauge since it will not be carrying high currents.  Any ribbon wire with 4 leads or more will work here — you will only use 4 of the leads when making cabled interconnects.

Optional: connector modules for DIY LED array assembly

I will use short segments of 22AWG wire to solder LED segments in my DIY LED strip.  This could be a lot of work you may want to avoid.

There is a solution to avoid this soldering labor: these solderless LED strip connection modules exist and you can purchase them.  Make sure you purchase the right kind of connection modules — in my case, the strip I will use is 10mm wide so I will purchase get the 2-pin 10mm units.

To make your life a little easier, you can choose to get both strip to wire as well as the strip to strip modules — but anything that lets you crimp a two-lead wire to the LED strip is fine.

Headers: sockets and connectors

Get a kit of JST XH 2.50mm pitch male connectors, female through-hole solderable headers and pins; these will be used to hook up the front panel and the fan.   This is what I did: I bought this header / connector / pin JST crimp kit and the JST header crimping tool.

With these supplies:

  • stable connection points can be created on the PCB,
  • the 4-wire and 2-wire cables  (of the exact lengths we need) can be created, and
  • the connector that ships with the fan cable can be replaced with the JST-XH connector that the PCB requires.

Auxiliary PCB parts

Get PCB pin strips to attach some components to the PCB board.  These pins fit the holes of the breadboard as well as the components, can be broken off individually, and any excess length is easily cut with wire trimmers.

Get a female 5.5 / 2.1 through-hole barrel socket to take up the 24 volts produced by the Prusa Research power supply.  Alternatively, you can purchase 5.5 / 2.1 mm barrel sockets with built-in cables.  Here are photos of a through-hole barrel socket and wired barrel sockets / plugs:

I will need a fuse holder and a 2 amp fuse.  The fuse holder can be obtained here (it's depicted below) and the fuses can be these (but it's on you to check that they really do blow at 2 amps).  The fuse is important for safety.  They usually come with protective lids, but you won't use the lid on your project's fuse holder, since the electronics case already has a lid.

Air quality sensor

Optionally, you can add an air quality sensor to your project.

While any I2C sensor with 3.3 volt power should work, I've chosen the BME688 from Bosch, in convenient SparkFun packaging form.  The project will include code to enable this sensor, should you get one for your own setup.  Do not touch the silver metal casing of the sensor at the center of the board.

You can use any air quality sensor you prefer (if, for example, you care about particulate matter instead of gases).  There are many sensors good for ESPHome use, but any sensor you choose must be 3.3 volt-powered and must support the I2C communication protocol.  Of course, if you choose a different sensor, you will have to alter the ESPHome programming of your smart enclosure to work correctly — refer to the ESPHome documentation for your chosen sensor.

Passive components

In addition to the parts above, you'll need a few electronics components that can be found pretty much anywhere online (and would be available in Radio Shack, if Radio Shack still existed in its original form):

  • One through-hole resistor 5000 Ω (5K1) in value, and another through-hole resistor 4600 Ω (4K7) in value.
    • They will be used to limit current going to the PWM pin of the fan, and current coming from the tachometer pin of the fan.
    • In a pinch, two 4600 Ω resistors would work, and two 5000 Ω resistors might work.
  • One through-hole ceramic non-polar 151 (150 pF) capacitor.
    • This cap will filter transients in the PWM signal for the fan.
  • Two through-hole Schottky diodes, part number 1N5819.
    • They will help rapidly unload reactive currents (back EMF spikes) from the motor of the fan and the LED strips, when they are switched off.
    • This blog carries a tutorial on how to govern high voltage loads using relays, which explains back EMF spikes — you should read it.

Parts from Prusa Research

From Prusa Research, you'll need the PSU, the base board, and the advanced filtration system.  I don't include photos here, because these are better photographed on Prusa Research's site (see the links).

Tooling and supplies

You will need a soldering iron, some flux you can apply onto the PCB, and a roll of rosin core solder.

I recommend you own a simple multimeter with alligator clips, and some DuPont wires.  These will be extremely useful to test for voltages and continuity.  Without a multimeter, you are generally flying blind.  Cables with retractable hooks on both ends will also be very useful for testing.

As far as other tools go, you will definitely need wire cutting pliers.  Have a pair of thin needle-nose pliers too — you'll use them to crimp JST XH pins in some circumstances.

Have some Kapton or electrician's insulating tape around, as well as some heat-shrink tubing suited for AWG22 wire.

Software

Finally, on the software side, we'll use ESPHome.  ESPHome is software that makes it extremely easy to program these ESP32 devices; instead of having to hand-roll C++, all I have to do is put together a YAML file (which I'll supply below) and this puts together all the functionality we need from the circuit, almost straight into the ESP chip.

You might prefer to install the ESPHome add-on on your Home Assistant instance;  if you don't have Home Assistant and don't plan to use it, you can manually install a standalone copy of ESPHome on your computer.  Either way, you'll need ESPHome on a computer with an USB type C port in order to program the ESP32.

Programming

FIXME explain that the microcontroller needs to be programmed here, because once on the board, USB ports are not accessible.

FIXME the web server must be uncommented.  The user must be instructed to comment it out later, if he plans to use Home Assistant.  Same goes for the MJPEG streaming endpoint.

FIXME instruct the user of the existence of the Web server.

FIXME camera and I2C sensor parts of the code must be commented out to prevent errors when testing.  The user must be instructed to uncomment that part later, and reprogram the ESP wirelessly.

Build the hardware

Prepare the camera

Follow these steps to prepare the camera for use:

  • Do each following step with the camera lens cover on.
  • Many of the heat sinks for small devices usually come with a double-sided 3M backing tape.  You need to remove every trace and bit of that tape, because that tape is actually thermally isolating.  Use isopropyl alcohol or another solvent to clean the back of the heat sink.
  • Place the heat sink upside down.
  • Cut an appropriately sized square from the thermally conductive tape, and firmly affix it to the heat sink.  Make sure no bubbles are under the tape; start over and repeat the process if you see any.  Cut any excess protruding from the sides of the heat sink.
  • Peel off the other side of the tape, and affix the heat sink with the tape squarely in the center of the back of the camera (which should have a metal backing).  Keep the camera covered with its built-in cover while you do this, so as to not impregnate the lens with grime or skin oils.

Once your camera has its heatsink properly installed, friction-fit the camera onto the camera support part of the electronics case you printed.  Thread the ribbon cable of the camera through the vent hole at the top of the camera support part.  The fit should go around the neck of the camera, it should be snug, and it should look like this:

Prepare the fan

Since the fan comes with a CLIK-MATE connector, but we're using JST XH connectors in this project, we are going to have to re-pin the cable, and then insert the pins into the JST connector.

A quick primer on making JST connectors well

The process is somewhat complicated, requiring the specialized JST crimping tool to do it fast, although it can be done (very carefully and very slowly) with a pair of thin needle-nose pliers as well.  If you're using the tool, here's a video full of macro shots that teaches you in detail how to do it; the process described is as follows:

  1. Cut the existing connector from the four-lead flat cable of the fan.
  2. Separate the four leads from each other roughly an inch long.
  3. Strip the end of all four leads to expose 2 millimeters of wire strands.
  4. For each lead, do as follows:
    1. Carefully insert the lead from the side of the long wings until the lead "stops".
      • The bare wire must be where the short wings (at the center of the pin) are, and the insulation must be where the long wings are.
      • Do not bend the strands or over-insert the lead — this will interfere with JST connection mating and can cause a short circuit.
    2. Crimp the wings of the pin around the lead using your tool or needle-nose pliers, making sure that the end of the pin (square-shaped, with a tiny spring) is not damaged in any way.
    3. Ensure that the short wings have tightly clamped on the bare wire strands, and the long wings are tightly wrapped around the insulation of the lead.
    4. Tug on the wire with reasonable force, while holding the pin firmly.  The lead should not come out of the pin.  If it comes out, start over again from the top.
    5. Insert the finished pin with lead into the JST socket.
      • The crimped pin goes into the channel only one way: the tiny spring aligned with the window (tiny hole) at the end of the bottom of connector, where the spring will lock and it will no longer be possible to remove the pin.
      • The spring of the crimped pin should somewhat click into place once it gets all the way in.
      • You may want to use the tip of a paper clip to push the pin all the way in.

The order in which the pins must be inserted is as follows: with pins 1 to 4 of the connector facing up, the negative lead (that's the lead with dashed white markings on its insulation) goes into pin 1 of the connector.  Then the rest of the pins go in the same order as they are on the cable.

Here is the instruction video on how to use the crimping tool I mentioned earlier.  This man seems to be a pro at this!  I failed numerous times until I got it right:

Here are some photos of the process; I have omitted my many failures just to prove it can be done:

Fan pinout

For reference, this is the pinout of the fan (with its corresponding position of each cable in the JST connector):

  1. Pin 1 is the negative terminal.
  2. Pin 2 is voltage in (24 volts).  It should be to the right of pin 1.
  3. Pin 3 is the tachometer output, to measure fan speed.
  4. Pin 4 is the PWM input, to govern fan speed.

Test the fan spins correctly

Connect 24 volt power to pin 1 (negative) and pin 2 (positive) of the fan's JST plug.  You can use the DuPont lead trick to supply power to the JST plug.

If you use the Prusa Research PSU to supply power, remember that the outside of the barrel plug is negative, while the inside of the plug is positive (double-check this with your multimeter and the polarity label printed on the PSU).  To safely test the fan using the PSU, you'll need a barrel plug cable with bare leads, as well as a way to clip each bare lead to a DuPont lead that can be inserted into the fan plug's tiny holes.  Be very careful not to short the bare leads as this will burn your PSU.

When you supply power to the fan this way, the fan should spin at its maximum speed sucking air through the filter and pushing air through the exhaust holes.  If the fan doesn't spin or it spins backwards, you have an issue you must fix in your connector.

Prepare the lighting

Ready-to-go lighting fixture?

You may have chosen a single high-power 24 volt LED, or a finished 24 volt LED fixture to mount to the ceiling of your enclosure, or even the LED fixture sold by Prusa Research for their enclosure.  All of those are fine choices.

All you must ensure in this case is that the wiring of the LED is properly terminated with a 2-pin male JST XH plug, where pin 1 is ground (negative) and pin 2 is (positive) 24 volts.

Do-it-yourself LED strip?

I chose to go the self-sticking LED strip route, so I have to actually prepare a lighting array using the LED strip.  My plan is to light the printing area of the Prusa MK4 (when the printer is running) with an el cheapo divisible LED strip I purchased, which means I have to affix segments of the strip in a roughly square configuration inside the ceiling of the printer, right above that printing area.

To maximize the amount of lighting covering that area (after some current measurement experimentation) I chose to go with 5 segments (each 30 cm wide) of 12 LED blocks (6 LEDs) each.  Given each strip is 1 cm wide, if we allow for 4 cm between strips, that creates a rectangular shape 30 cm wide (left-to-right) and 36 cm deep (front-to-back).  This yields about 0.9 amperes of power consumption — well within the safe margins for the cabling and headers this project specifies.

Cut the strips to size:

Solder the strips in series:

  • To minimize cable run, I elected to place the input leads of the strip such that they are closest to the the front left corner of the enclosure's top panel (on the underside).
    • The segments will be stuck to the inside of top panel in an orientation upside down of how they are soldered together.
    • This means the segment with the input must be to the right and at the bottom (closest to me) on my soldering workstation.
    • Thus, when mounting, I can flip the entire array upside down, and the input lead will be where I need it to be.
    • See the final test photo below to understand the final arrangement of the soldered LED segments.
  • When soldering, I used my calipers to space the strips out consistently, then cut and stripped the cabling accordingly to conform to this size.
    • You may choose to use a wooden template or some other sort of more precise spacing mechanism.
  • Importantly, when soldering, you must solder strips in series: the negative rail of one segment must be connected to the negative of the other segment, and the same is true for the positive rail.
    • This has interesting implications for the connection leads and the orientation of the strips — between two strips, one of the leads (either positive or negative) is always shorter than the other, and strips must be oriented in alternating rotations.
  • Note that the insulation should not be stripped more than 3 millimeters — cut excess stripped wire to size.  Finally, be careful not to move the lead as the solder is solidifying; you may get a weak connection if it does.

Here is the process I went through, depicted in photos:

I recommend you test every successful soldering step using a 24 volt power supply.  The last thing you want is to discover that you have to redo everything because a connection in the middle of the series is bad.

After testing, I insulated the exposed solder points using Kapton tape, carefully lifting a short amount of the adhesive backing from the segment before insulating the back of the solder points.  Other methods of protecting these solder points include standard electrical insulation tape or some other non-conductive medium like hot glue.  I verified with my multimeter that the tape is insulating (some variants of Kapton tape can be conductive).

With the LED array complete, I tested it:

I then made an extension cord that will connect the LED array to the PCB header designated for the lights (LEDSOCKET1), by attaching a JST XH 2-pin male connector to one ond of the cord.  The pinout is trivial: black (negative) to pin 1, red (24 volts positive) to pin 2.

A note about cable length: because of where I was planning to place the first LED segment, I calculated that the total cable run only needs to be 141 centimeters minus 9 centimeters (the length of the input leads) which equals 132 centimeters.  In my build, I ended up making this cord 135 centimeters long just in case, but (based on the placement of the first LED segment) this led me to have a 13 centimeter slack at the side of the connector; in retrospect, 122–123 centimeters would have been perfect.  Expect the total cable run length to vary for you too.

Since the typical LED cable has thicker insulation than signal-carrying cables, I had problems attaching the pins using the crimping tool as the pressure it exerts was cutting my leads outright.  I ended up having to carefully crimp the JST XH pins using thin needle-nose pliers under a magnifying glass.  I think the needle-nose pliers job turned out quite well — I tugged on the pins and none came off.

The final step is to mate the extension cord to the LED array by soldering it.

  • Insulate the connection.
    • Prior to soldering, insert some heat-shrink tubing around each lead of the extension cord.
    • Once the soldering is done, slide the heat-shrink tubing over the solder point of each leg, then heat up the tubing to make a tight insulation around the lead.
    • If you don't have heat-shrink tubing, you can accomplish insulating the two wires from each other by rolling electrician's tape around each individual solder point, then around the junction.  This is harder to do than heat-shrink tubing insulation.
  • Pay attention to the polarity when soldering the leads!  Black -> pin 1.  Red -> pin 2.

Prepare the sensor

To hook up the sensor, you need to do two things:

  1. Add a JST XH 4-pin socket to the sensor.
  2. Create a 4-lead cable, 10 centimeters (4 inches) longer than the cable of the filtration fan, ending with 4-pin JST connectors on both sides.

Soldering the socket to the sensor is easy.  Just make sure that pin 1 in the socket is soldered to GND on the sensor; pins 2 will be power (3V3), 3 SDA and 4 SCL.

Since I purchased a 10-lead cable, I repurpose 4 of its leads for this use by carefully prying four leads apart from the rest of the cable, making sure not to nick the insulation of any individual lead.   After separation, this is how it looks.

Strip 2 mm on both sides of each lead, and crimp JST pins to each stripped lead end.  I recommend that, once you're done crimping all pins, you test for continuity of every lead at both sides before inserting the pins into their respective connector.  Don't forget to tug on the pins to see if the leads are properly secured.  Doing these things before inserting the pins will save you from having to redo the connectors later.

As we did before with the fan, insert the pins into the connectors such that pin 1 is always leftmost / connects to ground when the connector's friction locks are facing up.  Note how the color codes of the wires match on both connectors.

At this point, you may want to test continuity on each lead again, using your multimeter and some DuPont jumper wires.

Test the sensor

The sensor should power on (an LED should turn on) when supplied with 3.3 volts to the 3V3 pin and grounded on the GND pin.  You can rig on a breadboard the 3.3 volt power converter to a 24 volt supply to generate the necessary power for the sensor, or you can use as supply the 3V3 and GND pins on your ESP32 device while supplying the ESP32 device with 5 volts power via USB.

Wire up the control buttons on the base board

We'll use the base board as a mechanism to control fan and lighting manually.  For that, we need to hook up those buttons to our ESP32 device; this is the first step to accomplishing that.

Carefully solder the top and bottom pins of each button to a two-lead cable each (each cable should be 70 cm long, and should not be thinner than 26AWG).

Following that, crimp JST XH pins to the other side of the wires (same as you did before with the fan), and insert those pins into a male JST XH plug.

Pay close attention to how you solder the wires and make the connector:

  • Pin 1 and pin 2 of your connector (ideally, black and red wire) must attach to the top and bottom leg of the fan button.  The name of the button is silkscreened in the back of the board.
  • Pin 3 and pin 4 of your connector (white and yellow in the picture below) must attach to the top and bottom leg of the LED button.
  • Pin 1 is the leftmost pin when the JST XH connector has the dual friction fit locks facing up.  The flat side of the JST XH connector with the windows for the pin springs is the bottom side.
  • By convention within this project, pin 1 of JST connectors is always ground / negative.  This particular hookup is no exception.

Here is how the board should look like after soldering.  The friction fit locks on the connector are blurry in the photo, but they are facing up.  Excuse the wire being too short in this example — I made a wire length mistake and have corrected that mistake after the fact by making an extension cable.

Test the buttons

To test for continuity, insert pin headers / DuPont wires into pins 1 and 2 of the JST XH connector, and attach the other side of said wires or pins to your multimeter's alligator clips.  Set the multimeter to resistance / continuity test mode.  When depressing the fan button, there should be continuity.  Repeat the test for pins 3 and 4 with the LED button.

Ignore the rest of the board.  We don't care about its electronics any more.

Place and solder all parts on the PCB

Before you start, make sure you don't have the camera attached to the Freenove ESP32.  Besides the annoyance it would cause you while soldering, the ribbon cable of the camera is delicate and can break or burn during soldering.  Be careful when popping open the brown cable clip holder that secures the camera ribbon cable — those clips are delicate and can break if an uneven pull force is applied to them.

With the PCB, place each component according to the schematic, and solder each pin of the component that the schematic wants soldered on its respective through-hole.

Solder components from shortest to tallest.  Avoid soldering e.g. the fuse holder first, since the fuse holder is the tallest one, and a soldered fuse holder will give you trouble soldering all other components, as the board will be upside down while you solder.  The one exception is the ESP32 — solder it last.  Try to solder it without inserting it too deeply, to provide clearance for the USB ports, should you need to reflash it later.

When you solder the fuse holder, please be absolutely sure its base is flush with the board.  The fuse holder is the tallest component on the board — there will not be much space left between the fuse holder clip and the electronics case lid.

Pay attention to the polarity of components.  Diodes and power will both give you a hell of a bad time if you put them in opposite directly to what the schematic orders.  In general, non-LED diodes from this build all have their negative side (cathode) connected to some sort of power, and their positive side to ground.

Sockets for JST connectors have an orientation too — the silk screen drawings on the PCB should match the shape of the connectors when inserted.

While the PCB is precision-made for most of the components, through-hole components should have their legs bent appropriately to fit their holes during soldering, then cut after the solder has cooled off.  There should be little to no space taken by component legs on the back side of the board.  Here is a bent leg from the fuse holder:

Components that don't have their own legs should be attached to the PCB with the PCB pins you purchased for this project.  When doing so, solder the pin on both sides — the component side and the PCB side.  Using pliers or wire cutters, break off the plastic that's stuck to the pin.

Make sure to clip any and all excess wire / pin length protruding from the back of the PCB.  Anything protruding from the back of the PCB will compromise the amount of space needed by the PCB inside the electronics case.

Be generous with solder on power connections.  Remember that power connections will be transmitting 1 to 2 amperes.

Be careful when you solder the JST XH sockets.  Too much heat or hot solder can melt them and cause them to break.

Finally, place the fuse in the fuse holder.  The fuse holder lid is not necessary.

Once you are done, it should look like this:


I'm not the best at soldering things but, as long as the magic smoke doesn't escape, I'm happy with that.

Test the ESP32 starts on the assembled PCB

Configure a lab bench power supply to produce 24 volts with current limiting at 2 amps, then connect a barrel plug to the supply (double check the polarity!), and finally plug the barrel plug to the PCB's barrel socket.

The ESP32 should come to life (its green LED should flicker) and its logs should be once again wirelessly accessible on ESPHome.

Put everything together in the enclosure

We're going to install everything we've built in the case now, prior to testing that everything works correctly.

Affix the electronics holder of the case to the enclosure

Install the electronics case plate onto the inside part of the front bottom right corner of the enclosure.  You'll note that the electronics holder can only fit in one orientation:

  • It has a round hole that perfectly matches the bottom screw of the enclosure's right door.
  • It has a tall slot that allows the holder to dodge the rivets of the left window of the enclosure.
  • It has a vertical notch in the center of its back wall that fits the zip tie notch of the front left pillar of the enclosure.
  • It has two small round holes on its back wall that mate with holes on the front left pillar of the enclosure.

Key the zip tie notch of the enclosure pillar with the vertical notch of the electronics holder, then press on the center until the zip tie notch goes through the vertical notch.  Ensure all three walls of the electronics holder sit flush with the enclosure and its window.

Note how the round hole lets the door screw through, and the rivets go through the tall slot on the side.

Also note the how the two small round holes mate with the enclosure pillar's holes.  Now use the screws and nuts to secure the holder through these two holes; screw the nut on the inside of the enclosure and the bolt on the outside of the pillar.  You don't need too much force — hand tightening will suffice.

Secure the lighting into the enclosure

If you're a happy customer of Prusa Research and bought their LED strip, just follow the standard mounting instructions.

If, however, you chose to DIY a LED matrix for the ceiling of the printer enclosure, then follow these steps:

  • Remove the adhesive backing from the first LED strip segment (wired to the extension cord for power input).
  • Paste it carefully (adhesive side up) onto the ceiling so it's centered between the left and right walls of the printer enclosure, and roughly 12-15 cm from the front of the printer enclosure towards the back (it should illuminate the closest side of the heatbed when it's roughly one third of the way from the front).
  • Continue the process with the rest of the strips, placing them further back and in parallel to each other.  Avoid any screws or zip tie notches.  Make sure every bit of every segment is properly pasted to the ceiling.
  • Zip-tie the wire (which should be towards the front top left corner of the enclosure) using one of the zip ties provided by Prusa Research with the enclosure.  Zip-tie it to the notch at the front top left corner.
  • With the wire straightened between the strip and the zip tie loop, use Kapton or electrical tape to affix the hanging portion of the wire, so it doesn't exert a vertical force on the LED strip segment attached to it.
  • With the wire running down to the front bottom left corner, zip-tie the wire to that corner as well.

Here are pictures of the process, step by step:

FIXME

Test the buttons of the base board

  • Power off the PCB by disconnecting it from the power supply.
  • Connect the Prusa base board header (which you earlier wired up to a JST 4-pin plug) to the CPSOCKET1 socket on the PCB.
  • Power on the PCB.
  • Navigate to the Web address of the ESP32.  You should see something like this:

From this interface, you should be able to check that pressing the buttons on the base board causes the Camera light switch and Advanced filtration system switch to change from OFF to ON.  Pressing these buttons should also cause the Camera light and Advanced filtration system controls to toggle.

The story is not over yet!

Sadly, I'm missing a few components to make the circuit fully functional.  But don't worry!  Stay tuned to this very blog post for updates as parts arrive and the final circuit comes together.