Skip to content

Diaphragmatic and Abdominal Breathing

October 19, 2010

Previous Related Post:

Out of Body:

[At Rest of You:]

The respiration monitor is working:

Ignore the op-amp and red and green wires at the center bottom of the photo–they’re for the GSR sensor, which I am not tracking here.  The respiration sensor is simply a stretch sensor attached to a voltage divider via the green wire to the lower right, and the black wire to the right.

The code for this sketch was from Dan O’Sullivan’s SerialFiler:

Next steps:

  • Build second unit
  • Add button(s) to mark critical moments
  • Revise Processing sketch to show all data points simultaneously
  • Onboard signal/alarm (?)
  • Consider mobile options:
    • On-board DataLogger
    • Wireless, to signal/alarm, send SMS, email, and/or send to database
      • XBee to Laptop
      • Hardwire serial to iPhone (?)
      • Bluetooth to Android

Subsequent to this post, I built the second unit, and worked on the visualization a bit more with another Processing sketch to try to show a little more information simultaneously:

The upper circle represents the belt around my diaphragm, while the lower one the belt around my belly.  Right now, they are only measuring the change in girth, so the next step will be to represent the growing staleness of air over time independent of girth, as one can always hold one’s breath.

The code for this sketch was modified from Tom Igoe’s Serial String Reader sketch:

Here is the modified code:

Respiration Sketch
Modified by Morgen Fleisig


Serial String Reader
Language: Processing

Reads in a string of characters from a serial port until
it gets a linefeed (ASCII 10). Then splits the string into
sections separated by commas. Then converts the sections to ints,
and prints them out.

created 2 Jun 2005
modified 6 Aug 2008
by Tom Igoe

import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port

float bgcolor; // Background color
float dfcolor = 255; // Diapragm fill color
float bfcolor = 127; // Belly fill color
float ddia; // Diaphragm ball Diameter
float bdia; // Belly ball Diameter

int MAX = 1024;

void setup() {

// List all the available serial ports

// I know that the first port in the serial list on my mac
// is always my Arduino module, so I open Serial.list()[0].
// Change the 0 to the appropriate number of the serial port
// that your microcontroller is attached to.
myPort = new Serial(this, Serial.list()[0], 9600);

// read bytes into a buffer until you get a linefeed (ASCII 10):

void draw() {
ellipse(width/2, height/4, ddia, ddia);
ellipse(width/2, 3*height/4, bdia, bdia);


// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():

void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil(‘\n’);
// if you got any bytes other than the linefeed:
if (myString != null) {

myString = trim(myString);

// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ‘,’));

// print out the values you got:
for (int sensorNum = 0; sensorNum 1) {
bdia = map(sensors[0], 850,880,height/2,height/6);
ddia = map(sensors[1], 850,925,height/2,height/6);


Previous Related Post:

Out of Body:

[At Rest of You:]

Next Post:


[At Rest of You:]


From → Rest of You

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: