For a demo that I want to prepare I need a pressure switch (pressure sensor) that regulate the pressure inside the balloon. The schema is the following: balloon inflated by an air compressor, regulated by a pressure switch (or sensor or whatever) connected to the Raspberry. So, inflate the balloon until the pressure is n, so the Raspberry will open the relay and shut the air compressor.

Which type of sensor can I use? I need an inline sensor or switch for the pressure and I'm not able to find it, I'm only able to find Barometrical sensor, or physical pressure sensor (touch).


2 Answers 2


You can use any pressure sensor which

  1. Uses 3.3 volts (you can use a logic-level converter) Just connect the sensor to 3.3v. Usually it just works.

  2. Works with whatever software your Pi is loaded with.

Take a look at a BMP085. In fact, Adafruit even has an article all about it (how to use + sample code)

  • How can I measure the pressure of the balloon with the BMP085? I mean, physically, where I connect it? I think I need an inline sensor, not a BMP, or at least, I cannot see its application in my project.
    – Possa
    Jan 12, 2016 at 14:23
  • @Possa Literally everything is on the link I gave you, including step-by-step instructions, sample codes, and download links.
    – Aloha
    Jan 12, 2016 at 14:33
  • 1
    @Possa As for the inline problem: Get a container with two and only two holes, attach sensor inside, wire up and seal off wires. Cut air hose, connect one part to a hole and another part to the second hole. If you did this then congrats. You just made a makeshift inline pressure sensor.
    – Aloha
    Jan 12, 2016 at 14:35
  • That's exactly the problem! I need to build that thing, or (if it exists) uses an inline sensor! Let's suppose that this is my simplified architecture: i.ytimg.com/vi/P0I2OvXbcKw/hqdefault.jpg (Compressor, tube, balloon) I obviously cannot put the BMP inside the balloon, so I have to make something up!
    – Possa
    Jan 12, 2016 at 14:44
  • @Possa How could a simple setup be so complicated? How could finding a container, punching holes, using hot glue and sealing off hoses be a problem? I obviously cannot put the BMP inside the balloon sigh
    – Aloha
    Jan 12, 2016 at 15:03

I have good experience with Honeywell ABPLANT005PG2A3 sensor.
Honeywell sensor

It is very small indeed (7mm x 8mm). I connect it to pressure source with SMC TIUB01 tube and M-3AU-3 fitting. I need to make only small hole with M3 thread to connect the pressure sensor.
This sensor uses 3.3V i2c so it could be directly connected to RPI pins.

It has great resolution and stability (but temperature compensation seems not to be perfect). And yes, it is cheap enough (retail price under $10).

This example shows how to work with this sensor:

#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>

#define MAX_PRESSURE 5.0
#define MIN_PRESSURE 0.0

#define SENSOR_ADDR 0x28

int main()
  int fd;
  char buf[10];
  float p, t;

  if ((fd = open("/dev/i2c-1", O_RDWR)) < 0) {
    printf("Failed to open the bus.");

  if (ioctl(fd, I2C_SLAVE, SENSOR_ADDR) < 0) {
    printf("Failed to acquire bus access and/or talk to slave.\n");

  if (read(fd, buf, 4) != 4) {
    printf("Failed to read from the i2c bus.\n");

  p = (buf[0] * 0x100 + buf[1] - 1638) *
      (MAX_PRESSURE - MIN_PRESSURE) / (14745 - 1638) + MIN_PRESSURE;
  t = (buf[2] * 0x100 + buf[3]) * 200.0 / 2047 / 32 - 50;

  printf("pressure=%f, temperature=%f\n", p, t);

This code should work with any i2c-enabled sensor from Honeywell (ABP series, HSC series, SSC series) as well as with some other sensors (ex. Measurement Specialties MS4515DO)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.