Those are subsequent print of the same file.
# Cold-state first-layer inconsistency — fixed with a temperature-based Z-offset compensation
I finally solved a first-layer inconsistency on my Elegoo Neptune 4 Plus that had been driving me crazy.
The same G-code, filament, Z offset, and start procedure could produce very different first layers depending on how recently the printer had completed another print:
- Starting after the printer had been idle for more than 10 minutes produced a bad, overly squished patch.
- Reprinting the exact same file immediately produced a good patch.
- Waiting 10 minutes before printing the same file again made it bad again.
Above reproduces the zoffset inconsistency consistently.
The test model is [First Layer Test Patch on Printables](https://www.printables.com/model/1921014-first-layer-test-patch).
## Attached pictures
The four attached pictures are ordered as follows:
- **Picture 1:** Bad patch from a cold start.
- **Picture 2:** Good patch printed again immediately, with no wait.
- **Picture 3:** Bad patch printed after waiting 10 minutes.
- **Picture 4:** Extruder-temperature graph for the tests.
Pictures 1–3 show the repeatable first-layer change. Picture 4 shows that the bed remained at temperature while the machine returned toward its idle/cold state between prints.
## Printer setup
Before these tests, I trammed the bed using Klipper's `SCREWS_TILT_CALCULATE`. My normal `PRINT_START` also runs an adaptive bed-mesh calibration for every print. The inconsistent result therefore occurred despite screw-tilt adjustment and a fresh adaptive mesh covering the test patch.
I use openNep4une with silicon spacers.
## What I mean by a “cold start”
In this post, a cold start does **not** mean that the bed is cold.
The bed remains heated between prints and is already heat-soaked. I call it a cold start when the printer has not printed for more than 10 minutes and the rest of the machine has returned toward its idle/cold state while the bed remains at temperature.
This distinction matters because I originally suspected bed heat soak. That did not explain the behavior: the problem still occurred after the bed had been held at 60 °C for a long time.
## What I found
The failure correlated with whether the machine had recently completed a real print. The extruder temperature at the moment `PRINT_START` began turned out to be a convenient measurement of that state, but I do **not** think nozzle temperature alone is the root cause.
That distinction is important because simply preheating the nozzle did not fix the problem. Printing only the skirt and walls as a warm-up did not fix it either. A good result followed a completed patch print, not merely a hot nozzle or a small amount of toolhead movement/extrusion.
Picture 4 shows the correlation I use for compensation: the good immediate reprint began while the machine was still in its recently-printed state and the extruder was hot, while the bad cold-start and delayed patches began after the machine had moved back toward its idle state and the extruder had cooled.
On my printer:
- In the cold/idle machine state, the effective Z position needed to move approximately **0.09 mm farther from the bed**.
- In the recently-printed state, no additional adjustment was needed.
- Using the measured extruder temperature as a proxy, full compensation at or below **60 °C**, no compensation at or above **160 °C**, and linear interpolation between them worked well.
For example, one print began at 85.2 °C. The macro calculated:
```text
TEMP_Z_OFFSET temperature=85.2C adjustment=0.0673mm config: bottom=60.0C top=160.0C height=0.09mm
```
The calculation is:
```text
0.09 × (160 - 85.2) / (160 - 60) = 0.0673 mm
```
I have not proven which physical component or accumulated machine state causes the shift. It may involve the probe, nozzle, toolhead, gantry, frame, or their combined geometry. Starting extruder temperature is only a practical proxy for how recently the printer completed a print. Preheating tests showed that nozzle temperature by itself is not sufficient to reproduce or eliminate the problem.
## Klipper macro
I sample the actual extruder temperature at the beginning of `PRINT_START`, before bed heating, homing, bed-mesh calibration, or nozzle heating changes it. This does not assume that the nozzle causes the shift; it uses nozzle temperature as an easily available indicator of the machine's cold versus recently-printed state.
The helper macro applies the full configured adjustment at or below the bottom temperature, no adjustment at or above the top temperature, and linearly interpolates between them:
```ini
[gcode_macro _APPLY_EXTRUDER_TEMP_Z_OFFSET]
description: Compensate cold-state Z clearance using extruder temperature as a proxy
variable_temp_z_offset_bottom: 60.0
variable_temp_z_offset_top: 160.0
variable_temp_z_offset_height: 0.09
gcode:
{% set EXTRUDER_TEMP = printer.extruder.temperature|float %}
{% set BOTTOM_TEMP = params.TEMP_Z_OFFSET_BOTTOM|default(temp_z_offset_bottom)|float %}
{% set TOP_TEMP = params.TEMP_Z_OFFSET_TOP|default(temp_z_offset_top)|float %}
{% set MAX_Z_ADJUST = params.TEMP_Z_OFFSET_HEIGHT|default(temp_z_offset_height)|float %}
{% if TOP_TEMP <= BOTTOM_TEMP %}
{action_raise_error("TEMP_Z_OFFSET_TOP must be greater than TEMP_Z_OFFSET_BOTTOM")}
{% elif EXTRUDER_TEMP <= BOTTOM_TEMP %}
{% set TEMP_Z_OFFSET = MAX_Z_ADJUST %}
{% elif EXTRUDER_TEMP < TOP_TEMP %}
{% set TEMP_Z_OFFSET = MAX_Z_ADJUST * (TOP_TEMP - EXTRUDER_TEMP) / (TOP_TEMP - BOTTOM_TEMP) %}
{% else %}
{% set TEMP_Z_OFFSET = 0.0 %}
{% endif %}
SET_GCODE_OFFSET Z_ADJUST={TEMP_Z_OFFSET}
RESPOND PREFIX="TEMP_Z_OFFSET" MSG="temperature={EXTRUDER_TEMP|round(1)}C adjustment={TEMP_Z_OFFSET|round(4)}mm config: bottom={BOTTOM_TEMP}C top={TOP_TEMP}C height={MAX_Z_ADJUST}mm"
```
At the beginning of my `PRINT_START` macro, I read the optional settings and call the helper:
```ini
{% set TEMP_Z_OFFSET_BOTTOM = params.TEMP_Z_OFFSET_BOTTOM|default(printer["gcode_macro _APPLY_EXTRUDER_TEMP_Z_OFFSET"].temp_z_offset_bottom)|float %}
{% set TEMP_Z_OFFSET_TOP = params.TEMP_Z_OFFSET_TOP|default(printer["gcode_macro _APPLY_EXTRUDER_TEMP_Z_OFFSET"].temp_z_offset_top)|float %}
{% set TEMP_Z_OFFSET_HEIGHT = params.TEMP_Z_OFFSET_HEIGHT|default(printer["gcode_macro _APPLY_EXTRUDER_TEMP_Z_OFFSET"].temp_z_offset_height)|float %}
# This must run before heating, homing, or bed-mesh calibration.
_APPLY_EXTRUDER_TEMP_Z_OFFSET TEMP_Z_OFFSET_BOTTOM={TEMP_Z_OFFSET_BOTTOM} TEMP_Z_OFFSET_TOP={TEMP_Z_OFFSET_TOP} TEMP_Z_OFFSET_HEIGHT={TEMP_Z_OFFSET_HEIGHT}
```
My slicer calls it like this:
```gcode
PRINT_START ... TEMP_Z_OFFSET_BOTTOM=60 TEMP_Z_OFFSET_TOP=160 TEMP_Z_OFFSET_HEIGHT=0.09
```
The three values mean:
- `TEMP_Z_OFFSET_BOTTOM=60`: at or below 60 °C, apply the full adjustment.
- `TEMP_Z_OFFSET_TOP=160`: at or above 160 °C, apply no adjustment.
- `TEMP_Z_OFFSET_HEIGHT=0.09`: the maximum positive Z adjustment, moving the nozzle farther from the bed.
The `RESPOND` line records the sampled temperature, calculated adjustment, and configuration in the Klipper console, which makes it easier to compare each print with the temperature graph.
## Important warning
The `0.09 mm`, `60 °C`, and `160 °C` values are empirical values for my printer. Do not copy the height blindly: a wrong Z adjustment can ruin the first layer or cause a nozzle crash. Start conservatively, observe the direction of the error, and calibrate it for your own machine.
Since adding this compensation, the cold-start patch, immediate reprint, and delayed reprint have been consistent.