It's the 21st century, anything is possible. Except for PID autotuning for a simple problem, heating/cooling system - make robust and ready to use solution. I've found only one library for PID autotune: https://github.com/br3ttb/Arduino-PID-AutoTune-Library, but even its author says that it is not a robust approach. My question is:

  1. What types of algorithms for PID autotune for a simple heater/cooler application exists? What are their pros and cons?
  2. Is there some open-source libraries for PID autotune?

3 Answers 3


First of all, I'm not an expert, but I'll try to give you basic answers listing all that I know as state-of-art. Also, I'm going to update the data with the feedback that people can give or adding new technologies developed.


Popular methods for tuning:

  1. Manual tuning: Stability
  2. Ziegler–Nichols
  3. Tyreus Luyben
  4. Automatic tuning: software tools
  5. Cohen–Coon
  6. Automatic tuning: Åström-Hägglund
  7. Harris Hawks Optimization Algorithm

Automatic tuning:

  1. (Newest) Neural networks: read-paper-1 read-paper-2
  2. Deterministic Q-SLP Algorithm: read paper
  3. Particle swarm optimization algorithm: read paper
  4. Genetic algorithm in C++: review library
  5. Bio-Inspired Multiojective Tuning: read paper
  6. Loop optimization software: open loop, closed loop control and references.
  7. Calculates initial values via the Ziegler–Nichols method automatically.
  8. Patented methods embedded on PID tuning softwares like Matlab. Check all until 2006
  9. Loop optimization software for Non-steady stable models.

Open-source softwares to autotune:

  1. Arduino library that you mentioned.
  2. Python: GEKKO view demostration
  3. Python: based on arduino-library view library
  4. Web based on arduino-library: open online tool

Other softwares:

So, You need to choose the simplest based on your requirements. You may try with Ziegler–Nichols. Also you can check this paper: (2017)"Designing a neuro-fuzzy PID controller based on smith predictor for heating system".

References: (2006) Autotuning of PID Controllers: A Relay Feedback Approach.


Marlin firmware has an autotuning algorithm, so you could either upload marlin to your board, or hook up a dummy board with marlin on it -> autotune -> get PID vals, and then apply them to the code that you're writing (although be careful for unaccounted problems between the two boards -operating voltage differences, etc.)

or implement the marlin PID_autotune source code to your project:


or here https://github.com/MarlinFirmware/Marlin/blob/f9db5ab965f39c594029301d20358cc7150f233a/Marlin/src/module/temperature.cpp#L660


Perhaps you're interested in a PID alternative such as Model Predictive Temperature Control support (MPC). Marlin (3D printer firmware) has the ability to use MPC instead of PID for the extruder temperature control.

Model Predictive Control (MPC) takes a different approach. Instead of trying to control against the measured temperature, it maintains a simulation of the system and uses the simulated hotend temperature to plan an optimal power output. The simulation has no noise and no latency, allowing for nearly perfect control. Thus it can compensate directly for extrusion speed and part-cooling. To prevent the simulated system state diverging from the actual hotend state, the simulated temperature is continually adjusted towards the sensor measurement. Although this does introduce a little noise and latency into the simulated system, the effect is far smaller than for PID.

That quote is from this very comprehensible article about MPC here: https://marlinfw.org/docs/features/model_predictive_control.html.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.