Your 3D printer is a precision machine and needs to be finely tuned to get the best results.
PID tuning in 3D printing can be an essential part of ensuring a quality print and maximizing the potential of your machine.
This article is a compact guide to PID tuning your printer using the two most popular firmware, Marlin and Klipper.
Both Marlin and Klipper are open-source firmware programs, which means that code and basic structure can be changed to suit the needs of the user.
This is why almost all 3D printer manufacturers use one of these programs to run their machines.
So, let’s take a closer look at what we’re talking about.
How Does PID Tuning Work in 3D Printing?
One question you may be asking is “what is PID tuning?”.
PID stands for proportional-integral-derivative and relates to how you set your printer to handle temperature adjustments of the hot end and heated bed.
So what does each of these terms mean?
- Proportional – This is the percentage of the current temperature compared to the target temperature.
- Integral – This measures the historical error of the heating process and how it worked in previous heating cycles. Adjustments are then made to ensure future heating is consistent.
- Derivative – A 3D printer uses “reprap” heating, which tries to keep the temperature at a constant. The derivative measures how quickly the heat above and below the target changes.
These are very brief descriptions of what PID means, and more information can be found in our article
The basic way that PID works in terms of your 3D printer is that you’re using it to find the machine’s best heat settings. A line of code is added to the firmware (either Marlin or Klipper) that runs through the PID process in order. This then returns results that are needed to enter a new line of code and therefore save the settings to the firmware.
We’ll look in a bit more detail at how to do this further.
Importance of 3D Printer PID Tune
Incorrect temperature settings and changes in heat during printing can adversely affect the end product of your printing endeavors.
Problems can occur such as blockages, under or over extrusion, stringing, and so on.
The importance of the correct heat settings relates to both the hot end and the heated bed.
The nozzle and the bed need to maintain a constant temperature to avoid the issues we’ve discussed.
For example, if the particular filament you’re using recommends a working temperature of say 190°- 215 °C, then you may want to set your hot end to 200 °C.
The heated bed similarly will have a recommended temperature range, say 50°- 70 °C, so you could go for 60 °C for good measure.
While printing, you don’t want either of these temperatures to fluctuate by more than 1 degree, so the correct PID setting will ensure that doesn’t happen.
The benefits to the success and quality of your prints will be apparent if you get the PID settings right.
How To PID Tune a 3D Printer
OK, we’ve looked at why it’s important to have correct PID settings for your 3D printer, so let’s now have a look at how to do it.
Before you start to try to get into Marlin and change things around, you’ll need to download another piece of software to help you.
This is what’s known as a “G-Code Terminal” and allows you to view and manipulate the “inner working” of the program.
One such terminal is Pronterface, but you could also use Octoprint or another similar program.
Marlin
As we’ve discovered, PID tuning covers settings for both the hot end and the heated bed.
Each of these will have a different command defined in a line of code which can be changed within the program.
So let’s briefly go through the steps you’d take to set PID for both hot end and heated bed.
Hot end
In this example, we’re going to use Pronterface and set our hot end to 200 °C

1. Open Pronterface: You should then be able to connect your printer to your PC/laptop, and the firmware (Marlin) will be visible at the bottom of the screen.
2. Enter the PID settings: In order to do this, you’ll have to find the line of code in this format: M303 E0 S200 C8.
The “M” relates to the Marlin command, “E” is the hot end (Proportional), “S” is the temperature (Integral) and “C” is the number of times the temperature cycles round the target to measure accuracy (Derivative).
3. Send the command: You need to send the command to the printer in order to allow it to run its tests.
Once done, you’ll receive the results of the PID test, but each figure will be prefixed with a “K” (KP, KI, KD). These results now form your new PID settings and need to be sent back to the printer.

4. Send the new PID settings: This time you’re going to prefix the figures with “M301” so that Marlin recognizes the changes.
5. Save the changes: A common mistake is that users forget to save their work, so remember to do this by adding an “M500” and sending that to the printer as well. The PID settings for the hot end will now have been completed.

Heated Bed
The heated bed follows a similar process, but with some slight variations.
This time, we’re going to set the bed temperature to 60 °C.
1. Open Pronterface: It’s likely you’ve already done this, but the process is the same.
2. Remove “PRINTBEDTEMP” command: This is a key step, as your settings will have no effect otherwise. Find the line with this command and remove the “//” in front of it. This basically “uncomments” the command and stop it working.
3. Enter the PID settings: The “M303” command still applies, but the designator for the heated bed will be different. So, the command this time will be: M303 EBED S60 C8.
The PID parameters are the same here as for the hot end.
4. Send the command: This would be in exactly the same way as for the hot end and the results would be returned in the same format.
5. Send the new PID settings: This is done in the same way, but this time using a “M304” prefix.
6. Save the changes: Again, use the “M500” command.
So, that’s a basic run through of how to PID tune your 3D printer using Marlin. Now let’s move onto how you’d do this using Klipper.
Klipper
Klipper is a slightly different animal compared to Marlin but performs the same functions.
Whereas Marlin, firmware is added directly to the mainboard of your printer and runs everything from there; Klipper operates slightly differently.
Instead of being added to the mainboard, Klipper operates on a separate computer, such as a Raspberry Pi.
This allows for faster operating speeds as it frees up space on your printer’s mainboard.
Obviously, as Klipper is a 3D printer firmware, it will have the option to adjust PID settings.
The method of doing this is still quite simple but completely different from Marlin.
So, let’s see how we go about that in Klipper.
Again, in this example, we’re going to use Pronterface and the settings of 200 °C for the hot end and 60 °C for the heated bed.

Hot end
1. Open Pronterface: Your printer should already be connected to the Raspberry Pi, but to use Pronterface, you’ll also need to connect it to a PC/laptop.
2. Send “TURN_OFF_HEATERS” command: This allows both your hot end and heated bed to cool to ambient room temperature.
3. Add the PID command: This is done by typing “PID_CALIBRATE_HEATER=extruder TARGET=200”. As you can see, the hot end is named as “extruder” and the temperature is 200 °C.
4. Send the command: This starts the PID tuning process and requests the results from your printer.
You’ll notice that no number of cycles was set as we did with Marlin, but Klipper will automatically conduct the required number to achieve the results.
5. Receive and save the results: You’ll receive the results back in a similar format to Marlin but like this; “pidKp, pidKi and pidKd”.
These results then need to be sent back to your printer using the “SAVE_CONFIG” command and adding the new settings.
6. Restart your printer: This is to ensure that the update has saved and is now configured to your printer.
The process therefore is pretty similar in performance and results to Marlin but just a different way of sending and receiving commands.
Heated Bed
The process for applying PID to the heated bed in Klipper is exactly the same, so we won’t go through each step individually again.
The only difference you need to note is the PID command will be “PID_CALIBRATE_HEATER=heated bed TARGET=200”.
Frequently Asked Questions
Of course, with anything that you may be unfamiliar with, you’re going to have questions.
It wouldn’t necessarily be possible to answer all of these in what is essentially a one-sided conversation!
However, there are some frequently asked question or FAQs that have come up in the past. Let’s see if we can answer some of those.
What temperature is needed for PID tune?
With Marlin, it’s not necessary to cool your printer, and it can be set to your target temperatures if you wish.
Klipper however, requires the printer heating elements to be at ambient room temperature before starting the PID tune.
How many cycles does it take to tune a PID?
The minimum recommend is three cycles in Marlin, but the default setting is usually around five. As our examples illustrate, we’ve used eight cycles, but you can go as high as ten or twelve.
Klipper employs a “it takes as many as it needs” approach and will cycle until it gets enough data to provide results.
How long does a PID tune take?
With Marlin and our example of eight cycles, it should only take 5–10 minutes for either the hot end or the heated bed.
Klipper can take anything from 5 minutes up to a couple of hours depending on how many cycles it chooses to take.
What happens if a PID is not properly tuned?
As we’ve discussed, the importance of PID tuning can mean the difference between success and failure of your prints.
An additional point to note here would be the potential waste of filament and energy if your printer isn’t operating to its full potential.
Final Thoughts
We’ve briefly gone through the basics of PID tuning your 3D printer using two of the most commonly used firmware programs on the market.
Hopefully this article will help you get the right PID settings for your printer and, in turn, avoid as many failed prints as possible.