PID Thermostat For The Arduino

kerinin arduino thermostat

PID Thermostat

This is a PID thermostat for the arduino. It supports independent tuning parameters for multiple hardware ‘profiles’, and includes an autotune mode to estimate the PID parameters for a given setpoint.



  • DS18-series (I’m using the DS18B20) temperature sensor
  • Solid-state relay rated for your power source
  • 16×2 LCD display (I’m using the LCD-09052 from Sparkfun)
  • 4 buttons (I think mine are normally closed)

kerinin arduino thermostat

There’s an arduino shield designed specifically for this sketch which can be ordered for around $25 on BatchPCB. The fritzing source files for the PCB layout are in the fritzing directory.


sudo pip install ino
brew install picocom

Other OS’s will have their own picocom install process. Picocom is only really necessary if you want to use ino serial. I prefer to use screen /dev/, FWIW.


# get it
git clone ./
cd arduino-thermostat
git submodule init && git submodule update

# deploy it
ino build
ino upload


You’ll want to take a look at the pin settings and either adjust your wiring to match or change them to reflect your hardware.

The up & down buttons cycle through the settings menus, the left & right change values. Set your setpoint and it should start driving the SSR

If you’re seeing lots of oscillations or periodic temperature spikes followed by long ramp down times, try running an autotune cycle. This works by pushing the power to 100% and waiting for the temperature to go outside a temperature band around your setpoint (controlled by the ‘Tuning Range’ parameter). It then drops the power to 0% and waits for the temperature to fall below the temperature band. Rinse and repeat until a ‘stable’ oscillation develops, at which point the PID parameters are set based on the amplitude and frequency of that oscillation.

The PID and autotune features use the awesome PID and PID_Autotune libraries by Bret Beauregard. For more information on how they work take a look at this post about the PID library and this post about the Autotune library

kerinin arduino thermostat Schematic


Please do! Fork the repo, make some changes and send me a pull request!

Future Directions

  • on/off switch
  • I’d like the temperatures to ramp from their current value to the target value over some time period based on the tuning parameters. This should reduce oscillation and overshoot.
  • Refactor the different files into self-contained classes. (Stop sharing global state!!!)

Read more: PID Thermostat For The Arduino

Leave a Comment

Your email address will not be published. Required fields are marked *