Calibrating the Pressure Sensor to match the Pressure Gauge on my Espresso machine

Some time ago I fitted both a mechanical pressure gauge (shown in the photo below) and an analogue pressure sensor (Danfoss AKS 32R) to my Gaggia Classic. The analogue sensor is connected via an ADC board to a Raspberry Pi, which displays the output on an LCD display. Calibration is needed to make the sensor reading match the gauge exactly.

Pressure Gauge

When I first installed the sensor, I used an approximate calibration as shown in the pseudo-code below:

minVoltage = 0.5V
maxVoltage = 4.5V
maxPressure = 20.6842719 bar (300 psi)
voltage = pressure sensor voltage (measured by ADC)

voltageRange = maxVoltage - minVoltage
bar = maxPressure * (voltage - minVoltage) / voltageRange

Although this was only based on the sensor specifications, it actually gave surprisingly good results. There was only about 0.5 bar difference between the gauge and the pressure sensor (the sensor always read slightly higher than the gauge). Nevertheless, I decided to calibrate the sensor against the gauge (on the assumption that the gauge was more likely to be correct). Absolute accuracy isn’t really critical, but I wanted them both to show the same values.

To calibrate the sensor, I took about 20 simultaneous measurements for the gauge and the sensor and plotted them in Excel as an X-Y chart. This isn’t as easy as it sounds, because the readings need to be taken when the pressure is fairly stable. After running the pump, it takes a while for the pressure to slowly reach equilibrium, and that’s when you need to very quickly take a note of both values! It’s also difficult to read figures very accurately off the gauge.

These measurements gave a reassuringly good straight line fit (below), which suggests that both the gauge and sensor have good linearity. Using Excel, I then added a trend line to the chart and read off the scale and offset values directly (Excel has an option to display the equation), as shown below.


To correct the pressure sensor reading, the value is scaled by the reciprocal of 0.9385 and the offset 0.829 is subtracted. These parameters are stored in a configuration file, so they can be easily changed if required.

This simple calibration process worked out really well and means that the pressure sensor readings displayed on the LCD (and stored in the log files) now match the mechanical gauge exactly!

Leave a Reply

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