← Open Viewer
GCodexG-Code Guide › M104 Command
M104

M104 — Set Hotend Temperature (Non-Blocking)

Category: Temperature  ·  Applies to: 3D Printer, Marlin, Klipper, Bioprinter  ·  Updated: May 2026

What is M104?

M104 sets the target hotend temperature and returns immediately without waiting for the temperature to be reached. The printer continues executing the next G-Code line while the heater warms up in the background.

Syntax

M104 [S] [T]

Parameters

ParameterDescription
STarget temperature in Celsius. S0 turns off the heater.
TExtruder/tool index (0, 1, 2...) for multi-extruder printers. Defaults to active tool.

Examples

M104 S210
↑ Start heating hotend to 210°C — does NOT wait
M104 S0
↑ Turn off hotend heater
M104 S230 T1
↑ Set tool 1 (second extruder) to 230°C without waiting

Important Notes

  • M104 is non-blocking — the printer continues to the next line immediately.
  • Use M104 early in your start script to begin heating while other setup commands run (saving time).
  • Use M109 (not M104) when you need the printer to wait until temperature is reached before continuing.
  • M104 S0 shuts off the heater — always include this in your end script to prevent fire hazards.
  • Temperature is measured by the thermistor — verify thermistor type matches firmware configuration.

Common Mistakes

  • Using M104 and immediately starting to print — the hotend may not be at temperature yet, causing under-extrusion or a clog.
  • Not including M104 S0 in the end script — hotend stays hot after print, wasting energy and causing wear.
  • Confusing M104 (non-blocking) with M109 (blocking) — use M109 when you need the printer to wait.

Frequently Asked Questions

Q: What is the difference between M104 and M109?
M104 sets the target temperature and moves on immediately — the printer does not wait. M109 sets the target temperature and pauses all motion until that temperature is reached. Use M104 for pre-heating while other tasks run, then M109 just before printing begins.
Q: What temperature should I set for PLA?
PLA typically prints between 190–220°C depending on the filament brand and color. A good starting point is 210°C for most generic PLA. Print a temperature tower (a model with M104 commands at each layer) to find the optimal temperature for your specific filament.
Q: Why is my temperature not reaching the set value?
Common causes: insufficient heater power (wrong heater cartridge wattage), poor PID tuning (run M303 to auto-tune), thermistor type mismatch in firmware, or a draught cooling the hotend excessively. Check wiring and run M303 E0 S210 C8 to auto-tune PID.