Sunday, May 10, 2026

MPXV7002 as Breath Sensor

Breath sensor made from an MPXV7002 and a silicon tube. The tube has incisions added near the breathing end to allow air to flow through while still building pressure at the sensor end. Enough pressure is still built up within the tube to allow circular breathing if desired. The sensor sends note on / off and continuous control data.

To improve this I might consider a wider tube that is coupled with the sensor or try more or different-sized puncture holes or a 3D printed mouthpiece. However, it still works really well as-is.

Wiring is simple as the sensor outputs an analog voltage and works fine on 3v3 or 5v power supply. The output voltage is rail to rail across the power supply voltage range, and can represent both positive and negative pressure, meaning that the neutral pressure will output at halfway of the voltage supply.

For a Teensy 3.x or 4.x: 3v3 to the 5V pin on the sensor, ground to ground and output of the sensor to Teensy A0 analog input pin.



Here is some code as an example: 


int air_pin = A0;
int air_pressure;
int air_pressure_prev;
int breath_controller = 1;

int threshold = 75;
int play_flag = 0;

int channel = 1;
int pitch = 60;
int velocity = 127;

void setup() {
Serial.begin(57600);
usbMIDI.read();
}

void loop() {
air_pressure = analogRead(air_pin) >> 3;
if(air_pressure != air_pressure_prev) {
air_pressure_prev = air_pressure;
usbMIDI.sendControlChange(breath_controller, air_pressure, channel);
Serial.println(air_pressure);
delay(10);
}

if(air_pressure > threshold && play_flag == 0) {
usbMIDI.sendNoteOn(pitch, velocity, channel);
Serial.println("note on");
play_flag = 1;
}

if(air_pressure < threshold && play_flag == 1) {
usbMIDI.sendNoteOff(pitch, 0, channel);
Serial.println("note off");
play_flag = 0;
}

}


0 comments: