The $8.04 USB MIDI Breath Controller

I have collected various bits and pieces for making controller devices, I just got around to testing a cheap pressure sensor module.

Available for about $4 from a number of Chinese Sellers, $1.98 + $1.56 shipping here

This sensor advertised as having a 0-40 kpa (0-5.8 psi) range, which is less sensitive than typically used in breath controllers, I can saturate it with a balloon popping breath pressure. The interface is an HX710B bridge amplifier with 24 bit resolution output, this resolution may allow acceptable low pressure performance, compared to the microprocessor’s built in 12 bit ADC more typically used. The HX710B is a stripped down 8 pin version of the HX711 used in strain gauge scales, it has no register settings, though there are a couple of parameters effected by the number of clock pulses. Here’s a decent user guide for the pressure module.)
HX710B Spec Sheet.
I have yet to test for low pressure noise, it might end up feeling more like playing a bass sax, or inflating a mattress if it has to be a pressure rather than a volume sensor. While a precision scale averages multiple readings in the 10 samples per second mode to null out sensor and ambient electrical noise, I am looking at sending 40 readings a second for better dynamic response.

(I learned some open source medical ventilators measure volume with a sensitive differential pressure sensor measure the 2 sides of a slight restriction)

The USB interface is done by the Arduino Pro Micro who’s ATmega32U4 processor has built in USB, more typically us for HID devices like a mouse simulation. The USBmidi library can be installed from within the Arduino IDE. You can get a 5V Pro Micro for $3.82 + $0.68 shipping Here.

Here’s a stripped down part of the code to read the sensor:

void setup()
{
Serial.begin(9600);
pinMode(A2, INPUT); //data line //Yellow cable, General-Analog Pins
pinMode(A3, OUTPUT); //SCK line //Orange cable
}

void loop()
{
digitalWrite(A3, LOW);// Hold clock low until sample is ready
while (digitalRead(A2) != LOW) // wait for sample ready signal
;
for (int i = 0; i < 24; i++) // shift in 24-bit serial data from HX711
{
clk();
bitWrite(x, 0, digitalRead(A2));
x = x << 1;
}
clk(); // 25th clk() signals future 10 sps sample rate
// Adding 2 more clocks signals to do 40 samples per sec next time
clk();
clk();
x = x << 7; // Shift scale to 32 bit so 2s compliment sign is ms-bit
Serial.println(x, DEC);
delay(100); //
}

void clk()
{
digitalWrite(A3, HIGH);
digitalWrite(A3, LOW);
}

I discovered that the sensor also report negative pressure, it seems to clip with less pressure than positive pressure but provides a symmetrical output signal once you get the 2’s compliment output read properly.

I haven’t messed with my hand crafted Ztnthian (I spent quite a bit of time contributing research and a bit of prototyping for open source Covid solutions) I briefly tested this controler with garageband.
I would like to add a tiny OLED display and a generic IR remote for performance configuration. In part because I am not that skilled at crafting a configuration app for a PC or phone.

I tested with a 5V (8 bit microprocessor) to more easily power the sensor with 5V, reportedly giving better sensitivity than 3.3v.
I would prefer to use a modern 16 bit processor like a teensy or A SAMD21 used in the Adafruit Trinket M0 or the $4.90 Seeedstuino XIAO in order to have enough ram to pour in more bells and whistles. (You can run Adafruit’s Circuit python on the Seeeduino board, making for cheap USB controller experiments for the python programmers), the board mounts like a flash drive on your PC you can just edit it’s code with a text editor)

Here’s a Seedestudio article on TinyUSB and the SAMD21 which includes USB MIDI functions.

I am getting up to speed on Bluetooth 5.0 which gives 4X the range and 2X the data rate of the previous version, (there are only a few premium cell phones that can use both of these advancements) The $10 Nordic Semi NRF52840-DONGLE is a cheap part for experimenting with Bluetooth MIDI, the bootloader requires you to use their free tools, though you can reportedly flash an Adafruit compatible bootloader to program it with Arduino IDE.

I will need to learn how best to tweak MOD parameters with a controler. I plan to craft a sort of guitar pick holder that uses squeeze pressure, orientation and gestures to generate control signals.

There are surplus badges with a compliment of sensors and bluetooth 4 that could also be made into controllers.

13 Likes

Hi, really exciting indeed.
Do you plan to add some keys to play notes also ?

One big objective is to keep the worn part as compact as possible, with no buttons or knobs. A big $2.50 investment nets a generic IR remote for configuration and mode selection, the button press delay is too large for real time note control (might have a simple looping test note available when in configuration mode).
IR Remote
I would like to add pitch detection to produce notes, using an added mike to pick up a Kazoo sort of hum, that would call for a 16 bit processor. (by the way the new Pi Pico is a candidate) might be able to get a trumpet like dynamic.
(one odd term used for a paper and comb instrument is " eunuch flute")

i was looking around for some teensy info and i spotted this…

thought you might like to see too :wink:

2 Likes

Hi, I’m trying to build in breath controller, but I’m having trouble with the code:
“x was not decalreted in this scope”.
Sorry, but I’m not very good at programming

I am making a similar device with the same Arduino Pro Micro and the HX711 module with the Q2-HX711 library. The problem i have is an excesive latency for a controller. It seems it corresponds to USB transmission, since the serial monitor output looks pretty fast.
Have you encounter that excesive latency?

I expect the sampling setting of the HX711 would be the bottle-neck, you don’t need weight scale resolution… I didn’t get to fully implement my experiment.

I found a sensor 4X more sensitive, got it grafted on with some twisted leads but have chickened out on making the smoke test (Enthusiasm can wane waiting 5 weeks for parts to come from china).