-
-
Save NameOfTheDragon/e579295549aaa19b3f41ae07b8f3cbd6 to your computer and use it in GitHub Desktop.
| ; An idea for using the heated bed of a 3D printer as a filament dryer. | |
| ; Adds GCODE command: START_DRYER TIME=T TEMPERATURE=C | |
| ; (T is time in seconds, C is bed temperature in Celsuis) | |
| ; To stop drying early, use STOP_DRYER. | |
| ; Also defined some utility macros: DRY_PLA, DRY_PETG and DRY_ABS. | |
| ; Edit these with your own preferred defaults. | |
| [gcode_macro START_DRYER] | |
| description: Start the heated bed filament dryer. | |
| gcode: | |
| {% set ChamberTemperature = params.CHAMBER | default(25.0) | float %} | |
| {% set BedTemperature = params.TEMPERATURE | default(50.0) | float %} | |
| {% set DryTime = params.TIME | default(14400) | int %} | |
| ; turn the heaters on, however you do that. | |
| M140 S{BedTemperature} ; Sets the print bed temperature without waiting. | |
| M141 S{ChamberTemperature} ; [OPTIONAL] Sets the enclosure temperature. | |
| ; then finally, | |
| SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE={DryTime} | |
| SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=bed_temperature VALUE={BedTemperature} | |
| SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=chamber_temperature VALUE={ChamberTemperature} | |
| UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1 | |
| [gcode_macro STOP_DRYER] | |
| gcode: | |
| ; Turn off heaters etc. here | |
| M140 S0 ; Disable bed heater | |
| M141 S0 ; [OPTIONAL] Disable enclosure heater/fan | |
| SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE=0 | |
| UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=0 ; Stop the timer. | |
| M117 Drying Stopped | |
| [gcode_macro DRYER_STATUS] | |
| variable_time_remaining: 0 | |
| variable_bed_temperature: 0 | |
| variable_chamber_temperature: 0 | |
| gcode: | |
| {% if time_remaining > 0 %} | |
| M140 S{bed_temperature} ; Reset bed temperature (prevents timeout) | |
| SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE={time_remaining - 1} | |
| M117 Drying {time_remaining} | |
| {% else %} | |
| STOP_DRYER | |
| {% endif %} | |
| [delayed_gcode DRYER_TIMER] | |
| gcode: | |
| UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1 | |
| DRYER_STATUS | |
| [gcode_macro DRY_PLA] | |
| gcode: | |
| START_DRYER TEMPERATURE=50 CHAMBER=25 TIME=14400 | |
| [gcode_macro DRY_PETG] | |
| gcode: | |
| START_DRYER TEMPERATURE=55 CHAMBER=30 TIME=18000 | |
| [gcode_macro DRY_ABS] | |
| gcode: | |
| START_DRYER TEMPERATURE=65 CHAMBER=40 TIME=14400 |
Guys
I am using btt octopus board with rasbperry pi 5.
I run code with GPT a little under 6 times and now no erroes
[gcode_macro START_DRYER]
gcode:
{% set TIME_PARAM = params.TIME|default(3)|float %}
{% set TEMP_PARAM = params.TEMP|default(50)|float %}
M140 S{TEMP_PARAM} ; Set non-blocking bed temp
SET_GCODE_VARIABLE MACRO=DRYER_STATE VARIABLE=time_remain_var VALUE={TIME_PARAM}
SET_GCODE_VARIABLE MACRO=DRYER_STATE VARIABLE=bed_temp_var VALUE={TEMP_PARAM}
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1
[gcode_macro STOP_DRYER]
gcode:
M140 S0 ; Disable bed heater
SET_GCODE_VARIABLE MACRO=DRYER_STATE VARIABLE=time_remain_var VALUE=0
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=0 ; Stop the timer
M118 Drying Stopped
[gcode_macro DRYER_STATE]
variable_time_remain_var: 0
variable_bed_temp_var: 0
gcode:
{% if time_remain_var > 0 %}
M140 S{bed_temp_var} ; Reset bed temp (prevents timeout)
SET_GCODE_VARIABLE MACRO=DRYER_STATE VARIABLE=time_remain_var VALUE={time_remain_var - 1}
M118 Drying {time_remain_var}
{% else %}
STOP_DRYER
{% endif %}
[delayed_gcode DRYER_TIMER]
gcode:
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1
DRYER_STATE
[gcode_macro DRY_PLA]
gcode:
START_DRYER temp=55 time=43200
[gcode_macro DRY_PETG]
gcode:
START_DRYER temp=65 time=43200
[gcode_macro DRY_ABS]
gcode:
START_DRYER temp=80 time=43200
[gcode_macro DRY_WarmRoom]
gcode:
START_DRYER temp=100 time=43200
akash191095 version works for me, running current git klipper etc... as of 3 august 2025
Nice macro set, but I wanted a better display on the timer, so I used this:
{% if time_remaining > 0 %}
M140 S{bed_temperature} ; Reset bed temperature (prevents timeout)
SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE={time_remaining - 1}
{% set hours_remaining = time_remaining // 3600 %}
{% set minutes_remaining = (time_remaining % 3600) // 60 %}
{% set seconds_remaining = time_remaining % 60 %}
M117 Drying {hours_remaining}:{minutes_remaining}:{seconds_remaining}
{% else %}
STOP_DRYER
{% endif %}
I was bored so I improved the macro a bit.
https://github.com/leadustin/QIDI-up2date-english/tree/main/dryer