Android phone as octoprint server

I was also trying to install your app on another 2 devices (both rooted) but in both cases I got error - app stopped working after I hit install Octoprint button in the app.

I have a tx6 android tv box with real USB ports. I installed everything and tried connecting to the printer (lk4pro) but I see no printer
Where do I find it? Under /dev/what ?
Termux-usb -l shows no devices

Hey @Filip,

I built the app on my laptop and have installed it on an old phone. It starts the octoserver, it sees the connected printer, but octoprint doesn't see the serial port. I think it is a rights issue, could it be that the child process doesn't get the permission to access the serial devices ?

I'm investigating the issue right now, looks like it broke with some octoprint update. I'll try to upload the fix this week

Hi, I want to use my Android phone as print-server too, but sadly @Filip 's .apk crashed while installing octoprint. My phone in question is an ancient Galaxy S2 (almost 10 years old by now...), but it still gets unofficial LinageOS updates. Thing is the kernel doesn't supply a driver for /dev/ttyACM* devices, and I'm to lazy to recompile it. But thanks to a couple helpful pointers in here I came up with another solution:

I made an Octoprint plugin that uses termux-usb and libusb to talk to CDC-ACM usb-serial devices. I tested this on my Galaxy S2 with LineageOS 17.1 (=Android 10) and an Ender 3 with a SKR-Mini E3 board. It is a bit flaky, also when while printing the printer stutters because something is still not fast enough, and also after like a minute of printing the phone crashes :joy: But it works up to that point :partying_face:

If you want to try it, see code and basic instructions here:

It's not exactly elegant, because it seems like you can only get the file descriptor for the usb device by running termux-usb -r -e /dev/bus/usb/001/011. So this Plugin opens a subprocess that starts the so called "cdcDaemon" with termux-usb. That Daemon uses the usb-fd to talk to the printer. The Daemon and Octoprint in turn are talking through two sockets (one for each direction).


Fixed a couple bugs and remembered I had a HTC 10 laying around as well -> Got my first smooth print off of an Android phone! :rocket: :grin:

This method should work with most devices as it neither needs root nor the dcd-acm driver in the kernel enabled.

1 Like

This is awesome! I think this is a very big deal. I have a new printer coming in and I'm going to set this up and report back.

Hey, @schuhumi

Trying to use the plugin in non rooted Honor 9. Almost there:

~ $ termux-usb -r /dev/bus/usb/001/002
Access granted.

Octoprint sees the port, but connections with 250000 baud rate failsl. 250000 is default for my printer, and I could communicate with it using other serial port connection apps. But here it fails:

2021-01-11 12:42:08,479 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port /dev/bus/usb/001/002, baudrate 250000 from hook Termux_CDC_ACM: timeout: 'timed out' @
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/octoprint/util/", line 3666, in _open_serial
    serial_obj = factory(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/octoprint/util/", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/data/data/com.termux/files/home/.octoprint/plugins/Termux_CDC_ACM/", line 95, in serial_printer_factory
    serial_obj = serial_printer(
  File "/data/data/com.termux/files/home/.octoprint/plugins/Termux_CDC_ACM/", line 38, in __init__
    self.OOPIconn = self.OOPIlistener.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/multiprocessing/", line 468, in accept
    c = self._listener.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/multiprocessing/", line 614, in accept
    s, self._last_accepted = self._socket.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/", line 293, in accept
    fd, addr = self._accept()
socket.timeout: timed out

What could cause this?

After a reboot and a fresh restart I saw a hint. Looks like serialDaemon gets None from libusb1.get_backend(), and socket fails to start, that leads to problem in previous Traceback.

It appears libusb can not work in my setup, backend can not be initialized:

~/.../plugins/Termux_CDC_ACM $ export PYUSB_DEBUG=debug
~/.../plugins/Termux_CDC_ACM $ python
Python 3.9.1 (default, Jan  8 2021, 21:18:33)
[Clang 9.0.8 ( 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import usb
>>> usb.core.find()
2021-01-12 00:45:49,299 DEBUG:usb.backend.libusb1:_LibUSB.__init__(<CDLL '', handle 8f400b6fe1046d6f at 0x707bc5abb0>)
2021-01-12 00:45:49,302 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/backend/", line 964, in get_backend
    _lib_object = _LibUSB(_lib)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/", line 62, in do_trace
    return f(*args, **named_args)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/backend/", line 717, in __init__
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/backend/", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
2021-01-12 00:45:49,307 DEBUG:usb.backend.libusb1:_LibUSB._finalize_object()
2021-01-12 00:45:49,737 ERROR:usb.libloader:'OpenUSB library' could not be found
2021-01-12 00:45:49,738 ERROR:usb.backend.openusb:Error loading OpenUSB backend
2021-01-12 00:45:50,984 ERROR:usb.libloader:'Libusb 0' could not be found
2021-01-12 00:45:50,985 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/", line 1297, in find
    raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available

Somehow libusb_init fails with Input/Output Error. export LIBUSB_DEBUG=1 outputs libusb: error [sysfs_get_device_list] opendir devices failed, errno=13 which means that opendir('/sys/bus/usb/devices') fails with access denied.

Really strange, because "Serial USB Terminal" app works ok and outputs printer serial port initialization messages. Probably some kind of Termux environment issue. Out of ideas, right now.

I just wanted to say that this is amazing! Not only is it super cool to be able to control my 3D printer from an old phone, but the installation process is also so much easier than on Windows (at least for me).

Thank you so much.
Samsung Galaxy J7 Duo and Anycubic Mega X.

On a fresh install i get my printer to connect by setting this serial port manualy in settings/serial connections/additional serial port (/dev/bus/usb/001/002). Wehn connecting set the port from auto detect to /dev/ttySAC0.

I taped my 5v pin. (Worked without it but just to be safe). Then booted the Printer.(Ender 3 Pro 4.2.2 board with marlin 2.0.x) pluged in the usb cable into the printer as first and into the Phone as last(Samsung Galaxy S9+ with one ui 2.5) via the original OTG connecter provided with the Phone. The connection is stable but if not done in the proper order it won't connect even if repeated properly.
When it won't connect anymore deleting the cache of the Octoprint on Android app seems to solve the problem.

I managed to root my phone and got Termux_CDC_ACM working under root, but for Anycubic S3 Mega it says serialDaemon:: Error: Couldn't find matching driver for usb device hex(dev.idVendor)='0x10c4', hex(dev.idProduct)='0xea60' !

Looks like your Mega X uses chipset similar to one on S3 Mega, and if it works for you, it should work for me. What it your working setup for Anycubic Mega X?

Maybe it's because my phone wasn't rooted. I just installed the .apk as it was and everything worked out of the box.
I'm running an Android version from around february 2020.