Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Raspberry Pi Powered Laser Engraver
Latest commit 8bf6927 @iandouglas96 Update
Failed to load latest commit information. Version 0.1 Version 0.1 Update
laserengraver Version 0.2 Version 0.2 Version 0.1

engravR 0.1

Raspberry Pi Powered Laser Engraver Powered by Python 2.7

See for a tutorial/intro video.

See for a more in depth tutorial and more information.

This software allows for the control of a laser engraver with a Raspberry Pi. Details on the construction of such a machine can be found here:

This code is based off of the code found there by Xiang Zhai.

G code interpreter and executer for 2D CNC laser engraver using Raspberry Pi
Xiang Zhai, Oct 1, 2013
zxzhaixiang at
Modifications for terminal interface and Use with GCodeTools by Ian D. Miller
Jan 7,2014
info [at]


This software includes three main sections:

-The "server" code, to run on the pi. This consists of the following files:


-The "test" code, which is a simple mini script that can be used to debugging:

-This functionality can also be obtained with laserengraver -m.

-The "client" code, which is a simple GUI to control the engraver remotely:

-Requires the pexpect library

Server Setup

-Put the three "server" files on the pi somewhere, probably in the home folder. For the purposes of this tutorial, I'll assume that files are in a folder called engravR in the /home/pi directory.

-Run following commands:

cd engravR
sudo chmod +x laserengraver

-Open laserengraver and edit the following lines to reflect the pin numbers you are using:

MX=Bipolar_Stepper_Motor(22,18,24,26);     #pin number for a1,a2,b1,b2.  a1 and a2 form coil A; b1 and b2 form coil B



-Now, we need to add laserengraver to the root $PATH to make calling laserengraver easier. Run:

sudo nano /root/.bashrc

-Add the following two lines:

alias sudo='sudo env PATH=$PATH'
export PATH=/home/pi/engravR:$PATH

-Save and exit nano.

-Now, try running:

sudo -i laserengraver -h

-The following should display:

usage: laserengraver [-h] (-f FILEPATH | -m) [-s SPEED]

RPi Controlled Laser Engraver

optional arguments:
  -h, --help            show this help message and exit
  -f FILEPATH, --filepath FILEPATH
                        Path to GCode file
  -m, --manual          Manually control printer
  -s SPEED, --speed SPEED
                        Engraving speed (mm/sec)

Now, the terminal interface is ready to go. If you are comfortable with using the cli via ssh to control the pi, you can probably stop here. If you would like a client GUI, proceed

To set this up, we need to do one more thing on the Raspberry Pi itself. Follow the instructions here: to configure ssh. On step 2, follow the instructions for installing avahi/zeroconf. Now, the Pi is ready to go.

Client Setup

-Put the file somewhere on the client machine.

-Open with your favorite text editor. Look at the folowing lines:

#User set variables
remdir = "/home/pi/engravingfiles/"
address = "raspberrypi.local"
user = "pi"
password = "your-password-here"

-Set remdir to whatever directory you want GCode files uploaded to.

-Address is the IP address of the pi (raspberrypi.local with avahi-daemon installed)

-User and password are both fairly self-explanatory

-Install pexpect however you want. I suggest using:

sudo pip install pexpect



-You may also be able to just double click on A GUI will then open. It's usange is fairly straightforward. The server and client will need to be on the same network.

Generating GCode

-This code is designed to process GCode generated by the GCodeTools Inkscape extension using the "Default" tool. See for information about GCodeTools, its installation, and its usage. GCode generated by other software may not work well or at all and require code modification.

Something went wrong with that request. Please try again.