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.