[How To] KlipperScreen on Android Smart Phones

Hey @jhs, thanks a lot for the procedure.
I’m a noob, i warn.
I’m currently stucking at the step 7 and on several points:
1 - i don’t know which app you used but on mine i don’t the same interface
2 - i do not succeed to launch xeyes
in winscp
3 - i have found the Klipperscreen.service but not in systemd folder
4- i don’t find the file Launch_klipperscreen.sh in KlipperScreen
I will try to reboot my old android tablet and wipe all datas in order to start on something clean.
If you have any ideas…

Hey @jhs,

Thankyou so much for this detailed step by step tutorial. It worked like a charm!
I’m using a rpi zero 2 w, which is connected through adb with a dji drone controller cable.

I would like to be able to run Klipperscreen automatically on the rpi startup, how do I do that?
If I want it to work I have to do this:

adb forward tcp:6100 tcp:6000
cd ~/KlipperScreen
DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py

Is it possible to run this on startup?
Also, would it be possible for klipper to recognize when I reconnect my device?

To answer myself.

You can run KlipperScreen on startup, by doing this:

  1. Go to the rc.local file (everything in this file runs on boot):
    sudo nano /etc/rc.local
  2. Put this code at the bottom:
    adb forward tcp:6100 tcp:6000 && cd /home/pi/KlipperScreen && DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py &
  3. Press ctrl+x, then y, then enter
  4. Reboot
    sudo reboot

voilà

1 Like

Reply to me
i have follow this step by step guide in paralell of yours and it works well now
https://www.angelrojasjr.com/2021/10/30/using-an-android-device-with-klipperscreen/
Thanks

2 Likes

Thanks man!!

Finally got work in boot… :smiling_face_with_three_hearts:

1 Like

Thank you for mentioning this great tutorial here. I couldn’t have done it better and therefore there is no use in copying this great work.
Nevertheless I will try to help anyone who has still trouble.

Where did you change this setting?! In XSDL server? If so, how?! I am struggling with this right now, I have the UI up and I have the xeyes but its doing weird things when I touch as if there is a mouse I cant see.

I hope I’m not out of line for responding to this post so far out… But where do you access Device Configuration for XSDL Server? I have the UI up and xeyes is there, its acting as if there is a mouse cursor somewhere that I cant see. So I want to attempt this step to see if it fixes it, however I see no way of accessing configurations for XSDL server.

Just start xsdl on your phone directly. I think you have a few seconds to enter configuration before the blue screen with connection information is displayed.
I do not have access to xsdl right now but this is what I remember.

1 Like

BOOM!! Thank you so much… works like a dream :slight_smile:

I got work by WiFi, because my phone only works in charger…
Modified rc.local.

From:
adb forward tcp:6100 tcp:6000 && cd /home/pi/KlipperScreen && DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py &

To:
cd /home/pi/KlipperScreen && DISPLAY=192.168.100.25:0 /home/pi/.KlipperScreen-env/bin/python screen.py &

Thanks for everyone!

2 Likes

Thanks a lot! I actually prefer to run it this way.

Hi, i have a weird “error”. Fresh install of mainsailos, KlipperScreen, InputShaper. Attached to the pi is a old Google Nexus 4 over USB. KlipperScreen shows up after booting the pi and everything works, i can home the printer, start prints etc. but after approx an hour xsdl shows the “blue screen of death” ^^ on the phone display with the info about port forwarding. Happens no matter if i am printing oder everything is idle.

Is there anything i can do to prevent this?

From the x0rg.log it seems there is no display attached. But it is and it works for a certain amount of time.

X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
[  1124.626] Build Operating System: Linux 5.4.0-72-generic armv8l Raspbian
[  1124.626] Current Operating System: Linux sx1 5.10.63-v7l+ #1496 SMP Wed Dec 1 15:58:56 GMT 2021 armv7l
[  1124.626] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1  smsc95xx.macaddr=E4:5F:01:34:59:D3 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=tty1 root=PARTUUID=8e3a2468-02 rootfstype=ext4 fsck.repair=yes rootwait
[  1124.627] Build Date: 04 January 2022  10:05:34AM
[  1124.627] xorg-server 2:1.20.4-1+rpt4+deb10u4 (https://www.debian.org/support) 
[  1124.627] Current version of pixman: 0.36.0
[  1124.627] 	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
[  1124.627] Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  1124.627] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Feb 11 22:45:03 2022
[  1124.628] (==) Using config directory: "/etc/X11/xorg.conf.d"
[  1124.628] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  1124.629] (==) ServerLayout "ServerLayout0"
[  1124.629] (==) No screen section available. Using defaults.
[  1124.629] (**) |-->Screen "Default Screen Section" (0)
[  1124.629] (**) |   |-->Monitor "<default monitor>"
[  1124.630] (==) No device specified for screen "Default Screen Section".
	Using the first device section listed.
[  1124.630] (**) |   |-->Device "Allwinner A10/A13 FBDEV"
[  1124.630] (==) No monitor specified for screen "Default Screen Section".
	Using a default monitor configuration.
[  1124.630] (**) Option "BlankTime" "0"
[  1124.630] (**) Option "StandbyTime" "0"
[  1124.630] (**) Option "SuspendTime" "0"
[  1124.630] (**) Option "OffTime" "0"
[  1124.630] (==) Automatically adding devices
[  1124.630] (==) Automatically enabling devices
[  1124.630] (==) Automatically adding GPU devices
[  1124.630] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  1124.631] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (WW) The directory "/usr/share/fonts/X11/Type1" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
[  1124.631] 	Entry deleted from font path.
[  1124.631] (==) FontPath set to:
	/usr/share/fonts/X11/misc,
	built-ins
[  1124.631] (==) ModulePath set to "/usr/lib/xorg/modules"
[  1124.631] (**) Extension "DPMS" is disabled
[  1124.631] (II) The server relies on udev to provide the list of input devices.
	If no devices become available, reconfigure udev or disable AutoAddDevices.
[  1124.631] (II) Loader magic: 0x1fdf80
[  1124.631] (II) Module ABI versions:
[  1124.631] 	X.Org ANSI C Emulation: 0.4
[  1124.631] 	X.Org Video Driver: 24.0
[  1124.631] 	X.Org XInput driver : 24.1
[  1124.631] 	X.Org Server Extension : 10.0
[  1124.633] (--) using VT number 2

[  1124.634] (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration
[  1124.635] (II) xfree86: Adding drm device (/dev/dri/card1)
[  1124.636] (II) xfree86: Adding drm device (/dev/dri/card0)
[  1124.638] (II) no primary bus or device found
[  1124.638] 	falling back to /sys/devices/platform/gpu/drm/card1
[  1124.638] (II) LoadModule: "glx"
[  1124.638] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[  1124.642] (II) Module glx: vendor="X.Org Foundation"
[  1124.642] 	compiled for 1.20.4, module version = 1.0.0
[  1124.642] 	ABI class: X.Org Server Extension, version 10.0
[  1124.642] (II) LoadModule: "fbturbo"
[  1124.642] (II) Loading /usr/lib/xorg/modules/drivers/fbturbo_drv.so
[  1124.643] (II) Module fbturbo: vendor="X.Org Foundation"
[  1124.643] 	compiled for 1.20.3, module version = 0.5.1
[  1124.643] 	Module class: X.Org Video Driver
[  1124.643] 	ABI class: X.Org Video Driver, version 24.0
[  1124.643] (II) FBTURBO: driver for framebuffer: fbturbo
[  1124.643] (WW) Falling back to old probe method for fbturbo
[  1124.643] (II) Loading sub module "fbdevhw"
[  1124.643] (II) LoadModule: "fbdevhw"
[  1124.644] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  1124.644] (II) Module fbdevhw: vendor="X.Org Foundation"
[  1124.644] 	compiled for 1.20.4, module version = 0.0.2
[  1124.644] 	ABI class: X.Org Video Driver, version 24.0
[  1124.644] (EE) open /dev/fb0: No such file or directory
[  1124.644] (WW) Falling back to old probe method for fbturbo
[  1124.644] (II) Loading sub module "fbdevhw"
[  1124.644] (II) LoadModule: "fbdevhw"
[  1124.645] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  1124.645] (II) Module fbdevhw: vendor="X.Org Foundation"
[  1124.645] 	compiled for 1.20.4, module version = 0.0.2
[  1124.645] 	ABI class: X.Org Video Driver, version 24.0
[  1124.645] (EE) open /dev/fb0: No such file or directory
[  1124.645] (EE) No devices detected.
[  1124.645] (EE) 
Fatal server error:
[  1124.645] (EE) no screens found(EE) 
[  1124.645] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[  1124.645] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[  1124.645] (EE) 
[  1124.648] (EE) Server terminated with error (1). Closing log file.

The journalctl -xe -u KlipperScreen has this output (and again, after booting the pi klipperscreen starts on the Nexus Display, and the files are in the directorys)

Feb 12 14:01:09 sx1 systemd[29712]: KlipperScreen.service: Failed to execute command: No such file or directory
Feb 12 14:01:09 sx1 systemd[29712]: KlipperScreen.service: Failed at step EXEC spawning /home/pi/KlipperScreen/launch_klipperscreen.sh: No such file or directory
-- Subject: Process /home/pi/KlipperScreen/launch_klipperscreen.sh could not be executed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The process /home/pi/KlipperScreen/launch_klipperscreen.sh could not be executed and failed.
--
-- The error number returned by this process is ERRNO.
Feb 12 14:01:09 sx1 systemd[1]: KlipperScreen.service: Main process exited, code=exited, status=203/EXEC
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStart= process belonging to unit KlipperScreen.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 203.
Feb 12 14:01:09 sx1 systemd[1]: KlipperScreen.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit KlipperScreen.service has entered the 'failed' state with result 'exit-code'.

Hi there,
New to klipper screen…
I am trying to get my old Samsung S6 to work as a screen.
I went through the step by step, I did get the eyes on the S6 but when I start XServer XSDL on the phone and connect the USB to the pi4 that is running klipper, I get part of the klipper screen UI but the upper right section gets stuck on “connecting to server”.
I though maybe that my USB cable was power only so I tried with one I know does data too but same result.

Any idea what I could be missing?

I also find the adb procedure complex and unneeded.

I installed KlipperScreen using KIAUH and “as of now” (because I also tried the adb way, before giving up, so something else may be left behind from it) I use the following

[Unit]
Description=KlipperScreen
After=moonraker.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=pi
# in the following line put the values that xsdl gives you in the blue screen when you start it
Environment="DISPLAY=PHONE_STATIC_IP:1" "PULSE_SERVER=tcp:PHONE_STATIC_IP:4713"
WorkingDirectory=/home/pi/KlipperScreen
ExecStart=/home/pi/.KlipperScreen-env/bin/python /home/pi/KlipperScreen/screen.py

[Install]
WantedBy=multi-user.target

Notice how I removed the “xinit” part from the command line. It was giving me an error with “screen not found” (or similar).

Remember to assign a static IP to your phone using your router configuration, for extra safety.

When I start the printer the phone may be off, in that case, once xsdl is ready, from Mainsail I select “restart KlipperScreen”.

I think this is the easiest way to use an Android phone and it should be listed as main recommendation, with adb and such as more advanced setup (maybe pin this post to the first post?).

1 Like

Hey!
I also looked at the tutorial by Angel R. Rojas, Jr. but I am getting problems creating a UDEV rule for the device.
Whenever I type the command “sudo vi /etc/udev/rules.d/51-android.rules” I am asked for my password and then an E325 ERROR appears.

I’ve just started using KS a week ago. I ran it for a few days via USB tether and it was rock solid. I switched over to wifi a few days ago (following @DrEaD post above), and it’s been problematic ever since. It will run for a little while, but then it reverts back to the blue screen. I have assigned a static IP address. The screen.py process is still running, but I still just have the blue screen. If I kill the screen.py process and then start it manually, it doesn’t work. The only way I an get it to work is by rebooting the Pi, and then it will work again for some time (minutes to hours) before it stops again. Anyone got any ideas on what I should check please?

Also, is it possible to run 2 instances of KS on the same Pi for the same printer? Currently, I have KS displaying on an Android tablet on my desk, but I would also like to set up an old phone mounted on the printer itself. Since the DISPLAY variable contains the IP address, I assume that I would need to run two instances of the screen.py process. I haven’t tried it yet, just just wanted to know if anyone as done that yet?

Thanks for any and all help

the /etc directory is set up such that the files within can only be edited by someone with root access, which is why you are being asked for the password.

Where do you see that E325 error? Is it in the terminal window or on the android device?

In Putty terminal…
It says it found a swap file!?!?
I just found a solution from another person (16.04 - E325: ATTENTION swap file already present error in Vi - Ask Ubuntu), but these commands don’t work for me.
I just get: ~ ~ ~ ~ …in the terminal and can’t do anything.

OK, that makes sense. Vi (which is an old UNIX text editor) has previously created a swapfile to store changes to the file being edited, but for some reason vi has exited abnormally, and left the swap file there. I followed the link you posted, and the answer is missing one piece of vital information: when he says to press r to recover the swapfile, or q to quit and delete the swapfile, those commands need to be preceded with a colon, so :r or :q. Just pressing r or q without the colon means something completely different.

If you don’t know how to use vi, I would suggest copying the file over to your PC, editing it there, and then copying it back (as root). I acually like vi, I used it for years cutting code, but it is a real pig if you are not familiar with it.

If you decide to use vi, and you mess it up, you can always quit gracefully by hitting the escape key, and then typing “:q!” (without the quotes), and that will force it to quit without saving changes.