Life hack: Add a PID temperature controller to your espresso machine


… does seem to be a fair question. In my case: The brew thermostat of my Rancilio Silvia died. Changing a thermostat is perhaps just as boring as fixing a flat bicycle tire. Adding a PID controller to an espresso machine however is good fun. Which must serve as a good explanation.

Good temperature control is claimed to give both higher quality and more consistent quality of your coffee shots.

The PID controller keeps a much tighter control of the temperature variations compared to the on/off thermostat control – as expected!

But I have to say that the Rancilio delivered superb quality coffee before the PID controller was installed – and it still does after the installation of the PID controller. So at least I didn’t break anything which to a certain degree is also a measure of success.

Please be careful if you disassemble any 220 volt device.

220 volts can and will kill you if you get in contact with live wires!

Unplug the device before you even remove the first screw!


Let’s have a look at the parts list

Parts List

PID cont.SSRTemp. sensorMiscellaneous
Basically any off-the-shelf PID controller should do just fine. Important thing is that it has solid state relay control (SSR) output and not current output since it will be driving a solid state relay (obviously). Looking 10 years back PID controllers were horribly expensive. Nowadays there are some pretty cost effective reliable models for sale on eBay. Actually at the same cost as a genuine Rancilio brew relay.

I chose a DIN 1/16 size since it then fits nicely into my espresso machine or alternatively into  a standard project enclosure so my wife and children are out of harms way when operating the machine. I.e. the 220V terminals are packed away and out of reach. The model I choose was a SESTOS D1S, but you may get even cheaper once.

SESTOS 1DS PID temperature controller
SESTOS 1DS PID temperature controller

There is much to say about PID control. Which I will not. There are plenty of resources elsewhere on the internet. I my self am an engineer and have sort of a basic understanding of what to tune in the controls to get a certain response (without being an expert in any way!). Luckily the PID controller will normally have an Auto Tune program which does a fair job in setting the control parameters. Try it out and if some fine tuning is still needed, in the case of unacceptable temperature overshoot or too long heat-up time, then consult here or drop a post or read further down and see if you get anything useful out of my PID “theory” section 🙂

You will want at least a 10 Amp Solid State Relay (SSR) which can take the net voltage 110-220V. They are cheap and reliable components. SSR’s does consume a bit more power (i.e. generates more heat) compared to electromechanical relay devices. It is not critical since it load it has to carry in your machine is only around 4 Amp for 220V installations. As far as I can see there is a specified voltage drop of 1.6V which must add up to 5.6W heat dissipated. It’s not much. I tried having it running for 2 hours lying on the table when I fitted the PID. it went no warmer than 30 °C… But make sure to install it in a fairly well ventilated space and not too close to other objects. Like wires and plastic shields etc. The SSR is best mounted on a metal surface.

25 Amp Solid State Relay
25 Amp Solid State Relay

One disadvantage of the SSR over your current mechanical relay is perhaps worth mentioning. SSR’s have a tendency to fail “shorted” on their outputs, while electromechanical relay contacts tend to fail “open”. This means that in the unlikely case of the relay failing then the boiler in your espresso machine will continue boiling even after the set temperature is reached. Have this in mind but don’t worry about it. SSR’s are known to as very reliable components.

As you see there are 4 terminals. 1 and 2 should be connected such that they power the heating element. I.e. connect them to the two wires attached to you existing brew thermostat. It does not matter which you put were as long as the two wires goes to terminal 1 and 2. Terminals 3 and 4 are the control input side. So they are for the PID to operate. Note that they have a + and – and this should correspond with the current output on the PID. for the SESTOS the terminals are SSR3 goes to PID8 and SSR4 goes to PID6.
On the advantage side you will have a completely silent relay when the SSR is in operation since there are no moving parts (no more “click-click” sound).

This is a (nearly irrelevant) discussion on it’s own. Several types of thermocouples exist but you just need one which is of the correct input type for your PID (see PID manual) and which covers the temperature range it is operating in. I chose a k-type sensor which was easy to mount and was available with a nicely insulated steel reinforced wire. The sensor type is a general purpose one which covers many applications more aggressive than an espresso machine mount so it will do just fine. As you see it’s response is also squat in the middle of the field when comparing the different thermocouple types available. But make your own pick. You coffee will taste the same I’m sure.

Thermocouple response overview
Thermocouple response overview
K-type thermocouple
K-type thermocouple

Note that you can cut off the end of the thermocouple and basically shorten it to any desired length. Just expose to two wires and twist hard them to ensure a good connection between them.

An important thing is the safety when you are dealing with 220V. So you need to make sure that all live wire terminals are well protected and out of reach. So you will need a casing for your PID control box. In my case I chose a DIN 1/16 size PID and measured out that it would fit inside the espresso machine. You may not want to cut a hole in your favourite household appliance! So alternatively you can mount it on the outside of the machine, but then put it in a project enclosure. These are readily available on eBay. The cut-out size for DIN 1/16 is 45X45 mm. If you find a box with an end plate a bit larger than this it is easy to unscrew the end plate. Make the cut-out and re-mount it with the PID installed.

Search the Electronic Components section on eBay for “project enclosures” and make your pick.

How is it all connected?

Some photos and drawings which may be of help if you want to try this out yourself:
click to enlarge

Connecting PID, SSR and thermocouple
Connecting PID, SSR and thermocouple
Connecting PID, SSR and thermocouple


The PID controller most likely have an auto tune program/feature. Let your espresso machine heat up for 30 min and then deploy the auto tuning. This lets the PID analyse the response of the system and set the gain or time parameters.

Try it out and see if you are happy with the result. In my own experience you will benefit from adjusting the parameters manually afterward. The main reason is that the auto tune wile most likely find the optimal set of parameters to include a good portion of integral action. Where this is a good thing to keep an almost undisturbed system stable it is not necessarily good for the system response you want of your espresso machine. When you press the brew button, cold water will flow to the boiler and the temperature will drop rapidly for a short time as you brew. Having a lot of integral action available in the control strategy will interpret this as a temperature which is offset even though heat is supplied. I.e. the integrated error will increase quite a lot during the seconds you brew. To make up for this, heat is supplied to the system until the error is again low resulting in a temperature overshoot of several degrees after each brew. This was NOT what you wanted. To avoid this set the integral gain/time low and compensate with differential instead. This worked for me. The temperature is at present time not quite as stable as it was using the auto tune parameters. But I manage with the +/- 0.7 °C temperature variations I’m seeing. Speed in getting to the set value and stable post-brew response is more important to me than +/- 0.1°C accuracy of the steady state temperature.

Enough silly talk about control strategy. You basically just wanted a cup of coffee right? 😉
So without further ado:

PID installed and ready to brew ;-)
PID installed and ready to brew 😉

29 thoughts on “Life hack: Add a PID temperature controller to your espresso machine”

  1. Hey!

    Having made the exact same setup as you, and thanks for the guide by the way, I’m curious to which settings you have altered and which values.
    I’ve run the auto tune, but, I’m also sing a rapid drop in temperature in brewing and somewhat time before the output signal goes high. But, I didn’t pay much attention for the short time I studied EE @ AAU so I’m basically lost on knowing what to do 🙂

    Thanks so much!

    1. I just recently installed a new boiler and learned that it altered the needed settings quite a lot. So it may be different for different machine versions.
      However I’m using:
      Integral M50 = 450
      Differention P = 226

  2. How did you fit the sensor in the boiler ? The tread from the sensor is more wide than the tread in this pre-2000 boiler(v1) ?

    1. Hi Ben,
      I put a little bit of thermal grease on the sensor and then simply tightened it under the brew thermostat on top of the boiler.

  3. HI,

    So when you set the machine to steam it bypasses the PID and goes to the steam thermostat?

  4. Thanks for publishing this page. It helped me installing a PID in my Silvia. I used Inkbird ITC-100V, K-thermocouple with 5mm washer and 25A SSR (all sourced from Ebay for ~USD$30). The Inkbird is the same as your Sestos.

    1. Sure.
      But 220 V times 25A is already like 5.5 kW. 40A would burn your fuse installed in the main switch board of your house installation first 🙂

  5. Hey, I’ve got the same setup.

    What PID settings are you using. I seem to have a long overshoot and want faster response, but can’t seem to get there.


    1. Yeah. There is a little issue here. The control settings cant really fit both the two common scenarios:
      1) Machine cold and warming up
      2) Machine already warmed up and you want to get back to the set point after brewing your coffee.
      I tuned the parameters of the PID according to scenario 2). Then I kranked up the parameter for the differential term since that is probably the most effective to avoid overshoot.
      It performs nicely during 2) but it IS admittedly slow during 1).
      Not much to do about it… unless 😀
      You install a Raspberry Pi and code up a PID control loop for each scenario. My wife has pulled the plug on that project though 🙁

  6. Hello, Thanks for the clear explanation!
    A also want to install a pid controller on my Rancilio V2.
    I want To use :
    With a SSR-25
    You are using the K-type thermocouple.
    You are explaining. ,,I put a little bit of thermal grease on the sensor and then simply tightened it under the brew thermostat on top of the boiler.”
    Did you shorten the sensor?
    Do you have A picture for me.? I don’t know exactly what you mean. Sorry for my bad writing I living in the Netherlands.

    Greetings Nanne

    1. Hi Nanne,
      I did not shorten the sensor, it fitted as it is. I did calibrate it with a known thermo sensor (i.e. adjusted the offset in the PID setting. Not the gain).

  7. Hey kuhlmeier

    So I bought the espresso machine now.. won’t you come by and do the magic? I’ll even buy you a beer if you additionally train a NN running on Coral learning if the brew was good or not and adjusting the parameters accordingly

    – Alejandro

    1. Funny enough that’s exactly what I intended with that hack! To travel the world and adjust people’s espresso-machine-PID-parameters. You got it mate! As soon as we get through this corona situation 🙂

  8. I’m going to attempt to replace the PID on a 2nd hand Sanremo Treviso LX (HX, E61 with rotary pump) which I’ve just acquired.
    Sanremo appear to have replaced the mechanical pressure relay controlling the boiler temp with a microcontroller PID, in the last revision, that has a set of DIP switches. No one will tell me how to configure them. I’ve tried everyone incl Sanremo.

    My only concern is that the manufacturer’s thermocouple is surface mounted, which is easy to replace, but I see my machine hit 2.5bar when switching on from cold, finally settling down after 10mins around 1.25->1.5 bar which is too high.
    It’s manual says 0.8-1b.
    Can’t turn it down because no one will tell me how to!
    Your post here gives me a nice solution, rip it out and replace it!

    I’m assuming you surface mounted that K type thermocouple on top of the boiler?
    I just don’t have the nerve to drill a hole into my boiler to take a direct reading. 🙂 Do you have any trouble with over shooting the boiler pressure on cold start?

    Also I tried to find a PDF manual online for the Sestos 1DS but couldn’t. Did yours come with a manual? I’ve ordered one from a Chinese re-seller on EBay, hoping it has some instructions with it.

    1. Hi George.
      Overshooting is a bit of an issue when I have made the first brew. The temperature drops rapidly during brewing because cold water is being infused in the boiler. The best fix I have come up with is to auto tune the parameters after the warmup/brew cycle and then decrease the integral gain. I.e. not putting so much weight on the integrated set point error from the temperature drop.

    2. A common advice for many (most?) E61-group machines is to allow ~30 minutes for warm-up. After 10 minutes, the boiler may be up to temperature but the group most probably is not yet.
      In this regard, the raised boiler pressure (and temperature) might be a feature, not a problem, to speed up the group head’s warm-up.
      Therefore, consider to re-check the boiler’s temperature/pressure consistency only after 40+ minutes, when you are sure the warm-up is complete, before you throw out a possibly well-tuned PID.

      (This is merely a general advice. I never touched any Sanremo machine.)

    3. An update after 5 months; Thought it would be worth sharing what I learned about this machine incase anyone else with one came here after finding it on Google.
      I did finally sourced the data sheet on the PID in the Sanremo Treviso. It’s made by GICAR in Italy and is called a “Termosteco PID”. The 8 way DIP switch is split into 2 parts. The lower 6 Bits/Switches is a binary representation of the desired temperature. The 7th and 8th bit/switch tells the PID what size of boiler it is controlling. All on is small, 01=medium, 10=large and all off is “generic”. I’ve found generic and medium work just as well on the Treviso.
      The real winning trick with this machine though is to reduce the size of the hole in the thermosyphon restrictor valve from factory 3mm to 2.5mm. That alone makes a dramatic change to flavour and consistency. I did it by putting copper wire in the hole bent over at each end to keep it in place.
      I’m going to stick with the GICAR PID for now. It does the job. Anyone in NZ need a SESTOS 1DS PID? I’ve got one spare now, unused. 🙂

  9. Thanks for posting this. I’m about to install a PID in my Silvia and like your idea of mounting it in the machine instead of hanging it between the GH and steam wand. But I’m concerned about heat effecting the PID. Has this been an issue?

    1. The same PID is actually still running.
      In conclusion, no heat has not been an issue. I run at 93 deg C.

      1. Noted Thanks, for the SSR 40A can i change it to 25A,
        Elektra sixties T3 output @3700 watt

Leave a Reply

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