Let klipper send the printing head position to another computer

Basic Information:

Printer Model: BTT Manta M8P
MCU / Printerboard: STM32G0B1
Host / SBC: BTT CB1
klippy.log (460.5 KB)

Hi, I am a new user of klipper and am trying to make my own 3D printer with BigTree Tech mother board. I wonder if there is a way to setup dual-direction communication between the klipper and a laptop (or Raspberry Pi), so I can collect and manipulate the data easily?

What I have achieved so far:

  1. Passing “GET_POSTION” or “M114” through touch screen and Mainsail interface. The head positions are displayed correspondingly.
  2. Using " biqu@BTT-CB1:~$ echo GET_POSITION > ~/printer_data/comms/klippy.serial" by ssh connection. The position data is displayed on the touch screen. (This is very close to what I need.)

What I want to achieve:
I would like the klipper sending the position data back through ssh connection, so I can collect and pass the data to another programme, which turns an LED array on and off in a certain pattern.

The suggestion I have got and still under developed:
“…use some daemon to listen on this endpoint, … You could work with some socat magic to listen on the PTY…” As I am lacking of knowledge in computer science, I have not made it work yet. If anyone could give any related links (docs or video tutorial), I will be very appreciate.

Other thoughts:
There might be other ways to bypass this problem? As I can get the postion data by Mainsail on chrome browser, could I use some webpage technic to grab the postion data out of the page? Or using the SPI/UART pins on the BTT Manta board to send a coded position data to another microcontroller (e.g. arduino or the GPIO pins on the BTT CB1).

Thanks in advnace.

What you’re looking for is the API Server and Moonraker.


Moonraker provides HTTP queries for the printer objects so you could query them from another PC and get data back.