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.

4 gedachten over “Water pressure sensor for Raspberry Pi”

  1. Hi Ger,

    Just started an interesting project, home control based on the Z-wave protocol. A Vera Plus controller with some switch devices for lights, electric fan in my cellar (fresh air) and also for my electric boiler in the bathroom (upstairs). This boiler switch also monitors the used power.

    Nice to be able to have lights switch on and off based on sunrise and sunset. Also with time offset if wanted.

    The devices are wireless controlled ~ 800 [MHz] with enough range in my house (no concrete floors or walls).

    Still investigating the power measurement and the possibility for graphs etc. This needs additional apps in the controller webbased software.

    Also possible to tease Tiny by switching lights on and off with the app on my phone (from my work). I don’t think she will understand although I have tried to explain this home control.

    Only looking for usefull application of this. It seems that a lot can be connected like smart energy meters (which I don’t have), safety camera’s, several sensors, etc. I will see and tell you.

    Greetings,
    Jeroen

    1. Hi Jeroen

      there are public domain software packages and applications that can be used to monitor your devices as well as graph their state as a function of time for instance. I myself use FHEM for the heating stuff and have Domoticz for the lights. The weatherstation is largely developed by myself but I do use the Wunderground services. The Z-wave protocol was not yet there when I started so I have only one device that I still need to put to use: a sensor to register electricitiy meter ticks. The plan was to connect that to the solar panel meter I installed quite some time ago.

      Useful applications: the weatherstation proved the most useful so far. But monitoring water pressure and temperature of my solar heaters is also useful: good to be warned when pressure goes low. Light switches are also useful: during holidays I once noticed to have forgotten to switch off some lights: could do that remotely later.

      Ger

  2. Thank you for sharing your experiences in this article. I am searching for way of monitoring pressure for spunding beer fermentations. Hoping to be able to incorporate a one-wire signal from pressure sensor/DS2438 along with the existing DS18b20 signals to a Brewpi/Fermentrack for remote monitoring and control. How would I get a copy of the “little C program” you mention in your article?

    1. Dear Allan, thanks for your interest. The idea exposed in the text you refer to will work but not optimally I found out. Reason is probably that too little current passes through the pressure sensor; it has been made for amperes not for microamperes. There is a better solution though. It is pressure sensor that immediately can be used with an ADC, such as also in the DS2438. They go under the term “G1/4″ inch 5V 0-1.2 MPa Pressure Transducer Sensor Oil Fuel Diesel Gas Water” and are offered at Ebay for a decent price. The other advantage is that you convert a voltage with the DS2438 for which there are many programming options available on the web. The applied voltage can also be measured with the DS2438 so that the whole measurement can be made supply voltage independent (within limits). At some point I will write down my experiences on this but at the moment my interest is distracted in other directions.

Geef een antwoord

Het e-mailadres wordt niet gepubliceerd.