I'm working on a project for which I use the Printrun package to serial communicate my G-code to my 3D printer (Creality Ender 3, Marlin firmware). The idea is that I have an external button connected to an Arduino such that whenever I press this button, the M114 command should be sent and I want to receive the nozzle Z-position.

At the moment the code looks like this:

from printrun.printcore import printcore
from printrun import gcoder

# some code for button
import serial
import time

arduino = serial.Serial(port = 'COM5', baudrate = 9600, timeout = 0.1)
def Button():
    data = arduino.readline()
    return data

printer = printcore('COM4',115200)

gcode=[i.strip() for i in open('MyCode.gcode')]
gcode = gcoder.LightGCode(gcode)   

button = Button()
if button == b'1':

The code is running but I don't get any information about the outcome of the M114 command when I press the button.


  1. Is there something in my code that I'm missing? How can I receive the answer from the M114 command using Printrun?
  2. Do you know any other package that allows me to receive the answer from the 3D printer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.