Skip to content

Instantly share code, notes, and snippets.

@dimaj
Last active November 5, 2025 10:13
Show Gist options
  • Select an option

  • Save dimaj/6b2007d76105feb7cbee29d0f2305aec to your computer and use it in GitHub Desktop.

Select an option

Save dimaj/6b2007d76105feb7cbee29d0f2305aec to your computer and use it in GitHub Desktop.
Flashforge AD5m \ pro nozzle wipe macro
[gcode_macro NOZZLE_WIPE]
description: Wipe the nozzle on the nozzle brush pad
gcode:
{% set wiper_start_x = params.START_X | default(25) | int %}
{% set wiper_end_x = params.END_X | default(-25) | int %}
{% set wiper_start_y = params.START_Y | default(110) | int %}
{% set wiper_end_y = params.END_Y | default(108) | int %}
{% set wiper_z = params.Z_OFFSET | default(4) | int %}
{% set extruder_start_temp = params.START_TEMP | default(220) | int %}
{% set extruder_end_temp = params.END_TEMP | default(150) | int %}
{% set start_x = wiper_start_x - 5 %}
{% set end_x = wiper_end_x + 5 %}
{% set y_travel = (wiper_start_y - wiper_end_y) | abs %}
# nozzle heating
M104 S{extruder_start_temp} ; set nozzle temperature
{% if not "xyz" in printer.toolhead.homed_axes %}
G28
{% endif %}
G90 ; absolute coordinates
G1 X{start_x} Y{wiper_start_y} Z{wiper_z} F18000 ; get into position
# wait for nozzle to reach temp, don't wait for stabilization
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_start_temp}
M104 S{extruder_end_temp} ; set nozzle temperature
# wait for nozzle to reach temp, don't wait for stabilization
TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={extruder_end_temp}
# Calculate how many steps nozzle should take. Basically, it's the length of the wipe
{% set steps = (((wiper_start_x|abs) + (wiper_end_x|abs))) | int %}
{ action_respond_info( "Starting nozzle wipe" ) }
# initialize variables
{% set x = wiper_start_x %}
{% set multiplier = 1 %} ; This is used to determine if Y movement should be towards or away from center
{% for i in range(0, steps) %}
# since we are starting to the right of wipe plate, we have to move left
{% set x = x - i %}
# negate multiplier to change direction of motion
{% set multiplier = multiplier * -1 %}
# move to new X and Y_travel * multiplier for Y
G1 X{x} Y{wiper_start_y + (i%2) * y_travel * multiplier} F1800
{% endfor %}
; lower the bed
G1 Z20
; Move nozzle to 0, 0
G1 X0 Y0 Z{wiper_z} F18000

This is a macro for Flashforge Adventurer 5M (Pro) to wipe the nozzle before prints. This macro implies that you are using Tinkering Poko's model, which could be found on Printables

You should double check that the default values match up with your installation (or, you can pass in all parameters to the macro)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment