<p>A very dumb, simple way to send GCODE to your printer from the terminal can be achieved with:<br />
<code>echo &quot;gcode here&quot; &gt; /dev/ttyS0</code><br />
/dev/ttyS0 can vary, It may be /dev/ttyACM0, /dev/ttyUSB0, or any similar with a different number.</p>
<p>You can figure out which path is correct for your printer with the command <code>ls /dev/tty*</code> and comparing the results with your printer plugged in and unplugged, Whichever device pops up new should be your printer.<br />
As well, Some printers may appear in <code>/dev/serial/by-id/</code> instead of <code>/dev/tty*</code>, so if you can't find your printer normally, try <code>ls /dev/serial/by-id/</code> instead.</p>
<p>If this doesn't seem to work, you may need to change the serial settings using the command <code>sudo stty -f /dev/ttyS0 115200</code>, replacing /dev/ttyS0 and 115200 to the device path and printer baud rate respectively.</p>
<p>If you are looking for a more bi-directional solution, you can use the command <code>screen</code>, which is usually installed by default. You can use it like this:<br />
<code>screen /dev/ttyS0 115200</code> and exit by Control+A, then pressing D<br />
Another solution would be the <code>pronsole</code> utility from Printrun/Pronterface, which can be installed using <code>sudo apt install printrun</code> and invoked with <code>pronsole.py</code> and you can then connect to your printer with the syntax<br />
<code>connect /dev/ttyS0 115200</code> or simply <code>connect</code>, as pronsole has the ability to autoconnect to your printer. Exit with the <code>exit</code> command.</p>

CC BY-SA 4.0
2021-08-16T13:46:04.217Z
2021-08-16T13:46:04.217Z
craftxbox
<p>Sending G-code to a printer via a serial interface is a bidirectional operation that requires waiting for acknowledgment from the printer before sending further commands. In theory, this shouldn't be needed and hardware flow control (or even XON/XOFF flow control if the hardware is not available) should be used, but that's not the way things were done. Thus, sending G-code with &quot;dumb&quot; commands like &quot;cat&quot; does not work.</p>
<p>If you want to send individual commands manually, you can use a program like Minicom (or screen's built-in serial terminal support) and process the acknowledgments yourself. But if you want to really stream print jobs, you need at least a minimal program for it. This can be written in a few lines of Python or Perl if you like. I know there are examples of such but I don't have the links handy and haven't tried any of them to be able to recommend one, anyway.</p>

CC BY-SA 4.0
2021-08-16T16:04:57.803Z
2021-08-16T17:36:45.763Z
2021-08-16T17:36:45.763Z
R.. GitHub STOP HELPING ICE
<p>You can send the data to the serial port using <code>echo</code>, but you'll have to use <code>cat</code> to get the response.</p>

CC BY-SA 4.0
2021-08-05T14:56:39.623Z
Your answer was flagged by the system as being a little short. Could you [edit] and expand your answer and provide examples of the commands in use (maybe with dummy data)?
Greenonline
CC BY-SA 4.0
2021-08-05T14:30:34.597Z
2021-08-05T14:56:59.227Z
2021-08-05T14:56:59.227Z
user77232
<p>I want to plug in my drivers from the printer into my Raspberry Pi. I want to control the printer's axes by sending G-code directly from the Raspberry Pi command line (if possible) to the drivers.</p>
<p>Is that possible and if yes does anyone know how? As I stated above without using any 3rd party program/software.</p>

CC BY-SA 4.0
2021-08-05T03:25:07.457Z
depends on what the printer accepts.  if firmware will accept g code over serial, you just need the correct port settings...
Abel
CC BY-SA 4.0
2021-08-05T07:17:02.460Z
Okay how can i see what my printer/firmware accepts?
Spieler Spiel
<raspberry-pi>
How to send G-Code directly from a Raspberry Pi to my printer without using any extra program/software
Spieler Spiel
# How to send G-Code directly from a Raspberry Pi to my printer without using any extra program/software

(Asked by: username_0 on 2021-08-04)

I want to plug in my drivers from the printer into my Raspberry Pi. I want to control the printer's axes by sending G-code directly from the Raspberry Pi command line (if possible) to the drivers.

Is that possible and if yes does anyone know how? As I stated above without using any 3rd party program/software.

**Tags:** raspberry-pi

> **Comments:**
> **username_1**: depends on what the printer accepts.  if firmware will accept g code over serial, you just need the correct port settings...  
> **username_0**: Okay how can i see what my printer/firmware accepts?  

---

## 3 answers

### Answer by username_2 on 2021-08-16. Score: 2

A very dumb, simple way to send GCODE to your printer from the terminal can be achieved with:  
`echo "gcode here" > /dev/ttyS0`  
/dev/ttyS0 can vary, It may be /dev/ttyACM0, /dev/ttyUSB0, or any similar with a different number.

You can figure out which path is correct for your printer with the command `ls /dev/tty*` and comparing the results with your printer plugged in and unplugged, Whichever device pops up new should be your printer.  
As well, Some printers may appear in `/dev/serial/by-id/` instead of `/dev/tty*`, so if you can't find your printer normally, try `ls /dev/serial/by-id/` instead.

If this doesn't seem to work, you may need to change the serial settings using the command `sudo stty -f /dev/ttyS0 115200`, replacing /dev/ttyS0 and 115200 to the device path and printer baud rate respectively.

If you are looking for a more bi-directional solution, you can use the command `screen`, which is usually installed by default. You can use it like this:  
`screen /dev/ttyS0 115200` and exit by Control+A, then pressing D  
Another solution would be the `pronsole` utility from Printrun/Pronterface, which can be installed using `sudo apt install printrun` and invoked with `pronsole.py` and you can then connect to your printer with the syntax  
`connect /dev/ttyS0 115200` or simply `connect`, as pronsole has the ability to autoconnect to your printer. Exit with the `exit` command.


---

### Answer by username_3 on 2021-08-16. Score: 1

Sending G-code to a printer via a serial interface is a bidirectional operation that requires waiting for acknowledgment from the printer before sending further commands. In theory, this shouldn't be needed and hardware flow control (or even XON/XOFF flow control if the hardware is not available) should be used, but that's not the way things were done. Thus, sending G-code with "dumb" commands like "cat" does not work.

If you want to send individual commands manually, you can use a program like Minicom (or screen's built-in serial terminal support) and process the acknowledgments yourself. But if you want to really stream print jobs, you need at least a minimal program for it. This can be written in a few lines of Python or Perl if you like. I know there are examples of such but I don't have the links handy and haven't tried any of them to be able to recommend one, anyway.


---

### Answer by username_4 on 2021-08-05. Score: 0

You can send the data to the serial port using `echo`, but you'll have to use `cat` to get the response.

> **Comments:**
> **username_5**: Your answer was flagged by the system as being a little short. Could you [edit] and expand your answer and provide examples of the commands in use (maybe with dummy data)?  

---

