Water pressure sensor for Raspberry Pi

A pressure sensor is a necessary part of any pressurized liquid system such as a solar boiler, the central heating system in a house and even a car. In all these systems it serves as a monitor on the well being of the system, in particular whether the liquid is still inside or whether there is a leak. Typically, it comes in the form of a pressure gauge somewhere attached to the tubing of the system. Only very recently are there electronic readings and this is usually for a central heating system. But solar boilers are also useful to monitor, just because they are more exposed to extreme weather conditions, and so the idea was already for a long time to install such a device.

But which one to take? The simplest form of such a sensor is a switch that opens when the pressure is above a given minimal value. These are found in the more normal cars, only fancy cars have a more involved one that actually gives a value for the pressure. Whether oil or (cooling) water pressure sensor, both are of the membrane kind because that gives the most rugged form. They are typically provided by VDO but sometimes cheaper look-a-likes are also available. They are frequently offered at a significant discount at Ebay. The membrane separates a pre-pressurized compartment from the compartment of which the pressure has to be taken. The membrane in-between deforms with the pressure difference and this is recorded by means of a strain gauge attached to the membrane. Typically the resistance of the strain gauge varies about 20 Ω per Bar.

Such resistance values are fine for car-applications. The moving coil meter that is usually attached to it through battery power will have a relatively high current to control its position and hence it remains relatively insensitive to vibrations. But for electronic applications it is not so easy as it means high currents that are not available from the RPi or the like of credit card computers. This calls for a special solution that took some while to be found.

First the selection of the pressure sensor itself. The solar boilers do not have a lot of water in them, 5 – 10 liters typically. The solar boiler also contains a pressure vat, a pre-pressurized compartment in contact through a membrane with the system liquid. The vat does not need to be big for a solar boiler, 8 liter is the smallest I could find though. It is pre-pressurized at 0.5 Bar. The bigger ones are at 1 Bar. The function of the vat is to compensate for the volume changes of the water during heating and cooling. To do so, the pressure should go at 1 Bar for the 0.5 Bar pre-pressurized vat. It then has the range from 0.5 Bar up and down to vary the position (and shape) of the membrane while heating or cooling. So, the set value at 20 ° C is 1 Bar and during operation and during outside temperature variations it may vary between 0.5 and 1.5 Bar. The latter are extreme values but possible. The maximum pressure in the system is set by a valve at 2.5 Bar. This will only be reached for instance when the pressure vat malfunctions (leaking membrane). Summing up: a pressure sensor is needed from 0 – 2.5 Bar with a good accuracy around 1 Bar.

Other conditions on the pressure sensor? Most have one of the two strain gauge contacts grounded. This is a good idea for cars where the instrument mass can serve as conductor: it saves wiring. For a microcomputer connection it is not so smart, so try to get one with free contacts (massless) to achieve galvanic isolation. The one that would be preferred (and available) is a VDO 360-081-032-NNNC that can be obtained with various couplings depending on the threading used in your system (different values for NNN). They are not cheap, of the order of 50-100 euro, but they are not expected to break down easily. If they do, there is a guarantee. A word aside on nomenclature: one will find pressure sensors under all kinds of names (Druckgeber, sender, Druckabnemer, etc.) neither of which is particularly appropriate so be prepared to select broad keywords to locate a decently priced item.

How to interface them. Because of the low currents available and the low resistance values offered by the strain gauge, one needs an analog-to-digital converter (ADC) that is capable of converting a small voltage, say 250 mV, to a minimally 8 digit number for accuracy. Interestingly, this is what the DS2438  Smart Battery Monitor by Maxim Integrated delivers. It has two ADC inputs, one for the higher battery voltages and one for the battery current measured across a small resistor (necessarily to avoid excessive loss due to the measurement itself). The chip has 1-wire interface that combines with temperature sensors of the type DS18B20, also from Maxim Integrated. The required electronic circuitry is minimal and in actual fact only requires either a current source or a (relatively) large resistor in series with the strain gauge. In the latter case some a-linearity is introduced that, as it is monotonic, can be corrected for. Using the simplest scheme with a resistor R from the strain gauge to the supply voltage of 3.3 Volt, the resistance Rg of the strain gauge is derived from the convertage voltage V as

Rg = (V / 3.3)*R

and with the calibration curves given for the pressure sensors one can then compute the pressure.

Where the temperature sensors DS18B20 are well provided with software drivers, the DS2438 unfortunately is not. The Python software that exists for the Raspberry Pi is just crappy. So I made a little C-program to take the value from the pressure transducer. Those interested can approach the author for a copy. When using programmed I/O, which is the simplest to implement, the data loss is something to worry about. But since taking a sample is so fast, there is no problem to repeat the reading procedure a few times until a sample has been successfully read. A more reliable procedure uses a UART (serial interfacing circuit) but then requires a little more hardware.

The pressure and temperature sensors are installed for a few weeks now and perform satisfactorily. I will install another one with my other solar heater system soon.


Een kuil, busjes met mannetjes en een hoop. In een wip hebben ze een enorme kuil in de weg gemaakt om dan vanaf de rand hun werk te bestuderen.

Er is minstens een busje. Ze hebben nu eenmaal een busje, dat hoort bij hun uitrusting.

De berg van zand en stenen komt uit de grond. Daar blijft na afloop van de klus nog wat van over. Daar gaan mijn mannetjes niet over. Maar nog maanden later kun je zien waar ze bezig zijn geweest.

Ik vraag bijna steevast of ze de schat al gevonden hebben. Ik moet de vraag vaak herhalen, want het lijkt niet tot ze door te dringen. Meestal schudden ze daarna meewarig nee maar er was er laatst een die meldde: nee, we moeten dieper!