PID Tuning: How to Stabilise Hotend and Bed Temperature
How to PID tune a 3D printer hotend and bed: Marlin M303, M301, M304 and M500, Klipper PID_CALIBRATE and SAVE_CONFIG, and what Bambu and Prusa do for you.
PID tuning lets the printer’s firmware measure how your hotend or bed heats up and cools down, and work out the three numbers (P, I and D) it uses to hold a steady temperature. On Marlin you run M303 E0 S210 C8 U1 for the hotend (or E-1 for the bed) and save with M500; on Klipper you run PID_CALIBRATE HEATER=extruder TARGET=210 and then SAVE_CONFIG. Do it after changing a heater, thermistor, hotend or silicone sock, or when the temperature swings by more than a degree or two while printing. Bambu Lab and recent Prusa printers handle it for you.
This guide explains what PID control does, the signs that you need to tune it, the exact commands for Marlin and Klipper with every parameter explained, how to tune with the fan on, how to save the result when your printer has no settings memory, and what to do when tuning doesn’t fix the problem.
PID tuning at a glance
| Question | Short answer |
|---|---|
| What does it fix? | Temperatures that wobble, overshoot or take a long time to settle |
| When to run it | After replacing a heater, thermistor, hotend or sock; when the temperature graph swings |
| Marlin hotend | M303 E0 S<temp> C8 U1, then M500 |
| Marlin bed | M303 E-1 S<temp> C8 U1, then M500 (needs bed PID enabled in the firmware) |
| Klipper hotend | PID_CALIBRATE HEATER=extruder TARGET=<temp>, then SAVE_CONFIG |
| Klipper bed | PID_CALIBRATE HEATER=heater_bed TARGET=<temp>, then SAVE_CONFIG |
| Temperature to tune at | The one you print at most, e.g. 210 °C for PLA, 60 °C for the bed |
| How long it takes | About 5–10 minutes for a hotend; longer for a bed |
| Bambu Lab, Prusa MK4 / Core One | Nothing to do: the firmware’s values are set for the stock heaters |
A V6-style hotend: brass nozzle, heater block in a silicone sock, heater cartridge and thermistor, with the heat break above.Photo: A7N8X ·CC0 ·Wikimedia Commons
The heater block holds the heater cartridge and the thermistor.
Heater and thermistor wires run to the terminal block.
The control box shows nozzle and bed temperature, height and progress.
The mainboard: the printer's brain.Photo: kenming Wang ·CC BY-SA 2.0 ·Wikimedia Commons
A heater block in a silicone sock, with the nozzle below and heat break above.Photo: A7N8X ·CC0 ·Wikimedia Commons
What PID control does
A printer can’t hold a temperature by itself. The firmware reads the thermistor, a small sensor in the heater block or bed, many times a second, compares it with the target, and decides how much power to send to the heater. The simplest way would be to switch the heater fully on below the target and fully off above it. That’s called bang-bang control, and it overshoots: the heater block keeps getting hotter for a moment after the power cuts, so the temperature swings up and down around the target.
PID control is smarter. It adjusts the heater power in fine steps, using three terms:
- P (proportional): reacts to how far off the target you are now. Far below, lots of power; just below, a little.
- I (integral): reacts to how long you’ve been off. If the temperature sits half a degree low for a while, I slowly adds power until the gap closes.
- D (derivative): reacts to how fast the temperature is changing. If it’s rising quickly towards the target, D eases off early so it doesn’t overshoot.
The right P, I and D depend on your exact hardware: how powerful the heater is, how big the heater block is, how well the thermistor touches it, and how much the fans cool it. PID tuning (often called autotune) measures that for you. The firmware heats to your target, lets it overshoot and fall back several times, times each swing, and calculates the three numbers.
target 210 °C · reads 210 °C · block 210 °C · heater 54 % · holding · protected
- drag ↔ / ← → pull the thermistor out of its bore (up to halfway)
- P thermal runaway protection on / off
- W break / mend the thermistor wire
- T control: PID tuned, PID badly tuned, bang-bang
- Space heater target 210 °C / off
- Home reset: reseat, mend, protection on, clear the error
Do you need to PID tune?
Tune it when:
- You’ve replaced the heater cartridge, the thermistor, the whole hotend, or the bed heater.
- You’ve added or removed a silicone sock on the heater block. The sock keeps heat in, so the block behaves differently.
- You’ve changed the part cooling fan or its duct, especially to a much stronger fan that blows on the heater block.
- The temperature swings while printing: watch the graph on the printer’s screen, or in OctoPrint, Mainsail or Fluidd. A well-tuned hotend usually stays within about a degree of the target once it has settled.
- The printer overshoots badly when heating, or takes ages to settle.
- You get “heating failed” or “not heating at expected rate” errors and you’ve already ruled out a loose thermistor or a damaged wire.
- You’ve flashed new firmware, which may have reset the values to generic defaults.
You can skip it when:
- You have a Bambu Lab printer. There’s no user-facing PID tune; the firmware takes care of heater control.
- You have a Prusa MK4, MK4S or Core One. Prusa’s documentation says the stock values are set for the stock heaters and don’t need changing. The older MK3S family does have an optional PID calibration in its menu: LCD Menu → Calibration → PID calibration.
- Your printer holds its temperature steadily and you haven’t changed any heating parts.
A Prusa i3, the design behind many beginner printers.Photo: John Abella ·CC BY 2.0 ·Wikimedia Commons
An Ultimaker 3, a boxed desktop printer.Photo: DirkvdM ·CC BY-SA 4.0 ·Wikimedia Commons
Unboxing a kit printer.Photo: kenming Wang ·CC BY-SA 2.0 ·Wikimedia Commons
Before you start
- Clean the nozzle and heater block. A thick coating of old plastic changes how the block holds heat.
- Fit the silicone sock if you print with one. Tune the printer as it really prints.
- Check the thermistor is fully seated and its screw or clamp is tight. A loose thermistor reads low and slow, and no amount of tuning makes up for that.
- Know your usual temperatures. Tune at the temperature you print at most: for example 210 °C for PLA, 240 °C for PETG, 60 °C for a PLA bed. PID values work over a range, but they’re best near where you tuned.
- Stay with the printer. The hotend will go a few degrees above your target while it measures. That’s normal, but don’t walk away from any heater test.
Solid filament above the heat break, molten filament in the heater block.
The finned heatsink keeps the top of the hotend cold.
The hotend fan cools the heatsink. It must run whenever the hotend is hot.
A hotend being built: the heater wrapped in Kapton tape.Photo: syvwlch ·CC BY 2.0 ·Wikimedia Commons
How to PID tune on Marlin
You’ll need to send G-code to the printer: through a USB cable and a terminal (Pronterface or OctoPrint’s terminal, for example) or the printer’s own console. Some Marlin builds also have a PID autotune entry in the LCD menu, often under Configuration or Control → Temperature, but the menu names vary between builds; the commands below work on any Marlin printer with PID enabled.
1. Check the current values
M503
Look for the M301 line (hotend) and, if your firmware has bed PID, the M304 line (bed). Write them down so you can go back if you need to.
2. Turn on the part cooling fan (optional but recommended)
If you print with the part cooling fan running, as you do for PLA, turn it on to your normal speed first. The fan blows partly on the heater block and steals heat, and you want the tune to include that.
M106 S255
S255 is 100%; S128 is about 50%. If you mostly print with the fan at 100%, use S255.
3. Run the hotend autotune
M303 E0 S210 C8 U1
What each part means:
| Parameter | Meaning | Notes |
|---|---|---|
E0 |
The first hotend | E1 for a second hotend; E-1 for the bed |
S210 |
The target temperature, in °C | Use the temperature you print at most |
C8 |
The number of heating cycles | At least 3; Marlin’s default is 5. 8 gives a steadier average |
U1 |
Use the result straight away | Without it, Marlin only prints the result |
The hotend heats up, overshoots, cools, and repeats. Each cycle takes a minute or so. When it finishes, Marlin prints the new Kp, Ki and Kd values in the terminal.
4. Save
M500
That stores the new values in the printer’s memory (EEPROM) so they survive a restart. Send M503 again to check the M301 line shows the new numbers.
Without U1: setting the values by hand
If you ran M303 without U1, or want to type in values from an earlier tune, set them with M301:
M301 P21.01 I1.73 D63.67
M500
Those three numbers are the example from Marlin’s documentation, not values to copy: use the ones your own tune printed.
Bed PID on Marlin
M303 E-1 S60 C8 U1
M500
E-1 selects the bed. Use your usual bed temperature. A bed is big and slow, so each cycle takes several minutes. To set bed values by hand, use M304 P… I… D… and then M500.
A print bed in layers: heater, aluminium, magnet, spring steel, PEI.
The heated bed with a PEI sheet. The part is the only thing printed on it.
A part being printed on a spring-steel bed.Photo: Leonhard Lenz ·CC BY-SA 4.0 ·Wikimedia Commons
Model predictive control (MPC)
Recent versions of Marlin also offer model predictive temperature control (MPC) as an alternative to PID. Instead of three gains, it builds a model of the heater, the block and the fan. If your firmware was built with it, you autotune it with M306 T and save with M500. Marlin’s documentation notes that M306 T moves the nozzle to 1 mm above the bed during the test, so clear the bed first. If your printer uses MPC, M303 isn’t the command to use.
Stepper drivers on the mainboard, one per motor.Photo: kenming Wang ·CC BY-SA 2.0 ·Wikimedia Commons
The power supply turns mains power into 24 V for motors and heaters.
An assembled Ender 3: a classic bed-slinger.Photo: kenming Wang ·CC BY-SA 2.0 ·Wikimedia Commons
How to PID tune on Klipper
On Klipper you run the tune from the console in Mainsail or Fluidd, and Klipper writes the result into your config file for you.
1. Hotend
Turn on the part cooling fan if you print with it (M106 S255 works on Klipper too), then:
PID_CALIBRATE HEATER=extruder TARGET=210
HEATER is the name of the heater section in your config: extruder for the hotend. TARGET is the temperature in °C. Klipper’s own example uses TARGET=170; using your normal print temperature tunes it closer to how you’ll use it. The heater runs up to the target, then switches on and off several times while Klipper measures.
When it finishes, the console shows the new pid_Kp, pid_Ki and pid_Kd values and tells you to save them.
2. Save
SAVE_CONFIG
Klipper writes the values into an auto-generated block at the bottom of printer.cfg and restarts. If SAVE_CONFIG reports a conflict, your old pid_Kp, pid_Ki and pid_Kd lines are still set elsewhere in your config (often in an included file): delete them there and run it again.
3. Bed
PID_CALIBRATE HEATER=heater_bed TARGET=60
SAVE_CONFIG
Klipper’s documentation recommends PID for the bed only if the bed heater is switched by something that can switch fast (a MOSFET or solid-state relay). PID can toggle the bed heater several times a second, which a mechanical relay won’t survive. If your bed uses a mechanical relay, use Klipper’s watermark control instead.
PID_CALIBRATE also accepts WRITE_FILE=1, which saves the raw temperature samples to /tmp/heattest.txt if you want to graph them.
An enclosed CoreXY printer on a home desk.Photo: Mortymore ·CC BY 2.0 ·Wikimedia Commons
A CoreXY print head on a QIDI printer.Photo: Haroldbarlow8911 ·CC BY-SA 4.0 ·Wikimedia Commons
A modern toolhead: extruder, hotend and fans in one housing.Photo: disinterpreter ·CC BY-SA 2.0 ·Wikimedia Commons
The toolhead rides the gantry; cable chains carry its wires.Photo: disinterpreter ·CC BY-SA 2.0 ·Wikimedia Commons
Saving the values when there’s no EEPROM
Some Marlin builds don’t have settings memory turned on, so M500 replies with an “EEPROM disabled” message and the tune is lost at power-off. Two ways round it:
- Put the values in the slicer’s start G-code, so every print sets them. Add a line such as
M301 P… I… D…(andM304 P… I… D…for the bed) near the top. - Rebuild the firmware with the values in
Configuration.h(DEFAULT_Kp,DEFAULT_Ki,DEFAULT_Kd, and theDEFAULT_bedKpset for the bed), or with EEPROM support enabled.
Where to find the start G-code:
| Slicer | Path |
|---|---|
| OrcaSlicer | Printer settings → Machine G-code → Machine start G-code |
| Bambu Studio | Printer settings → Machine G-code → Machine start G-code |
| PrusaSlicer | Printer Settings → Custom G-code → Start G-code |
| Cura | Preferences → Configure Cura → Printers → Machine Settings → Start G-code |
Menu names move between slicer versions. If you can’t find it, search the slicer’s settings for “start G-code”.
Tuning with the fan: why it matters
A part cooling fan doesn’t only cool the plastic. Some of its air hits the heater block and nozzle, and that steals heat. When the fan switches on at layer 2 or 3, a hotend tuned with the fan off suddenly needs more power. If its PID values can’t respond fast enough, the temperature dips by several degrees and recovers slowly. On some printers the dip is big enough to trip a “heating failed” safety error.
Three things help:
- Tune with the fan running at the speed you normally print at.
- Fit a silicone sock on the heater block. It shields the block from the fan’s air and also keeps plastic off it.
- Aim the duct at the print, not the nozzle. A duct that blows straight across the heater block makes any hotend struggle.
Marlin also has optional PID_FAN_SCALING, which adds power when the fan speeds up, but it has to be enabled and set in the firmware build.
A heater block in a silicone sock, with the nozzle below and heat break above.Photo: A7N8X ·CC0 ·Wikimedia Commons
A small fan cooling the extruder assembly.Photo: syvwlch ·CC BY 2.0 ·Wikimedia Commons
A dual-nozzle head: two hotends side by side.Photo: Creative Tools from Halmstad, Sweden ·CC BY 2.0 ·Wikimedia Commons
How to tell if the tune worked
Heat to your usual temperature and start a print, then watch the temperature for a few minutes, especially when the fan turns on.
| What you see | What it means | What to do |
|---|---|---|
| Settles within about a degree of the target and stays there | The tune is good | Nothing |
| Overshoots by several degrees on heat-up, then settles | Usually fine for printing | Retune with more cycles if it bothers you |
| Dips several degrees when the fan starts, recovers slowly | Tuned with the fan off, or the fan hits the block | Retune with the fan on; fit a sock; check the duct |
| Swings up and down steadily by 2–5 °C | Values too aggressive or wrong for this hardware | Retune at your print temperature |
| Jumps or drops suddenly by many degrees | Not a tuning problem: a wiring or thermistor fault | Check the thermistor and its wires |
| Tune fails with an error | The heater can’t reach or hold the target | See below |
The first layers going down on a heated bed.Photo: syvwlch ·CC BY 2.0 ·Wikimedia Commons
A bed-slinger FDM printer halfway through a 225-layer print.
A metal-framed i3 printing a vase.Photo: John Abella ·CC BY 2.0 ·Wikimedia Commons
PID tuning and thermal runaway protection
PID tuning and thermal runaway protection are related but different. PID decides how much power to give the heater. Thermal runaway protection is a safety check that watches whether the temperature behaves as it should, and cuts the heaters if it doesn’t, for example if the thermistor falls out of the block and keeps reading low while the heater keeps heating.
On Klipper this check is the [verify_heater] section, with these defaults:
| Setting | Default | What it does |
|---|---|---|
max_error |
120 | How much accumulated temperature error is allowed before shutting down |
check_gain_time |
20 s for extruders, 60 s for the bed | How long the heater has to show progress while heating |
hysteresis |
5 °C | How far from target counts as “at temperature” |
heating_gain |
2 °C | How much the temperature must rise during check_gain_time |
If those checks fail, Klipper stops with an error such as “Heater extruder not heating at expected rate”. Marlin has its own checks, which report “Heating failed” or “Thermal runaway”.
Badly tuned PID values can trip these checks, for example when the fan pulls the temperature down further than the firmware expects. A good tune often makes false alarms go away. But never respond to a runaway error by turning the protection off or loosening its limits until you’ve checked the hardware: a loose thermistor, a damaged wire or a failing heater all look like that error, and the protection exists because they can cause fires. Our is 3D printing safe guide explains thermal runaway protection in more detail.
The "blob of death": plastic that leaked and wrapped the hotend.Photo: LunaEatsTuna ·CC BY-SA 4.0 ·Wikimedia Commons
Heater and thermistor wires run to the terminal block.
The bed controller: actual temperature, setpoint and material.
When PID tuning won’t fix it
If the tune fails, or the temperature still won’t hold after tuning, look for a hardware fault:
- The thermistor isn’t seated. If it sits loose in its hole, or its clamp screw is loose, the reading lags behind the real block temperature. Push it fully in and tighten the screw gently.
- A damaged thermistor wire. Wires that flex at the print head break inside their insulation. A reading that jumps by many degrees, or drops to a very low number, is the classic sign. Wiggle the wire carefully while watching the temperature.
- A weak or failing heater cartridge. If the hotend takes far longer to heat than it used to, or can’t reach high temperatures, the cartridge may be failing, or it may be the wrong voltage (a 12 V heater on a 24 V printer or the reverse is dangerous, so check before fitting a replacement).
- The wrong thermistor type in the firmware. If you fitted a different thermistor, the firmware has to be told its type, or every reading is off. That’s a firmware setting, not a PID value.
- A fan blasting the block. A powerful part fan aimed at the nozzle can cool the block faster than the heater can keep up. Fit a sock and check the duct.
- A loose or corroded connection at the mainboard or the hotend’s terminal block. Power off before checking.
- For beds: a bed that can’t reach its target in a cold room, or with a big glass plate, may simply need longer, or insulation underneath.
If you see plastic leaking out round the nozzle threads or coating the block, clean it and fix the leak before tuning, because the coating changes how the block behaves. See how to unclog a 3D printer nozzle.
The nozzle threads into the heater block.Photo: syvwlch ·CC BY 2.0 ·Wikimedia Commons
The mount that holds the hotend to the carriage.Photo: syvwlch ·CC BY 2.0 ·Wikimedia Commons
A V6-style hotend, cut away so you can see the filament inside.
The print head: extruder on top, finned heatsink, heater block and nozzle.
What to calibrate after PID
A stable temperature makes every temperature-sensitive test more reliable, so PID tuning fits early in the calibration order, right after the mechanical checks:
- Temperature tower. Now the temperature is steady, find the best one for your filament. See temperature tower.
- E-steps on older printers, then flow rate. See E-steps calibration and flow rate calibration.
- Retraction, which depends on temperature. See retraction test.
The whole sequence is in how to calibrate a 3D printer. If you’re not sure which part is the heater block, the thermistor or the heat break, parts of a 3D printer shows each one.
195 °C, 0.8 mm retraction: few strings.
210 °C, 0.8 mm retraction: few strings.
225 °C, 0.8 mm retraction: many strings.
Your action plan
- Decide if you need it: new heating parts, new firmware, or a temperature that won’t hold.
- Clean the block, fit the sock, check the thermistor is tight.
- Turn the part fan on to your usual speed.
- Run the tune at your usual temperature:
M303 E0 S210 C8 U1(Marlin) orPID_CALIBRATE HEATER=extruder TARGET=210(Klipper). - Save:
M500orSAVE_CONFIG. - Tune the bed too if your firmware uses PID for it:
M303 E-1 S60 C8 U1orPID_CALIBRATE HEATER=heater_bed TARGET=60. - Watch the temperature during a real print. It should sit within about a degree.
- If it doesn’t, check the hardware before tuning again.
FAQ
What does PID tuning do on a 3D printer?
It measures how your heater and its block heat up and cool down, and calculates the three values the firmware uses to hold the temperature steady without overshooting or wobbling.
How do I PID tune my hotend in Marlin?
Send M303 E0 S210 C8 U1, replacing 210 with your usual print temperature, wait for it to finish, then send M500 to save. Turn the part fan on first if you print with it.
How do I PID tune the bed?
On Marlin, M303 E-1 S60 C8 U1 then M500, if your firmware has bed PID enabled. On Klipper, PID_CALIBRATE HEATER=heater_bed TARGET=60 then SAVE_CONFIG.
How often should I PID tune?
Only after changing heating hardware (heater, thermistor, hotend, sock, or a fan that hits the block), after a firmware update that resets settings, or when the temperature stops holding steady.
Should I PID tune with the fan on?
Yes, if you normally print with the part fan running. The fan cools the heater block, and tuning with it on gives values that cope with that.
Do Bambu Lab printers need PID tuning?
No. Bambu printers don’t offer a user PID tune; their firmware manages the heaters. The same goes for Prusa’s MK4, MK4S and Core One, where Prusa says the stock values suit the stock heaters.
Can bad PID values cause thermal runaway errors?
They can trip the safety checks, for example when the fan pulls the temperature down too far. But a loose thermistor or damaged wire causes the same error, so always check the hardware before assuming it’s the tune, and never disable the protection.
What does M303 C8 mean?
Run eight heating cycles. More cycles give a steadier average; Marlin needs at least three and uses five by default.
Related guides
- Is 3D printing safe?: thermal runaway protection and fire safety.
- Temperature tower: the next step once the temperature holds.
- E-steps calibration: the other firmware calibration for older printers.
- How to calibrate a 3D printer: the full calibration order.
