<p>Based on Oscar's solution using M206, I found it convenient to add in my MicroSD card a hierarchy of such gcode files to set the Z offset to every possible value in some range. For example, "printing" the file z_offset/1mm/1mm2/1mm275.gcode will set (permanently) the Z offset to 1.275 millimeters.</p>

<p>This hack is a workaround to the lack of Z offset setting in the printer's menu, and is an alternative to "hardware" Z tuning by moving the endstop. It can be useful when using different build plates with varying thickness, or attaching a pen or any other tool to the print head.</p>

<p>Here is a simple bash script which creates the files taking the MicroSD card location as argument:</p>

<pre><code>#!/bin/bash -e

mkdir $1/z_offset

for i in {9..0}
do
    mkdir <span class="math-container">$1/z_offset/"$</span>i"mm
    for j in {9..0}
    do
        mkdir <span class="math-container">$1/z_offset/"$</span>i"mm/"<span class="math-container">$i"mm"$</span>j"
        for d in 00 25 50 75
        do
            echo -e \
                 M206 Z-<span class="math-container">$i.$</span>j<span class="math-container">$d\\nM500\\nM117 Z-offset="$</span>i"."<span class="math-container">$j$</span>d"mm \
                 &gt;<span class="math-container">$1/z_offset/"$</span>i"mm/"<span class="math-container">$i"mm"$</span>j"/"<span class="math-container">$i"mm"$</span>j$d".gcode
        done
    done
done
</code></pre>

<p>I chose a 0.025mm resolution, as 0.1mm is slightly to coarse to adjust for first layer issues. Tested successfully on a Creality Ender 3 printer (which seems to have a 0.015mm resolution on the Z-axis).</p>

CC BY-SA 4.0
2019-05-15T22:56:36.037Z
2019-05-15T22:56:36.037Z
Tifn
<p>Assuming you already know your Z-offset value, there are several ways to set Z-offset for your printer:</p>
<ul>
<li><p><strong>on printer's display</strong></p>
<p>On the printer's LCD, navigate to <strong>Control</strong> &gt; <strong>Motion</strong> &gt; <strong>Z Offset</strong>. Here you can set the Z-Offset value. Next, navigate to <strong>Control</strong> &gt; <strong>Store settings</strong> to store this offset permanently to EEPROM.</p>
<p>The location of this setting may vary depending on the printer and firmware, but it is usually located in the <strong>Control</strong> section.</p>
</li>
<li><p><strong>in slicer</strong></p>
<p>Z-offset value can be set in slicer, from where it will be added at the beginning of each generated G-code file.</p>
<ul>
<li><p><strong>PrusaSlicer</strong></p>
<p>Navigate to <strong>Printer Settings</strong> &gt; <strong>Size and coordinates</strong> &gt; <strong>Z offset</strong>. Requires an <strong>advanced</strong> view mode.</p>
<p><a href="https://i.sstatic.net/Psq65.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Psq65.png" alt="PrusaSlicer Z-offset setting" /></a></p>
</li>
<li><p><strong>SuperSlicer</strong></p>
<p>Navigate to <strong>Printer Settings</strong> &gt; <strong>Size and coordinates</strong> &gt; <strong>Z offset</strong>. Requires an <strong>expert</strong> view mode.</p>
<p><a href="https://i.sstatic.net/OqeFr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OqeFr.png" alt="SuperSlicer Z-offset setting" /></a></p>
</li>
<li><p><strong>Cura</strong></p>
<p>Navigate to <strong>Print settings</strong> &gt; <strong>Build Plate Adhesion</strong> &gt; <strong>Z Offset</strong>. Requires <a href="https://marketplace.ultimaker.com/app/cura/plugins/fieldofview/ZOffsetPlugin" rel="nofollow noreferrer"><strong>Z Offset Setting</strong></a> plugin installed.</p>
<p><a href="https://i.sstatic.net/b0mED.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/b0mED.png" alt="Cura Z-offset setting" /></a></p>
</li>
</ul>
</li>
<li><p><strong>in G-code</strong></p>
<p>It can be set with <code>M851</code> command, followed by <code>M500</code> to store it in the EEPROM. For example:</p>
</li>
</ul>
<pre><code>   M851 Z-0.69;
   M500;
</code></pre>
<ul>
<li><p><strong>in firmware</strong></p>
<p>In <strong>Configuration.h</strong>, find <code>NOZZLE_TO_PROBE_OFFSET</code> and set third parameter (Z-offset):</p>
</li>
</ul>
<pre><code>    #define NOZZLE_TO_PROBE_OFFSET {
       -53.5,   // X-offset
       8,       // Y-offset
       -0.69 }  // Z-offset &lt;-- set it here
</code></pre>
<hr />
<p>I usually set it via <strong>printer's display</strong>, since it seems like the fastest and most practical way.</p>

CC BY-SA 4.0
2023-01-02T19:07:04.067Z
2023-01-02T19:07:04.067Z
kosteklvp
<p>You don't! Level the bed such that you know the nozzle is above the bed. Stop the print. Disable the steppers. Let it all cool down. Tram the bed (or what you call level). Then start the print again. It doesn't matter what first layer height your slicer thinks it is. All that matters is that it sticks and doesn't elephant foot. Note, if you are using glue stick or white glue (like I do) the thickness of the glue layer will be different between the edge of the glass (I assume you're using glass, otherwise you're never going to get a good tram) and the starting position of the prints. </p>

CC BY-SA 4.0
2019-05-15T23:41:31.650Z
2019-05-15T23:41:31.650Z
user77232
<p>It is preferred to get the distance correct by hardware changes (leveling screws). But it is possible to do it with software. You can not only change the Z offset in the slicer or in the configuration of Marlin, but also with G-code commands.</p>
<p>The &quot;paper drag&quot; method is perfect for determining the correct Z level. Once you leveled with the paper, you do not need to create an offset to account for the paper thickness, however, there are purists that do that. So basically, what we call Z=0 is in fact Z=&quot;paper thickness&quot;, unless you are a purist. But a slightly larger gap makes printing much easier. Too small heights cause e.g. rippling effects or too much pressure build-up in the nozzle. In order to change your offset after leveling, you could try one of the following methods. This is sometimes a useful method for creating a little extra offset for printing PETG, but personally I do not do that.</p>
<p><strong>In Ultimaker Cura</strong>:
Open the plugin manager (&quot;Toolbox&quot;-&gt;&quot;Browse packages...&quot;) and install &quot;Z Offset Setting&quot;, a new parameter will be available in the &quot;Build Plate Adhesion&quot; settings menu called &quot;Z Offset&quot;. (See also <a href="/a/5939/5740">this older, not up-to-date answer</a>)</p>
<p><strong>In Marlin configuration file</strong>, modify the MANUAL_Z_HOME_POS constant:</p>
<pre><code>//#define MANUAL_Z_HOME_POS 0
</code></pre>
<p><strong>In G-code</strong>:</p>
<p>By adding the following lines to your start G-code (see e.g. <a href="/a/4746/5740">this answer</a>) using the <a href="http://marlinfw.org/docs/gcode/G092.html" rel="nofollow noreferrer"><code>G92</code></a> G-code command:</p>
<pre><code>G0 Z0.2 ; Move the head to 0.2 mm (so now 0.3 on your machine)
G92 Z0  ; Call this Z = 0
</code></pre>
<p>or when you are able to connect to the printer over USB using a printer terminal (e.g. Pronterface, Repetier or OctoPrint) using the <a href="http://marlinfw.org/docs/gcode/M206.html" rel="nofollow noreferrer"><code>M206</code></a> G-code command:</p>
<blockquote>
<p>Use M206 to apply a persistent offset to the native home position and coordinate space. This effectively shifts the coordinate space in the negative direction.</p>
</blockquote>
<pre><code>M206 Z-0.2 ; Will raise the Z height by 0.2 mm
M500       ; Stores the offset in memory
</code></pre>
<p>Alternatively, when you cannot connect through a terminal, putting the last 2 lines in a text file and saving that as a <code>.gcode</code> file on an SD card and &quot;printing&quot; the file will also store the new offset (if <code>M500</code> is enabled in the configuration file: <code>#define EEPROM_SETTINGS // Enable for M500 and M501 commands</code>)</p>

CC BY-SA 4.0
2018-10-23T20:38:42.120Z
I had seen the plugin for cura but it felt hacky to me especially since this seems like it would be a universal requirement for everyone without auto bed leveling. Is this what everyone else does??
Matthew Goulart
CC BY-SA 4.0
2018-10-23T20:53:25.407Z
@MatthewGoulart Preferred solution is to correctly level the bed from a hardware point of view (what most people do). From the software solutions I prefer the `M206` / `M500` as this stores this for all models you print. If you do it in the slicer or startcode, you need to remmeber that, e.g. when you change slicer.
0scar
CC BY-SA 4.0
2018-10-23T21:04:28.713Z
Sorry if this question has an obvious answer, but how would you level it on a hardware level? Are you saying I give the screws an extra 1/8 of a turn after leveling with the paper?
Matthew Goulart
CC BY-SA 4.0
2018-10-23T22:26:21.190Z
When you say "Once you leveled with the paper, you do not need to create an offset to account for the paper thickness" are you implying that most people just ignore the offset introduced by the paper? Are you saying I should just not take it into account?
Matthew Goulart
CC BY-SA 4.0
2018-10-23T22:36:46.050Z
@MatthewGoulart - Yeah, just ignore it. The paper width *is* your zero starting point.
Greenonline
CC BY-SA 4.0
2018-10-23T20:11:23.933Z
2023-01-02T13:57:56.357Z
2023-01-02T13:57:56.357Z
0scar
<p>I have what I thought would be a simple question.</p>

<p>I don't have an auto leveling probe, I do my leveling manually with 4 screws and a piece of paper (I measured the thickness to 0.1&nbsp;mm).</p>

<p>For the longest time I would have trouble with the first layer, sometimes having to give the bed screws a quarter turn to bring the bed up a bit. I would see that the nozzle seemed quite far away from the bed. This went on for the longest time and I just chalked it up to the quality of my printer.</p>

<p>I realized recently that when I level the bed, I am inserting a piece of paper in between the nozzle and the bed. Obviously, I should be taking the thickness into account as a 0.1mm thick piece of paper accounts for 50&nbsp;% higher than the nozzle should be for a 0.2&nbsp;mm first layer height.</p>

<p>My question is, how do I set (either in Cura or directly in Marlin config) the z home offset to account for the 0.1&nbsp;mm thickness of my calibration paper?</p>

<marlin><ultimaker-cura><bed-leveling>
How to set the Z home offset
Matthew Goulart
# How to set the Z home offset

(Asked by: username_0 on 2018-10-23)

I have what I thought would be a simple question.

I don't have an auto leveling probe, I do my leveling manually with 4 screws and a piece of paper (I measured the thickness to 0.1 mm).

For the longest time I would have trouble with the first layer, sometimes having to give the bed screws a quarter turn to bring the bed up a bit. I would see that the nozzle seemed quite far away from the bed. This went on for the longest time and I just chalked it up to the quality of my printer.

I realized recently that when I level the bed, I am inserting a piece of paper in between the nozzle and the bed. Obviously, I should be taking the thickness into account as a 0.1mm thick piece of paper accounts for 50 % higher than the nozzle should be for a 0.2 mm first layer height.

My question is, how do I set (either in Cura or directly in Marlin config) the z home offset to account for the 0.1 mm thickness of my calibration paper?

**Tags:** marlin, ultimaker-cura, bed-leveling

---

## 4 answers

### Answer by username_4 on 2018-10-23. Score: 8 | Accepted answer

It is preferred to get the distance correct by hardware changes (leveling screws). But it is possible to do it with software. You can not only change the Z offset in the slicer or in the configuration of Marlin, but also with G-code commands.
The "paper drag" method is perfect for determining the correct Z level. Once you leveled with the paper, you do not need to create an offset to account for the paper thickness, however, there are purists that do that. So basically, what we call Z=0 is in fact Z="paper thickness", unless you are a purist. But a slightly larger gap makes printing much easier. Too small heights cause e.g. rippling effects or too much pressure build-up in the nozzle. In order to change your offset after leveling, you could try one of the following methods. This is sometimes a useful method for creating a little extra offset for printing PETG, but personally I do not do that.
In Ultimaker Cura:
Open the plugin manager ("Toolbox"->"Browse packages...") and install "Z Offset Setting", a new parameter will be available in the "Build Plate Adhesion" settings menu called "Z Offset". (See also this older, not up-to-date answer)
In Marlin configuration file, modify the MANUAL_Z_HOME_POS constant:
//#define MANUAL_Z_HOME_POS 0

In G-code:
By adding the following lines to your start G-code (see e.g. this answer) using the G92 G-code command:
G0 Z0.2 ; Move the head to 0.2 mm (so now 0.3 on your machine)
G92 Z0  ; Call this Z = 0

or when you are able to connect to the printer over USB using a printer terminal (e.g. Pronterface, Repetier or OctoPrint) using the M206 G-code command:

Use M206 to apply a persistent offset to the native home position and coordinate space. This effectively shifts the coordinate space in the negative direction.

M206 Z-0.2 ; Will raise the Z height by 0.2 mm
M500       ; Stores the offset in memory

Alternatively, when you cannot connect through a terminal, putting the last 2 lines in a text file and saving that as a .gcode file on an SD card and "printing" the file will also store the new offset (if M500 is enabled in the configuration file: #define EEPROM_SETTINGS // Enable for M500 and M501 commands)

> **Comments:**
> **username_0**: I had seen the plugin for cura but it felt hacky to me especially since this seems like it would be a universal requirement for everyone without auto bed leveling. Is this what everyone else does??  
> **username_4**: @MatthewGoulart Preferred solution is to correctly level the bed from a hardware point of view (what most people do). From the software solutions I prefer the `M206` / `M500` as this stores this for all models you print. If you do it in the slicer or startcode, you need to remmeber that, e.g. when you change slicer.  
> **username_0**: Sorry if this question has an obvious answer, but how would you level it on a hardware level? Are you saying I give the screws an extra 1/8 of a turn after leveling with the paper?  
> **username_0**: When you say "Once you leveled with the paper, you do not need to create an offset to account for the paper thickness" are you implying that most people just ignore the offset introduced by the paper? Are you saying I should just not take it into account?  
> **username_5**: @MatthewGoulart - Yeah, just ignore it. The paper width *is* your zero starting point.  

---

### Answer by username_1 on 2019-05-15. Score: 1

Based on Oscar's solution using M206, I found it convenient to add in my MicroSD card a hierarchy of such gcode files to set the Z offset to every possible value in some range. For example, "printing" the file z_offset/1mm/1mm2/1mm275.gcode will set (permanently) the Z offset to 1.275 millimeters.
This hack is a workaround to the lack of Z offset setting in the printer's menu, and is an alternative to "hardware" Z tuning by moving the endstop. It can be useful when using different build plates with varying thickness, or attaching a pen or any other tool to the print head.
Here is a simple bash script which creates the files taking the MicroSD card location as argument:
#!/bin/bash -e

mkdir $1/z_offset

for i in {9..0}
do
    mkdir $1/z_offset/"$i"mm
    for j in {9..0}
    do
        mkdir $1/z_offset/"$i"mm/"$i"mm"$j"
        for d in 00 25 50 75
        do
            echo -e \
                 M206 Z-$i.$j$d\\nM500\\nM117 Z-offset="$i"."$j$d"mm \
                 >$1/z_offset/"$i"mm/"$i"mm"$j"/"$i"mm"$j$d".gcode
        done
    done
done

I chose a 0.025mm resolution, as 0.1mm is slightly to coarse to adjust for first layer issues. Tested successfully on a Creality Ender 3 printer (which seems to have a 0.015mm resolution on the Z-axis).


---

### Answer by username_2 on 2023-01-02. Score: 1

Assuming you already know your Z-offset value, there are several ways to set Z-offset for your printer:

on printer's display
On the printer's LCD, navigate to Control > Motion > Z Offset. Here you can set the Z-Offset value. Next, navigate to Control > Store settings to store this offset permanently to EEPROM.
The location of this setting may vary depending on the printer and firmware, but it is usually located in the Control section.

in slicer
Z-offset value can be set in slicer, from where it will be added at the beginning of each generated G-code file.

PrusaSlicer
Navigate to Printer Settings > Size and coordinates > Z offset. Requires an advanced view mode.


SuperSlicer
Navigate to Printer Settings > Size and coordinates > Z offset. Requires an expert view mode.


Cura
Navigate to Print settings > Build Plate Adhesion > Z Offset. Requires Z Offset Setting plugin installed.




in G-code
It can be set with M851 command, followed by M500 to store it in the EEPROM. For example:


   M851 Z-0.69;
   M500;


in firmware
In Configuration.h, find NOZZLE_TO_PROBE_OFFSET and set third parameter (Z-offset):


    #define NOZZLE_TO_PROBE_OFFSET {
       -53.5,   // X-offset
       8,       // Y-offset
       -0.69 }  // Z-offset <-- set it here


I usually set it via printer's display, since it seems like the fastest and most practical way.


---

### Answer by username_3 on 2019-05-15. Score: 0

You don't! Level the bed such that you know the nozzle is above the bed. Stop the print. Disable the steppers. Let it all cool down. Tram the bed (or what you call level). Then start the print again. It doesn't matter what first layer height your slicer thinks it is. All that matters is that it sticks and doesn't elephant foot. Note, if you are using glue stick or white glue (like I do) the thickness of the glue layer will be different between the edge of the glass (I assume you're using glass, otherwise you're never going to get a good tram) and the starting position of the prints.


---

