Sensor with HX711 PCB

TL;DR

  • Differential air pressure sensor
  • Built using a 3D-printed body and standard strain gauges
  • Material cost below USD 2 (below USD 1 in quantities of 10 or more)
  • Designed for a measurement range of ±10 kPa
  • Tested for detecting sip-and-puff gestures

Introduction

I recently needed an air pressure sensor for one of my projects. I was looking for something inexpensive and easy to source. The sensor only needed to operate over a range of roughly ±10 kPa relative to atmospheric pressure, and there were no strict accuracy requirements. Essentially, I needed a sensor capable of detecting the mild vacuum and overpressure generated when a person sips and puffs into a tube.

There are quite a few suitable options available. ST, for example, offers the MPXx5010 sensor family (originally developed by NXP), and there are also sensors from Asian manufacturers such as CFSensor. The problem is that these options tend to be either relatively expensive or difficult to source for one-off builds.

This made me wonder whether it would be possible to build a “good enough” pressure sensor using only inexpensive, widely available components.

As it turns out, it is…to some extent.

The resulting sensor will never be as precise or reliable as a commercially manufactured device. Nevertheless, it works surprisingly well for the intended purpose. After an initial calibration, it remains reasonably stable over a typical indoor temperature range and is not particularly sensitive to humidity.

Sensor assembled in a 3D printed case

What I will not do in this article is present a scientific analysis of the sensor or provide a complete specification. I expect every sensor to behave somewhat differently due to variations in the construction process, the materials used, and countless other factors that cannot be tightly controlled when building a device like this at home.

Instead, my goal is to show that it is possible to build a simple, low-cost pressure sensor that is perfectly adequate for certain applications. I will describe how I built mine so that others can adapt the design, improve upon it, or build on my code and 3D models for their own projects.

Sensor Idea

Building a pressure sensor comes with several challenges, and building one from 3D-printed parts adds even more. My initial idea was to print a hollow body with a thin membrane and attach a strain gauge to the membrane. After several iterations, I concluded that a two-part design would be the best solution:

Sensor case

The lower part forms the membrane, which is 0.4 mm thick. A circular wall is printed directly onto the membrane, creating the air chamber and providing a mounting surface for the top cover. The top cover contains the hose connector and two mounting points for screws. It is significantly thicker than the membrane to provide the necessary rigidity. Both parts are bonded together using super glue, creating an airtight seal. I used PLA+ to print the housing, although PETG would likely be a good alternative as well.

For the measurement, I use two strain gauges in a half-bridge configuration. One gauge is mounted in the center of the membrane, where it experiences tensile strain when positive pressure is applied. The second strain gauge is centered on the edge of the membrane, where it experiences compressive strain under the same pressure.

Strain gauge placement and theory of operation

This arrangement offers another important advantage: thermal compensation. Since both strain gauges are mounted on nearly the same surface, they experience the same temperature changes. As a result, their resistances change by approximately the same amount, causing most of the temperature-induced error to cancel out.

Sensor Assembly

Assembling the sensor can be a bit challenging. The most delicate step is attaching the strain gauges to the membrane. I don’t think there is a single “best” method for doing this. Although it is possible to attach the strain gauges first and solder the wires afterward, I would not recommend that approach, as the heat generated during soldering can easily deform or melt parts of the thin membrane.

In the following, I will describe the assembly method that I have found to be the most reliable and easiest to work with.

First, I used two small strips of adhesive tape to fix the strain gauges onto a clean surface at the correct spacing (8.5 mm), while leaving the solder pads exposed.

Next, I added additional tape to the sides to ensure everything stayed in place while soldering the wires to the strain gauges. I used red and black wires for the reference voltage connections and a yellow wire for the signal. The insulation of the signal wire was stripped in a way that allowed it to be connected to both gauges, making the soldering process much easier.

After attaching the wires and cleaning the assembly with IPA, I applied another piece of adhesive tape over the entire assembly and trimmed it to the correct width using an X-Acto knife.

The complete assembly can then be lifted and positioned on the membrane. To do this, first mark the center of the membrane using either the alignment marks on the sides of the case or the provided printable template. Make sure you do not use the center of the strain gauge itself. Instead, use the alignment marks on the gauge.

Lift the gauge assembly using the side of the transfer tape opposite the wires as a hinge. This ensures that the assembly can be returned to exactly the same position after applying the adhesive. Apply a small amount of super glue to the strain gauges, then lower the assembly back onto the membrane. Press the gauges firmly and evenly against the membrane for 15–30 seconds. Once the adhesive has set, carefully remove the transfer tape wherever possible.

Optionally, you can apply a small amount of additional glue to secure the wires to the side of the sensor for improved strain relief.

As a final step, glue the two halves of the sensor together. Apply a small amount of super glue along the wall of the bottom part, then firmly press the top cover into place. Hold it for 15 to 30 seconds, then allow the glue to fully cure.

Your sensor is now ready to use.

Taking Measurements

We now have two resistors on a membrane whose resistance changes slightly when pressure is applied. To make the sensor useful, we need to measure these tiny resistance changes.

The two strain gauges form one half of a Wheatstone bridge. By adding a second voltage divider and connecting both dividers to the same reference voltage, we complete the bridge. The voltage difference between the two halves is the quantity we are interested in. Ideally, the reference divider remains stable while the voltage across the strain gauge divider changes with the applied pressure.

Because these voltage changes are extremely small, they must be amplified before they can be measured. Since we are interested in the difference between the two bridge outputs, a differential amplifier, more specifically an instrumentation amplifier, is the ideal choice. Finally, the analog signal must be converted into a digital value.

Building such a circuit from discrete components is unnecessarily complicated. Instead, I highly recommend using an off-the-shelf solution such as the HX711 or HX717. These inexpensive ICs integrate everything we need: a stable reference voltage, a differential amplifier, and a high-resolution analog-to-digital converter. The following example shows how to connect the sensor to an HX717. R1 and R2 represent the strain gauges on the sensor.

Example schematic for HX717

Congratulations! We now have a digital representation of the applied pressure. But is it useful yet? Probably not. The raw value is not calibrated and has no meaningful reference point. Instead, we simply get an integer that does not directly correspond to any physical quantity.

Calibration is therefore an essential step and brings us to the software side of the project. First, we need to establish a reference point for zero pressure, followed by one or more calibration points that define the measurement range.

At first glance, it might seem sufficient to measure the sensor with no pressure applied to determine the zero point. In practice, however, the zero value drifts depending on the previously applied load. After positive pressure, the resting value settles slightly higher than it does after negative pressure. As a result, the sensor effectively has two different zero points, one for positive measurements and one for negative measurements.

A practical solution is to treat all values between these two zero points as zero. Measurements above the positive zero point use that value as their reference, while measurements below the negative zero point use the negative reference. The measured value can then be linearly interpolated between the corresponding zero point and the calibrated maximum or minimum, allowing the result to be expressed as a more intuitive range, such as ±100%.

I did not calibrate the sensor against any specific physical reference value, so I cannot make any claims about its absolute accuracy or linearity. Instead, I calibrated it based on my own ability to perform sip and puff gestures.

If you have access to equipment capable of generating a stable pressure or vacuum and can perform some measurements, I would be very interested in the results, especially regarding the sensor’s linearity.

For my intended use, however, calibrating the sensor to my own sip and puff strength is entirely sufficient ;)

I wrote some code to execute the signal conditioning and the calibration. You will find this in the download section of this post.

Final Thoughts

The described sensor works quite well for its intended purpose, and I think it has some potential for DIY projects. I haven’t seen anything that uses a similar technique, so I think it is worth writing about and sharing the idea.

Printing the sensor also provides a lot of freedom in terms of its shape and how it can be mounted. This may allow you to build a product with a custom-made sensor that would not have been possible using a commercial one. You could even integrate the sensor directly into the enclosure of a product.

If you use this idea in one of your own projects, I would be happy to hear about it.

Project files

DOWNLOAD: Code, STL and SCAD files