Home Automation: Smart Relay Control for Your 3D Printer Enclosure
by Caelestis Workshop in Circuits > Remote Control
1788 Views, 13 Favorites, 0 Comments
Home Automation: Smart Relay Control for Your 3D Printer Enclosure
Welcome! In this Instructable we will build a powerful and easy to use relay control system to simplify and automate your 3D printing setup. By the end of this Instructable, you'll have optimized your printing workflow. The total cost for this project is between $100-$150, depending on what parts you already have.
Purpose and Features
The relay control box acts as the central hub for managing the functions of your 3D printing enclosure. Using relay switches and a Raspberry Pi 4B+ gives you full control over your 3d printer and connected peripherals:
- 3D Printer: Turn on and off your 3d printer remotely.
- Enclosure Lighting: Turn on and off your enclosure lights.
- Ventilation System: Turn on and off ventilations inside youre enclosure.
- Scalability: There are possibilities for expansion for peripherals you might want to add later.
Why is there a need to build a Relay Control Box?
By following this Instructable, you will enhance your 3D printing environment and get practical experience in electronics and automation. This project allows you to customize your setup to meet your specific needs, offering:
- Automation: Optimize your 3D printing environment and reduce the complexity of the tasks you perform.
- Convenience: This means that one can control several devices with just a single interface.
- Scalability: It is very easy to add more devices to the system as your needs are growing.
Safety First
Safety is a very important aspect that should not be compromised when undertaking this project. Electrical components entail certain dangers, which include electric shocks and fire risks when handling electrical parts. It is always advisable to unplug the power supply from the outlet before attempting to work with it. Ensure all connections are made correctly before applying power to the system.
Disclaimer
This project involves working with electrical components and power supplies, which can be dangerous if not handled properly. Follow all safety precautions and double-check your work. I am not responsible for any damage, injury, or loss resulting from following this guide. Proceed at your own risk and always prioritize safety.
This Instructables will give a step by step guide on how to construct your relay control box, from the physical casing of the device, to the wiring and programming of the software. Below are the procedures that you need to follow in order to develop a useful tool for helping you in your 3D printing process.
Supplies
Materials List
Below is a list of parts needed, including links for purchase.
- 3D Printable Relay Control Box - 1 set (Custom designed to house the relay modules, power supply, and additional components)
- Mean Well LRS-100-12 12VDC, 8.5A, 102W Power Supply - Provides reliable power to your peripherals and relays
- Raspberry Pi 4B+ (8 GB RAM) - Controls the relay modules and runs OctoPrint
- Freenove Breakout Board for Raspberry Pi - Simplifies connections to the Raspberry Pi GPIO pins
- 4-Way Relay Module Board (5V) - Controls multiple external devices such as lights and ventilation systems
- 1-Way Relay Module Board (5V) - Dedicated to switching the 3D printer on and off
- Four pairs of 5.5x2.1mm DC jack female and male plugs - Facilitate power connections to external devices, including lights and fans
- 140mm Fan - For cooling the Raspberry Pi, relays and power supply. Any fan will do, but i used the Noctua Redux because of its silent operation
- 26 AWG red silicone wire - For power connections
- 26 AWG black silicone wire - For ground connections
- 5-meter 8-pin ribbon cable - For Dupont connections
- Male DuPont connectors - For the ribbon cable connections
- Pin Housing - For the ribbon cable connections
- M3 brass inserts - To be pressed into the housing for secure fastening
- 5x20mm glass fuse holder - For circuit protection
- 8A Fuse - For circuit protection
- Crimp connectors - For safe connections
- Heat shrink tubing - For insulating connections
- Nylon Cable Ties - For organizing wires
- Screws - Various M3 screws used for mounting components
- 8mm Self-tapping screws - For mounting the fan
Tools Required
You will also need the following tools to assemble and modify the relay control box:
- Soldering Iron: For making secure electrical connections.
- Wire Strippers: Essential for preparing wires.
- Dupont crimping pliers - For securing connectors to cables
- Screwdrivers: Needed for assembling and disassembling the components.
- Multimeter: For testing voltages and ensuring connections are correct.
- Pliers: Useful for bending wires and handling small components.
- 3D Printer: For printing the custom relay control box.
3D Print the Relay Control Box
Begin by 3D printing the body and lid to house and support the relay modules, power supply, raspberry and other components.
Download the 3D printable files for the relay control box from my Printables page.
Print Settings
I recommend using a 0.4mm nozzle diameter, providing a good balance between print speed and detail. Set the layer height to 0.2mm; although 0.3mm is also viable. The recommended material is PETG due to strenght and temperature resistance.
You will need to insert M3 brass inserts into the printed parts. These can be melted into the holes using a soldering iron or a wood burner tool.
Printing Tips
It is also advisable to ensure that your print bed is clean and well leveled to reduce the chances of warping. Make changes to your print speed and temperature depending on your printer’s capabilities and the manufacturer’s guidelines for the PETG filament.
Mounting the Components
In this step, we will install the components to the 3D-printed case. Make sure you have all the screws and brass inserts needed for a strong and firm attachment.
Inserting M3 Brass Inserts: Begin by melting M3 brass inserts into the eleven holes as described in the following picture.
Install the Relay Modules: Fasten the relays to the box using M3 flathead "PC Screws".
Installing the Power Supply: Use three screws to fasten the power supply into the box. Ensure that the power supply is properly fastened to prevent any movement and future loose connections.
Installing Connectors and Fuse Holder: Slide the C19 socket, the fuse holder, and the four female jack plugs into the corresponding holes in the box. Verify that each part is securely fastened to avoid movement and bad connections.
Preparing the Raspberry Pi: Attach the Freenove breakout board to the Raspberry Pi. The Freenove breakout board makes it easier to connect and use GPIO pins. I did not use the bottom screws.
Installing the Raspberry Pi: Press the Raspberry Pi into the box. The Pi does not need to be fastened with screws as the tension will keep it in place.
Ready for Circuit Assembly: The box is now prepared for the circuit assembly with all of the parts installed and ready. To begin wiring the components, move on to the next step.
Circuit Assembly
To complete the circuit assembly, we'll connect all of the parts. Refer to the photographs for guidance and follow the instructions.
Wiring the C19 Socket: Connect the C19 socket's ground wire directly to the ground on the power supply. Attach the brown to (L) on the socket and then to one of the fuse holder's pins, and then connect the second pin of the fuse holder to the power supply's L. Lastly, directly attach the N on the socket (blue) to the N on the power supply.
Preparing the 8P Ribbon Cable:
Prepare about 5 centimeters of the 8P ribbon cable. Split the wires, crimp male Dupont pins on each wire, and put on the Dupont plastic casings. Do this on both ends of the ribbon cable.
Connecting the Ribbon Cable: Attach the ribbon cable to the following pins:
Red from 5V on Raspberry Pi, and DC+ on the 4-way relay module.
Black from GND on Raspberry Pi, and DC- on the 4-way relay module.
Brown from Raspberry Pi's GPIO 15 and IN1 on the 4-way relay module.
White from GPIO 18 on Raspberry Pi, and IN2 on the 4-way relay module.
Grey from Raspberry Pi's GPIO 23 and IN3 on the 4-way relay module.
Purple from Raspberry Pi's GPIO 24 and IN4 on the 4-way relay module.
Wiring the Single Relay Module: Use an 8P ribbon cable and separate only the black, red, and brown wires. Crimp them with Dupont male connectors and wire the following:
Red to 5V on Raspberry Pi and DC+ on the single relay module
Black to GND on Raspberry Pi and DC- on the single relay module
Brown to GPIO 8 on Raspberry Pi and IN1 on the single relay module ( I later changed this from GPIO 14 to GPIO 8)
Connecting the 4-Way Relay Module COM to Power Supply: Crimp the red silicone wires with male Dupont connectors on both ends, then connect each COM on the 4-way relay module to the power supply's +V.
Wiring the Negative Pins of the Female Jack Plugs: Cut four long black silicone wires and crimp them with uninsulated connectors. Insulate the uninsulated connectors with heat shrink tubing. Connect each black wire to the long (negative) pins of the female jack plug sockets. Use nylon strips to keep the four black wires together and place them underneath all of the other cables that lead to the power supply.
Attach Spade Connector: Crimp all the black wires to a single spade connector.
Attaching Spade Connector to Power Supply: Attach the spade connector to the -V on the power supply.
Wiring the Positive Pins of the Female Jack Plugs: Cut four long red silicone wires and crimp them with uninsulated connectors. Insulate the uninsulated connectors with heat shrink tubing. Connect each red wire to the short (positive) pin of the female jack plug sockets. Use nylon strips to keep the four red wires together and place them underneath all of the other cables that lead to the power supply.
Connecting Red Wires to 4-Way Relay Module: Crimp each of the red wires with a male Dupont connector and connect each of them to one of the NO terminals on each of the four relays on the 4-way relay module. Use a multimeter to test which wire leads to which female jack socket to connect the first jack socket to relay number one, the second to relay number two, and so on.
Preparing the C19 Cable for the 3D Printer Power Supply: Take the C19 cable that connects the 3D printer power supply to the wall socket. Unplug it and remove some insulation from the center to reveal the ground, L, and N wires. Cut the L (brown) wire and crimp on connectors.
Connecting the C19 Cable to the Single Relay Module: Attach the L (brown) wire connectors to COM and NO on the single relay module.
This completes the wiring. In the following stage, we'll attach the fan and close the box.
Enclosing the Control Box
In this step, we'll attach the fan to the lid and secure it to the box. Follow the instructions and use the photos for help.
Attaching the Fan: Start by attaching a 140mm fan onto the lid with self-threading screws made for fans.
Cutting the Fan Wires: Cut off around 5-7 centimeters of the power cable from the fan to make it fit inside the box.
Crimping the Fan Wires: Attach male Dupont's to the fan's black and red wires.
Connecting the Fan to the Power Supply: Connect the red wire to +V and the black wire to -V on the power supply.
Securing the Lid: Fasten the lid to the control box with three M3 countersunk PC screws. To prevent movement, make sure that the screws are tight.
This concludes the step. In the next step, In the following step, I will demonstrate how to wire peripherals with jack plugs.
Connecting Peripherals
In this step, we will wire peripherals such as fans and lights to the control box.
Soldering the Jack Plug: Soldering on a jack plug makes wiring and powering peripherals simple. Positive wire goes to the short pin (+) and to the negative wire goes to the long pin (-). After soldering, screw the housing back on to close the plug.
Connecting to the Control Box: After the jack plugs are ready, insert them into the control box's female DC sockets.
The peripheral wiring is now complete. Before mounting the relay control box, we will first configure the control inside of OctoPrint and make sure it functions.
Configuring OctoPrint and Testing Relays
To control the relays, we will install and set up OctoPrint's Enclosure Plugin in this step. Refer to the photos for help and follow the instructions.
Install OctoPrint: To install OctoPrint on your Raspberry Pi 4B+, if you haven't previously, follow the official installation instructions. Verify that OctoPrint and your 3D printer are operating correctly.
Access the Plugin Repository: Open the web interface for OctoPrint and log in. Click the wrench-shaped Settings button, then choose Plugin Manager. To access the official plugin repository, click Get More.
Install the Enclosure Plugin: Look up "Enclosure Plugin" in the plugin repository. To finish the installation, click the Install button. Reboot OctoPrint after installation.
Configure the Plugin: After installation, go back to the Settings page and find the plugin settings. Map each relay to its corresponding GPIO pin on the Raspberry Pi. Set up appropriate labels for each controlled device (e.g., Printer, Enclosure Light, Ventilation). Adjust any other settings such as automatic shutdown timers or specific triggering behaviors if needed.
Since we used GPIO 8, 15, 18, 23, and 24, use the following pin numbers in the Enclosure Plugin:
- GPIO 14 = Pin 24
- GPIO 15 = Pin 10
- GPIO 18 = Pin 12
- GPIO 23 = Pin 16
- GPIO 24 = Pin 18
Test the Relay Switching: With the relays properly configured, toggle each device from the OctoPrint web interface to verify that everything is working. Observe whether the relay switches control their respective devices, such as the 3D printer, lights, and ventilation.
This concludes the configuration and testing of the relays. If all works well it is now time for mounting the control box.
Mount the Relay Control Box
In this step, we will install the finished relay control box and complete the project.
Mounting the Relay Control Box: I placed the finished relay control box beneath the table, near my printer enclosure. You can install it wherever you see fit in your configuration.
Congratulations on successfully creating your own relay control box for your 3D printer enclosure. You've completed this Instructable to make a fully functional device! Take a minute to acknowledge your efforts on this project. Not only did you create something practical and useful, but you also learned new skills that you can use in future projects.
Don’t forget to share your creation.
Thank You
Thank you for following along with this guide. I hope it was informative and inspiring. Keep building, experimenting, and pushing the boundaries of what you can create!
Credit
Credit to Quantenquark for inspiring this build with his Printables model "Power supply for my 3D printing enclosure".