Trouble connecting Pi4 to MK3s (Einsy board) via GPIO

Information about my setup

Hardware: Raspberry Pi 4 2gb.
Software: Octoprint 0.18.0 (Stable 0.17.0 didn't work).
Printer: Prusa MK3s, Firmware 3.9.1.
Connected: via GPIO pins.

What is the problem?

I did a 2hr print today via USB.
But can't connect to printer via GPIO pins.


Attempt 1

In the printer:

Didn't work (I kept it on of course).


Attempt 2

I followed the "Configure RPi Zero W GPIO" guide here (Although I have Pi4 2gb):

Trying to connect to the printer, successful for a bit (see picture):
image

Then I get this error:
image


Attempt 3

Saw a comment relating to pi4 in the guide (link above in Attempt 2):
To change the config.txt at the end
from
dtoverlay=pi3-miniuart-bt
to
enable_uart=1 dtoverlay=disable-bt

Trying to connect to the printer, successful for a bit with around 3/22 resend ratio.

Then I got this error:
image

Here are 2 logs
config.txt log:

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
# enable raspicam
start_x=1
gpu_mem=128
enable_uart=1 dtoverlay=disable-bt

serial.log log:

2020-12-27 13:13:06,522 - Changing monitoring state from "Offline" to "Detecting serial connection"
2020-12-27 13:13:06,536 - Performing autodetection with 4 port/baudrate candidates: /dev/ttyS0@115200, /dev/ttyS0@250000, /dev/ttyAMA0@115200, /dev/ttyAMA0@250000
2020-12-27 13:13:06,536 - Trying port /dev/ttyS0, baudrate 115200
2020-12-27 13:13:06,537 - Connecting to port /dev/ttyS0, baudrate 115200
2020-12-27 13:13:06,545 - Handshake attempt #1 with timeout 2.0s
2020-12-27 13:13:06,546 - Connected to: Serial<id=0xb148d090, open=True>(port='/dev/ttyS0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=2.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2020-12-27 13:13:06,547 - Send: N0 M110 N0*125
2020-12-27 13:13:06,552 - Recv: echo:Unknown command: "UhH"(2)
2020-12-27 13:13:06,553 - Recv: ok
2020-12-27 13:13:06,554 - Changing monitoring state from "Detecting serial connection" to "Operational"
2020-12-27 13:13:06,566 - Send: N0 M110 N0*125
2020-12-27 13:13:06,567 - Recv: echo:Unknown command: "%"(2)
2020-12-27 13:13:06,567 - Recv: ok
2020-12-27 13:13:06,568 - Send: N1 M115*39
2020-12-27 13:13:06,572 - Recv: echo:Unknown command: ""(2)
2020-12-27 13:13:06,573 - Recv: ok
2020-12-27 13:13:06,574 - Send: N2 M21*18
2020-12-27 13:13:06,580 - Recv: Error:No Line Number with checksum, Last Line: 0!ªÖ•¹‘é 1
2020-12-27 13:13:06,581 - Recv: ok
2020-12-27 13:13:11,560 - Send: N3 M105*36
2020-12-27 13:13:11,586 - Recv: echo:Unknown command: ""(2)
2020-12-27 13:13:11,587 - Recv: ok
2020-12-27 13:13:16,565 - Send: N4 M105*35
2020-12-27 13:13:17,467 - Recv: e±èKª¹­¹½Ý¹Çommand: "w[|"(29
2020-12-27 13:13:17,468 - Recv: ok
2020-12-27 13:13:21,566 - Send: N5 M105*34
2020-12-27 13:13:53,249 - Recv: echo:Unknown0command: "&fs73.3v77br76v3wf3~s6v7r77w62f76776nb3&v67n266s?w3$f67"7vff~r7s?(fs7r673v&v663@&r73w?s77"(2)
2020-12-27 13:13:53,261 - Recv: ok
2020-12-27 13:13:53,263 - Send: N6 M105*33
2020-12-27 13:13:53,270 - Recv: Er¹KéNo Line Number with checksum, Last Line: 0
2020-12-27 13:13:53,271 - Recv: Resend: 1
2020-12-27 13:13:53,274 - Recv: ok
2020-12-27 13:13:53,276 - Send: N1 M115*39
2020-12-27 13:13:53,284 - Recv: Error:No Line Number wiôh checksum, Last Line: 0
2020-12-27 13:13:53,285 - Recv: Resend: 1
2020-12-27 13:13:53,288 - Recv: ok
2020-12-27 13:13:53,289 - Send: N2 M21*18
2020-12-27 13:14:23,338 - Communication timeout during an active resend, resending same line again to trigger response from printer. Configure long running commands or increase communication timeout if that happens regularly on specific commands or long moves.
2020-12-27 13:14:23,346 - Send: N2 M21*18
2020-12-27 13:14:24,051 - Recv: Error:Line Number is not Last Lineÿïÿûý?·,ëKª¹­¹½Ý¹command: "67vv7vv7r3v™ÒúºÊ²º’ýnb6vf77~7&fv<sv&23&62??sf0767vv2fv37v67vsw7736sw73"6fw3?vw6w372fv33f"(2)
2020-12-27 13:14:24,052 - Recv: ok
2020-12-27 13:14:24,065 - Send: N3 M105*36
2020-12-27 13:14:24,072 - Recv: Error:No Line Number with checksum, Last Line: 0
2020-12-27 13:14:24,074 - Send: N4 M105*35
2020-12-27 13:14:24,075 - Recv: Resend: 1
2020-12-27 13:14:24,078 - Recv: ok
2020-12-27 13:14:24,080 - Send: N1 M115*39
2020-12-27 13:14:24,086 - Recv: Error:No Linÿÿûÿ»Y®—‹»6_¡kKúEòror:No LZ«Number with chekksum, Last Line: 0
2020-12-27 13:14:24,087 - Changing monitoring state from "Operational" to "Error: No Linÿÿûÿ»Y®—‹»6_¡kKúEòror:No LZ«Number with chekksum, Last Line: 0"
2020-12-27 13:14:24,089 - Send: M112
2020-12-27 13:14:24,090 - Send: N7 M112*38
2020-12-27 13:14:24,090 - Send: N8 M104 T0 S0*41
2020-12-27 13:14:24,091 - Send: N9 M140 S0*108
2020-12-27 13:14:24,143 - Changing monitoring state from "Error: No Linÿÿûÿ»Y®—‹»6_¡kKúEòror:No LZ«Number with chekksum, Last Line: 0" to "Offline (Error: No Linÿÿûÿ»Y®—‹»6_¡kKúEòror:No LZ«Number with chekksum, Last Line: 0)"
2020-12-27 13:14:24,145 - Connection closed, closing down monitor
2020-12-27 13:27:41,842 - Changing monitoring state from "Offline" to "Detecting serial connection"
2020-12-27 13:27:41,876 - Performing autodetection with 4 port/baudrate candidates: /dev/ttyS0@115200, /dev/ttyS0@250000, /dev/ttyAMA0@115200, /dev/ttyAMA0@250000
2020-12-27 13:27:41,877 - Trying port /dev/ttyS0, baudrate 115200
2020-12-27 13:27:41,877 - Connecting to port /dev/ttyS0, baudrate 115200
2020-12-27 13:27:41,893 - Unexpected error while connecting to serial port /dev/ttyS0, baudrate 115200 from hook default: error: '(22, 'Invalid argument')' @ comm.py:_open_serial:3670
2020-12-27 13:27:41,894 - Could not open port /dev/ttyS0, baudrate 115200, skipping
2020-12-27 13:27:41,894 - Trying port /dev/ttyS0, baudrate 250000
2020-12-27 13:27:41,895 - Connecting to port /dev/ttyS0, baudrate 250000
2020-12-27 13:27:41,898 - Unexpected error while connecting to serial port /dev/ttyS0, baudrate 250000 from hook default: error: '(22, 'Invalid argument')' @ comm.py:_open_serial:3670
2020-12-27 13:27:41,898 - Could not open port /dev/ttyS0, baudrate 250000, skipping
2020-12-27 13:27:41,898 - Trying port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:27:41,899 - Connecting to port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:27:41,902 - Handshake attempt #1 with timeout 2.0s
2020-12-27 13:27:42,910 - Could not write anything to the serial port in 5 tries, something appears to be wrong with the printer communication
2020-12-27 13:27:42,923 - Changing monitoring state from "Detecting serial connection" to "Offline (Error: Could not write to serial port)"
2020-12-27 13:27:42,957 - Closing down send loop
2020-12-27 13:27:50,898 - Changing monitoring state from "Offline" to "Detecting serial connection"
2020-12-27 13:27:50,900 - Performing autodetection with 7 port/baudrate candidates: /dev/ttyAMA0@115200, /dev/ttyAMA0@250000, /dev/ttyAMA0@230400, /dev/ttyAMA0@57600, /dev/ttyAMA0@38400, /dev/ttyAMA0@19200, /dev/ttyAMA0@9600
2020-12-27 13:27:50,900 - Trying port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:27:50,901 - Connecting to port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:27:50,920 - Handshake attempt #1 with timeout 2.0s
2020-12-27 13:27:51,922 - Could not write anything to the serial port in 5 tries, something appears to be wrong with the printer communication
2020-12-27 13:27:51,939 - Changing monitoring state from "Detecting serial connection" to "Offline (Error: Could not write to serial port)"
2020-12-27 13:27:51,950 - Closing down send loop
2020-12-27 13:28:50,237 - Changing monitoring state from "Offline" to "Detecting serial connection"
2020-12-27 13:28:50,238 - Performing autodetection with 7 port/baudrate candidates: /dev/ttyAMA0@115200, /dev/ttyAMA0@250000, /dev/ttyAMA0@230400, /dev/ttyAMA0@57600, /dev/ttyAMA0@38400, /dev/ttyAMA0@19200, /dev/ttyAMA0@9600
2020-12-27 13:28:50,238 - Trying port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:28:50,239 - Connecting to port /dev/ttyAMA0, baudrate 115200
2020-12-27 13:28:50,257 - Handshake attempt #1 with timeout 2.0s
2020-12-27 13:28:51,261 - Could not write anything to the serial port in 5 tries, something appears to be wrong with the printer communication
2020-12-27 13:28:51,280 - Changing monitoring state from "Detecting serial connection" to "Offline (Error: Could not write to serial port)"
2020-12-27 13:28:51,299 - Closing down send loop

Have you tried running in safe mode?

No.

Did running in safe mode solve the problem?

Not sure what safe mode does.

You have some significant interference issues with this connection. Look at the logs, the data going back and forth is consistently corrupted. Need a shielded cable, maybe if you're connecting via the GPIO pins twisting the wires together can improve things. Otherwise you'll need to find a way of making the connections better, or shielding them properly. It's probably easier to use the USB cable.

Click the blue words - they're links that will explain all you need to know.

Cable

AWG: 36 (or 34, can't remember).
Length: around 45cm (±5cm).

Picture:

I'm not entirely sure what you want me to do with that picture of the cable, my comment above remains the same - try and shield it or make the connections more secure. Or use the USB (since that worked)

Just to show what I currently have, I think you are right (note: I am not an electrician).
I will buy new cable with proper shielding, probably shorter too (I don't need that long).

Thank you @Charlie_Powell.

1 Like

Did you get Octoprint to work via GPIO serial pins? I'm also having trouble to get this setup to work.

I ended up using the USB connection, didn't want to waste time making new cables...

I'm pretty sure that in my case the cables was too thin/too long/unshielded, and as a result there were electric interferences...
As you can see the communications back from the printer were gibberish (look at "serial.log log"):
'Recv' are the things the printer send back, sometimes it's somewhat readable & it reports about problems with the commands sent by the RPi, so the communications are problematic both ways.