tyler/ May 21, 2019/ Brewing Hardware, Electronics, Engineering/ 0 comments

Before the hiatus, I made an attempt at creating a Continuous Fluid Density Sensor. Here are the primary components:

  1. Two dip tubes in the fermenter
  2. MPXV7002DP differential pressure sensor
  3. ADS1115 16-bit analog to digital converter
  4. Generic, chrome plated brass, 2.5 mm hose barb to M3 adapters and 2.5 mm pneumatic hose
  5. Generic 12V aquarium diaphragm pump (model no longer listed on eBay)


The first step was to install new dip tubes into the fermenter. These are just two tubes in the tank that terminate with their openings directed downward. They are connected to cam-lock adapters on the outside of the tank for attachment to hoses.

I also wanted the portions of pipe inside the fermenter to have as few recesses as possible to limit contamination by undesirable microbes. I soldered the NPT stainless fittings using acidic flux (I used Stay-Clean). The 1/4″ stainless tubing connects through a compression fitting. These leaves less room for leaks and microbes.

Now that we have dip tubes between which to measure the pressure difference, the first step in design is to calculate the expected difference in the pressure at the tip of each tube. The difference in their heights is approximately 15 cm. The conversion between Pascals and centimeters of water is 98.0665 \frac{Pa}{cm H_2O}, so the differential pressure between the two tubes due to a column of water is:
\Delta P_{H_2O}=15 cm H_2O \cdot 98.0665 \frac{Pa}{cm H_2O}=1471 Pa

The original gravity for a generic pale ale is approximately 1.05, so the differential pressure at the beginning of fermentation would be:
\Delta P_{Initial}=1.05 \cdot \Delta P_{H_2O}=1544.5Pa

The final gravity for a generic pale is about 1.011, so the differential pressure at the end of fermentation would be
\Delta P_{Final}=1.011 \cdot \Delta P_{H_2O}=1487.2 Pa

And finally, the change in the differential pressure is \Delta P_{Initial}-\Delta P_{Final}=57.4Pa.

Copper 1/2″ male NPT x 1/2″ male NPT with a 2.5 mm hose barb soldered in.

The dip tubes need to be connected to a differential pressure sensor. The pressure sensors in the price range for this application connect via 2.5 mm pneumatic hose, but there are no adapters between pipe fittings (what I use in my brewery) and this diameter hose. So, I made adapters by taking a short length of 1/2″ NPT copper pipe and soldering a brass hose barb into it. The plating on the brass interfered with the soldering, so grinding down the threads on the barb before soldering was necessary.

Diaphragm Pumps

Lastly, the dip tubes will have a tendency to fill with fluid. Measuring the differential pressure will require a means to push the fluid out and fill the tube completely with gas. That’s accomplished with two diaphragm pumps. These simply take gas from the top of the fermentor and push it through the tubing leading to the dip tubes.

Diaphragm pumps with fermenter vent connected to their inlets and each dip tube connected to one of their outlets.


This device is a differential pressure sensor. It operates at 5V and outputs an analog voltage between 0.5V and 4.5V that is proportional to the pressure detected by the device. Specifications dictate that this device detects a -2.0 kPa to 2.0 kPa range at 2.5% average and 6.25% maximum error. The first question is whether this is a significant error.

At a range of 4000 Pa, the average error is 100 Pa and the maximum error is 250 Pa. This is an immediate, obvious problem. In fact, I wonder whether I had an error in these calculations when I was initially making this design. Our average error is twice the change we are trying to measure. While this certainly looks bad, it’s worth further investigation. The datasheet does offer more information on the nature of this reported error:

Linearity: Output deviation from a straight line relationship with pressure over the specified pressure range.
Temperature Hysteresis: Output deviation at any temperature within the operating temperature range, after the temperature is cycled to and from the minimum or maximum operating temperature points, with zero differential pressure applied.
Pressure Hysteresis: Output deviation at any pressure within the specified range, when this pressure is cycled to and from the minimum or maximum rated pressure, at 25°C.
TcSpan: Output deviation over the temperature range of 10° to 60°C, relative to 25°C.
TcOffset: Output deviation with minimum rated pressure applied, over the temperature range of 10° to 60°C, relative to 25°C.
Variation from Nominal: The variation from nominal values, for Offset or Full Scale Span, as a percent of VFSS, at 25°C.

MPXV7002DP datasheet

This means that there are only a few kinds of error introduced into the measurement, and we can understand when to expect variation in the measurement.

  1. TcSpan and TcOffset: Pressure measurements will change with the temperature of the device, even if the pressure to which it is exposed is not changed.
  2. Temperature and Pressure Hysteresis: Pressure measurements will change if pressure or temperature are cycled, even if they are returned to their original values.
  3. Linearity: A predictable error in the pressure measurement that occurs because the model of how pressure and the signal from the device are related is inaccurate.
  4. Variation from Nominal: A predictable error that occurs due to things like inaccuracy in the calibration.

The good news is that two of these types of error will at least be consistent, which is the most important thing. The goal is to measure a change in the differential pressure over time, not to measure the differential pressure accurately. The error may be large, but the device may accomplish its goal if the error cancels out by either being constant. At the very least, it’s worth a try!


The MPXV7002DP emits an analog signal that is proportional to the pressure difference is measuring. The signal ranges between 0.5 V and 4.5 V.  Using this signal in software running on a microcontroller requires converting it to a digital number. This is accomplished by an analog-to-digital converter (ADC).

The ESP-8266 and ATmega328P both have on board analog-to-digital converters, but these only provide 10-bit resolution. Since the MPXV7002DP only uses 90% of the range from 0V-5V, the resolution of the pressure reading will be:
2^{10} \cdot 0.9 \cdot 4000 Pa = 4.34 Pa

This means that no matter how accurate the pressure sensor is, the output will jump in 4 Pa steps. This is about 7% of the pressure difference that should be measured. Since we’ve already determined that we’re going to be relying on a trend in the data to determine when the density of the fluid is no longer changing, this isn’t that bad. But who wants to look at 4 Pa increments?

The ADS1115 device is a 16-bit analog to digital converter. That will give us a resolution of:
2^{16} \cdot 0.9 \cdot 4000 Pa = 0.07 Pa

The increased precision will not mean much, but won’t it be pretty?


Here are the electronics.

It’s obvious from the state of the project box that I had two problems with the initial design.

First, the 5V regulator couldn’t deliver enough instantaneous current to power the pump transistors and the microcontroller simultaneously. The solution was to add an additional switching power supply.

Second, the MPXV7002DP is a 5V device while the ESP8266 is a 3.3V device. The ADS1115 can operate at a wide voltage range, so is compatible with the MPXV7002DP, but its voltage must then be shifted down to communicate with the ESP8266. This only requires a clever configuration of transistors, but I wasn’t clever enough. My on board voltage shifting didn’t work, so I had to rip it off and solder on a separate module that had previously worked in testing.

After these two modifications, the microcontroller successfully booted and functioned appropriately. I installed a modified version of my fermenter software on the microcontroller, my Raspberry Pi, and my PC, and gave it its first test run after a brew day.

Initial Results

Initial results were terrible. The performance of this device flew right past embarrassing to land firmly on ludicrous. There were two major problems.

The microcontroller software was a modified version of my fermenter software, so it took a pressure measurement every second and sent it to the server. Every hour it would turn on the diaphragm pumps for a few seconds to clear any fluid that had gotten into the tube. Unfortunately, the differential pressure plummeted immediately after the pumps turned off. This would suggest a rather brisk leak in the tubing leading to the lower dip tube. With a full second interval between pressure measurements, the pressure varied wildly. There would be no detection of a subtle trend with this new error introduced. Leak testing would be necessary, but this wouldn’t be easy. Testing for leaks would require pressurizing the system and then submerging in water or spraying it with a soap solution to look for bubbles. Unfortunately, several parts are inside the fermenter and several others are connected to electronics, so this will be a meticulous job, especially where the pneumatic tubing connects to the pressure sensor. Additionally, one second data resolution will likely be inadequate. This would require a larger modification to the software than I was hoping for.

So, I literally put this project box on the shelf. When I came back to it a few weeks later, a second problem became apparent. The tubing was contaminated with a white substance, which was probably a mold. This is a major problem, because I can’t just rinse the pneumatic tubing leading to the pressure sensor with a sanitizing solution; the pressure sensor is not tolerant of liquids. I’d have to replace the pneumatic tubing, and I’d probably need to consider an alternative source for pressurized gas such as a CO_2 cylinder.

Next Steps

This project deserved a second iteration, but it revealed several problems with my brewery. Much of my equipment and software had become difficult to use and more difficult to maintain. I spent years allowing the garden to grow, but it needed pruning. At the same time, my career, parenthood, and my other side project started taking up much of my time. Just like that, three years passed and my brewery gathered dust.

I’ve been doing some pruning this year, and I hope to breath life into the brewery in the next couple of years. There’s still a lot of work to do.

Next post: μDAQC. That’s Micro Data Acquisition and Control. Simple, right?

Share this Post

Leave a Comment

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