Trick #6: Control a relay / send Linux commands with Printoid

Many users (and not yet users) of Printoid asked me if it’s possible to control a relay with Printoid to switch ON/OFF their 3D printer, or to light ON / light OFF their system.

The answer is purely YES, with PRO and PREMIUM versions.

Indeed, these two versions let you create custom GCODE commands, but the same panel also let you create custom SSH commands to execute any command or script on the OctoPrint’s host machine.

You can control a relay, but in a more general way you can send any command to your host machine (Linux or Windows).

Step 1: Fill the printer profile with your SSH settings


In order to be able to send SSH commands, Printoid needs to know:

  1. The SSH login (if you are using OctoPi or OctoPrint on Raspbian, the login is pi)
  2. The SSH password (the password for this user account)
  3. The port* (optional in LAN, the default port 22 will be used because it is the default SSH port – but this field requests a value in WAN)

* Important: the port value is mandatory if you wanna use the SSH commands over the Internet. This value is not 22 in WAN, and it is not the same public port than the one you have opened to make OctoPrint reachable over the Internet (as indicated in the dedicated tutorial). This time you need to open another port in order to forward another public port (the value of your choice, for example your birthyear+1 is a good value) to the local port 22.

Please note that Printoid will not execute any command on your machine without your consent.

Step 2: Open the custom commands panel from the menu


Simply click on the “Commands” action (with the terminal icon)

Step 3: Create a new command


Simply click on the “+” button at the top.

[EDIT] From Printoid v7.xx, the “+” button is present as the last element of the command list. Click on it to create a new command.

Step 4: Fill the command parameters


  1. Select ‘SSH’ in type.
  2. Give a name to this new command
  3. Enter the command to execute
  4. Choose an icon and a color
  5. Check the box if you wanna add this new command to the main panel.

Please note that, for the “command” field:

  • As you can see, I my own case, I execute a batch script on my Rapsberry (super_light_on). In that case, the most important thing to know is that you SHALL specify the FULL path to the script to be executed, otherwise Printoid will not be able to execute it (the app will not search the script by itself, unless you have exported its path to an environment variable).
  • You can, if you want, execute directly a Linux command. For example, sudo shutdown -r now to reboot the system, or gpio -g mode … to perform an action on a GPIO
  • You can’t retrieve the result of a command, for the moment. For example, you can execute the command ls -al if you want. Printoid wont show anything.

Step 5: Save the new command


If you have check the “show on home” box, you will get a new icon near the axis control arrow to execute your command.



You might also read the tutorial to send custom GCODE commands here.


5 thoughts on “Trick #6: Control a relay / send Linux commands with Printoid

  1. Simply desire to say your article is as surprising. The clarity in your publish is just excellent and that i can suppose you are a professional in this subject. Fine along with your permission allow me to grasp your feed to stay up to date with impending post. Thanks 1,000,000 and please continue the enjoyable work.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s