Adapting an S6 for OctoPrint

In my last post, I managed to get OctoPrint running inside Debian on my Galaxy S6. Everything was running fine, except a few small things keeping the system from being fully controllable from OctoPrint:

1) Can’t restart/shutdown phone from OctoPrint’s web interface
2) Permissions block 3D printer every time it’s reconnected

These issues are caused by a problem with SELinux blocking access to necessary system files from within Debian, so a workaround was needed.
Since the Debian user had write access to /sdcard, it was just a matter of getting Android to react predictably to changes in a file (i.e., shutting down).
That’s when I found these two helpful programs:
Automate, an Android app that can do various tasks when triggered by a particular event
System Command Editor: an OctoPrint plugin to add more buttons to the system drop-down menu.

How it works

When a customized button is clicked in OctoPrint, a value is written to a file on Android that’s accessible to Automate. Automate will then read the file and execute the command associated with the value. This setup opens up the possibility of easily issuing a wide range of commands from the OctoPrint UI.

Setting it up

1) From the OctoPrint UI, go to Settings > Plugin Manager > Get More…
Search for System Command Editor and click Install.

2) Restart OctoPrint for the plugin to take effect. Use the system drop-down menu and click “Restart OctoPrint”

3) After OctoPrint restarts, go to Settings > Server and add the commands below:
-Restart system:

echo '2' > /sdcard/sysmsg.ini

-Shutdown system:

echo '1' > /sdcard/sysmsg.ini

4) Scroll down and click on “System Command Editor” in Settings, and create a new command using the info below.
-Name: Enable Printer

echo '3' > /sdcard/sysmsg.ini

Click “Confirm” and “Save” when you’re done.

4) Download Automate and open it.

5) Set Automate to run after device boots. Open the settings menu and go to “Settings”, then enable “Run on system startup”.

6) To set up a new automation “flow”, either:

  • Import a prebuilt flow
    • Download this file: SysMsg.flo, tap “Import” under the settings drop-down menu, and locate the file. Once you import the flow, tap edit (pencil icon) and then “Flowchart” to make sure the “shell command” block is configured for your printer’s serial port


  • Create your own flow
    • Tap the “+” button and create a flow according to the image below (open in a new tab or download for full resolution)

7) On the flow’s main screen, tap “Start” and grant the permissions it asks to run.

That’s it!
You should now be able to use every button in OctoPrint’s system drop-down, as well as enable your 3D printer once it’s connected without having to manually access your phone.

Leave a Reply

Your email address will not be published. Required fields are marked *