Auto Shutdown Printer after print finished


I am new to Linux but have some background in web programming and a little in C++. I have managed to fumble my way through setting up my printer and Pi to a PC power supply where the Pi is running on the standby circuit and I can turn on and off the printer with the system menu using the command "gpio # write 1/0" and all is working great. However now I would like the printer to shutdown after a set time after printing completion. I don't want the Pi to shutdown so I don't think the plugin will be what I am looking for. I don't know where to go from where I am at. Basically I need to know where I would edit (which file and location) and how to program a time lapsed command of "gpio # write 0"


If it were me, I think I'd write a Python script, put it in the ~/scripts folder, mark it executable with chmod a+x scriptname.

Then I'd use the Gcode Systems Command plugin to connect that with a pseudo gcode like 900. Finally, I'd call OCTO900 at the end of the appropriate OctoPrint -> Settings -> Gcode Scripts section for end-of-job.

As for a delay, you probably would want the Python script to delay...

import time
import RPi.GPIO as GPIO
GPIO.setup(25, GPIO.OUT, initial=GPIO.LOW)
GPIO.output(25, GPIO.HIGH)


Ok so I am slowly piecing together in my head what you just said lol. I don't know what Python is at all, I think I can sorta make sense of the next thing. If I'm not mistaken that is a plugin to OctoPrint that will allow me to make custom commands in the gcode? I will see if I can figure out how to do that. as far as the script part I is that going in the same file you told me to create initially? and I don't know what you mean by marking it executable with chmod a+x. Sorry I am very new to the Raspberry Pi.


Hi Impact,

I had a similar issue with trying to run a system command. I just wanted it to be in the control tab instead of the System pull-down. The Gcode Systems Command plugin is great for that. You can add it into any gcode that you send to Octoprint, i believe also within Octoprint is somewhere that you can specify some gcode to be before or after every print.

Linux and most other Unix style OSes use a permissions system that allows files, folders, devices etc to be set to be allowed to read, written and or used by specific users, groups or others. chmod is the cli command to change permissions where x stands for executable. A quick google will do the trick or have a look here: File Permissions.

As for the script, you don't need python, a simple shell script will do fine:

sleep 60
/usr/local/bin/gpio write [pin] [1/0]

I guess you are using wiringpi to set the gpio ? Well the above is for that. You just need to know the pin and if its 0 or 1 you want.

Have FuN!
Jan P.

PS: I forgot to mention, IDK where your gpio binary is, I compile it from source but if you use it from a package it might be else where, to find out issue

which gpio

That will give you the full path, also just to mention, sleep 60 will delay the following commands by 60 seconds. Set that to what ever delay you want after the printer finishes. You can write another little script that will switch your printer on and implement that for each print start.


Have you tried this plugin? PSU Control You said you think "the plugin" isn't what you're looking for, but not what "the plugin" you aren't looking for was called. PSU Control won't shut down the pi, it just turns off a power supply, and I think it has the ability to work via GPIO (though I'm not 100% sure on that).