It is a little bit dangerous to let a 3D printer run unattended. 220 degree at the Hotend, a heated printbed, liquid plastic and in my case cheap electrical parts from china... So I wanted to monitor the print process from everywhere and the possibility to shutdown my both printers ... here is my solution ...

If you have only one printer you can use the second plug socket for lighting as example. This construction is also usable as an IPswitch without octoprint, if you want to switch more plugs, you just need more relay and plug sockets ...

If you do not have any experience with electricity, do not do this instructable, a little mistake can be really dangerous ... If you do this instructable, you do it on your own risk !

Step 1: Requirements:


- Raspberry Pi 2||3

- 4 channel relay modul

- 2 * plug sockets

- rubber connector socket with switch and fuseholder

- raspi cam

- raspi cam cable 1m

- 12V 2.1A switching power supply

- 5V step down converter with micro usb plug

- fan with temperature sensor

- 4A fuse (fast-acting)


- cable (NYM-J 3x1.5mm²) 1m

- cable shoes

- a lot of screws

know how:

- Fusion 360 or every other 3D modeling software

- 3D printing

- how to setup a raspberry

- linux

- basics of bash scripting

- high voltage electricity

Step 2: How I Made the Case:

I used Fusion 360 to design the case. To got an idea how big the case has to be, I downloaded all 3D models which I found:




I created the other models ( rubber connector socket, plug sockets, step down converter, power supply ) very simple by hand. After that I arranged the models several times until I had a compact and accessible inner life of the case. Now I was able to design the case around the parts, there is a distance of 8 mm between the case and the parts for air circulation. I printed the case parts with a wall thickness of 1.2 mm and an infill of 20%(cura settings) ... The side and the top/bottom parts are 3mm thick and they are a little bit flexible, so 4 or 5 mm are a better choise ...

Step 3: Electricity:

High voltage:

I switching both pole, in case of plugs and cable you can never know, which pole has power and which one not, so it is just saver ... I used copper cable with a 1.5 mm2 cross section, not needed in this case, but also saver :-) and the connection to the plug sockets is better ... It is very important to connect through the PE conductor ... I used a 12V power supply, so I have energy for the fan and I can use one of the step down converter with micro usb plug, so it is simple to power the raspberry ...

hints from other users:

from Tinkering On Steroids:

- protect the 220v connectors with shrink tubes or isolation tubes ...

from Chris Rowe :

- seperate the high voltage area from the low voltage area, as example with a middle strut ...

- protect the whole high voltage wires with shrink tubes or isolation tubes ...

I got some hints from other users which has fear that my construction will burn or the relays are not strong enough, so I have to say the following one:

- my first printer has a powersupply with 400W

- my second printer has a powersupply with 250W

- so the max. used power will be 650W

- the max. power of a flexible extension cable with 1.5 mm2 cross section is 3200W

- so my plug/socket construction with non flexible cables should also handle 3200W

- every relay on the relay board can theoretical handle 2500W ( I do not trust them )

- my 4A fuse will acting by ca. 1000W

- so I think there is enough reserve to the upper limit

- and I'm not going to switch my electric kettle with this construction :-)

please do not hesitate to contact me, should you have some hints or suggestions ...

Low voltage:

I power the relay module with 5V from the raspberry, I used 4 free gpio pins from the raspberry, which do not have other functions like I2C, Serial and so on, to prevent serveral effects, like relay flap during the boot process ...

Step 4: Installing and Configuration of 2 Octoprint Instances:

just follow this tutorial to install the first instance:


- start with Basic setup

- Updating & Switching Branches is not really needed

- do Webcam if you want to use one

- do Automatic start up if you want that the server start up during boot process

- I describe System commands in the next step, so you can skip it here

- Make everything accessible on port 80 is usefull, if you want to access your print servers via standart http port, I had an apache already running, so I did another solution, see next steps

to install a second instance, repeat the tutorial with some little changes:

- Basic setup

cd ~
git clone --depth 1 https://github.com/foosel/OctoPrint.git OctoPrint2
cd OctoPrint2
virtualenv venv
./venv/bin/pip install pip --upgrade
./venv/bin/python setup.py install
mkdir ~/.octoprint2

- Webcam

I used one picam for both printer, so nothing to do here

- Automatic start

- rename your ~/OctoPrint2/scripts/octoprint.default to ~/OctoPrint2/scripts/octoprint2.default

- change the content of ~/OctoPrint2/scripts/octoprint2.default to:

# Configuration for /etc/init.d/octoprint2

# The init.d script will only run if this variable non-empty.

# base directory to use

# configuration file to use

# On what port to run daemon, default is 5000

# Path to the OctoPrint executable, you need to set this to match your installation!

# What arguments to pass to octoprint, usually no need to touch this
DAEMON_ARGS="--port=$PORT --config=$CONFIGFILE --basedir=$BASEDIR"

# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user

# Process priority, 0 here will result in a priority 20 process.
# -2 ensures Octoprint has a slight priority over user processes.

# Should we run at startup?

- rename ~/OctoPrint2/scripts/octoprint.ini to ~/OctoPrint2/scripts/octoprint2.ini

- change the "INIT INFO" part of ~/OctoPrint2/scripts/octoprint2.ini to:

# Provides:          octoprint2
# Required-Start:    $local_fs networking
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: OctoPrint2 MyPrinterName daemon
# Description:       Starts the OctoPrint daemon with the user specified in
#                    /etc/default/octoprint2.

- execute the given commands with octoprint2

sudo cp ~/OctoPrint2/scripts/octoprint2.init /etc/init.d/octoprint2
sudo chmod +x /etc/init.d/octoprint2
sudo cp ~/OctoPrint2/scripts/octoprint2.default /etc/default/octoprint2
sudo update-rc.d octoprint2 defaults

do start / stop with:
sudo service octoprint2 {start|stop|restart}

after you start both daemons, you should able to access both print servers via:



- please go on both through the initial configuration

- it is helpfull if you use differnet colors for every print server

- configure one printer per print server

Step 5: Turn On, Turn Off Your Printers ...

I created 3 scripts in ~/.octoprint/scripts :



# pins of socket 1
gpio -g mode 18 out
gpio -g mode 27 out

gpio -g write 18 0
gpio -g write 27 0



# pins of socket 1
gpio -g mode 18 out
gpio -g mode 27 out

gpio -g write 18 1
gpio -g write 27 1



if [[ $(date +%u) -gt 5 ]]
  # at the weekend
  if [[ $(date +%-H) -ge 7 ]] && [[ $(date +%-H) -le 21 ]]
    # do nothing during 7:00 til 21:59 o^clock
    exit 0
  # during the week
  if [[ $(date +%-H) -ge 16 ]] && [[ $(date +%-H) -le 21 ]]
    # do nothing during 16:00 til 21:59 o^clock
    exit 0

# wait 10 minutes, so that the printer can cooldown ...
sleep 600

# pins of socket 1
gpio -g mode 18 out
gpio -g mode 27 out

gpio -g write 18 1
gpio -g write 27 1

- i added execution rights to this files "chmod 750 *.sh"

- after that I added the following lines to ~/.octoprint/config.yaml :

  - action: enable_socket1
    command: ~/.octoprint/scripts/enable_socket1.sh
    name: Enable AnetA8
  - action: disable_socket1
    command: ~/.octoprint/scripts/disable_socket1.sh
    confirm: You are about to disable printer AnetA8!
    name: Disable AnetA8
  enabled: True
  - event: PrintDone
    command: ~/.octoprint/scripts/disable_socket1_after_time.sh
    type: system

The first block "system" is to add 2 commands(enable/disable socket1) to the webgui, the second block "events" starts the script disable_socket1_after_time.sh after every finished print, but the script itself disable the printer only during the night and my worktime ...

I did the same equivalent for ~/.octoprint2 with the pins of plug socket 2 and restarted both octoprint daemons:

service octoprint restart
service octoprint2 restart

or you can use a plugin:

I got the information from "vitormhenrique" that he created a plugin for octoprint to switch gpio pins via octoprint web interface ...



I didn't test it, yet ...

Step 6: One Website for Both Daemons

this step depends on your own network configuration, so I can only show my way:

I added 2 additional IP adresses to my raspberry pi network interface


I added 2 additional dns aliases to my router config which points to the additional ip addresses:



I added 2 virtualhost configurations to my existing apache config:

<VirtualHost aneta8.fritz.box:80>
        ServerAdmin webmaster@localhost
        ServerName aneta8.fritz.box

        ErrorLog ${APACHE_LOG_DIR}/aneta8_error.log
        CustomLog ${APACHE_LOG_DIR}/aneta8_access.log combined

        ProxyPreserveHost On
        ProxyRequests On

        ProxyPass /video
        ProxyPassReverse /video

        ProxyPass /
        ProxyPassReverse /

<VirtualHost daycom.fritz.box:80>
        ServerAdmin webmaster@localhost
        ServerName daycom.fritz.box

        ErrorLog ${APACHE_LOG_DIR}/daycom_error.log
        CustomLog ${APACHE_LOG_DIR}/daycom_access.log combined

        ProxyPreserveHost On
        ProxyRequests On

        ProxyPass /video
        ProxyPassReverse /video

        ProxyPass /
        ProxyPassReverse /

so I am able to access my both printer directly ...

Step 7: At Last:

Maybe I am going to add some pushbutton to the box, to switch the plug socket directly on the printer station, a status display, some sensors which monitor the temperature around the printers or the power consumption is also possible.

If you like this tutorial, please vote for me, thanks ...

<p>Nice work! I was wondering the same thing. I wish my power supply of my Wanhao i3 Plus had a simple I/O to turn it off like all computer ATX power supply.</p>
<p>There is nothing I love more than neat wiring, reminds me of the 3d pipes screensaver :)</p>
<p>I have a plugin for OCTOPI that allow you to use RPI GPIO using the web interface.</p><p>It's also capable of turning on / off pins when the print is started or complete, you can also add delays for those events.</p><p>https://github.com/vitormhenrique/OctoPrint-Enclosure</p>
<p>I added this info to the related step ...</p>
<p>Do you have a link for the * sockets?</p>
<p>you should use stuff which match with your country electricity stuff ...</p><p><a href="https://www.amazon.de/gp/product/B0014DTBQQ/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1">https://www.amazon.de/gp/product/B0014DTBQQ/ref=oh...</a></p><p><a href="https://www.amazon.de/gp/product/B005G3QGOU/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1">https://www.amazon.de/gp/product/B005G3QGOU/ref=oh...</a></p>

About This Instructable




Bio: I'm working as Technical Solution Manager (whatever this means) for a big IT company in germany, next to my job I'm teaching our ... More »
More by TK92648926:Dual 3D OctoPrint Server With Powerswitch The Suit (programmable, interactive) Perfect calibration of cheap 3D printers ... 
Add instructable to: