Hacking Mindfulness with an Arduino and the iPhone

Meditation VS Web

For the past six months, I’ve been working on measuring human physiology during meditation. Most notably, instead of focusing on measuring using an EEG (to record brainwaves), I’ve been focusing on measuring the changes in physiology caused by the autonomic nervous system.

And so, I started out building an Arduino based device to measure galvanic skin response, skin temperature, and heart rate. Within a few months, I found the most major physiological changes from meditation occur in the heart rate.

With this in mind, I built an iPhone app called buddha mind to measure and see the changes meditation makes on your heart rate.

This app was an amazing success, and within the first hour made the front page of Hacker News and brought over 4,000 people to the launch site.

Well, now we’ve reached another breakthrough. We’ve developed the very first version of an algorithm to measure and know when you entered a meditative state based upon heart rate variability.

We figured the best way to demo this new algorithm would be by controlling and manipulating a physical object with meditation. With that in mind, we built this light orb:

How it Works

This light orb is a DMX controlled strip of RGB LEDs house inside of a glass orb. It’s receiving DMX data from an Arduino triggered by an Electric Imp.

The Electric Imp is a really exciting project, and this build would have never been possible without it. An Electric Imp allows you to connect any device to the internet, and exposes and entire API for it. The code is fairly straightforward (written in Squirrel), and easy enough to debug based upon the insane complexity going on behind the scenes.

The buddha mind sends an API call to the Electric Imp as soon as the Bluetooth LE heart rate monitor is connected in app. This starts the pulsing white light of the orb.

Once the user starts meditating, our algorithm tracks the heart data, waiting for the heart rate variability to reach a threshold. Once reached, buddha mind makes API call to the Electric Imp to tell it to begin sending the Arduino the trigger for running the meditation lights.

Here’s what the Squirrel code for the Electric Imp looks like:

val <- 0.4; // Default value to send with PWM
function blink()
        hardware.pin1.write(val); // Update the value sent with PWM on pin 1
class input extends InputPort // This is how we create an API input
  name = "LED control"
  type = "number"
  function set(value)
         val = value;
imp.configure("First Program", [input()], []); // Also need to register input for API here.
hardware.pin1.configure(PWM_OUT, 1.0/500.0, 1.0); // Configure pin1 for PWM to send values to Arduino

We send data to this Electric Imp with a post request. It looks like this example, only not with curl in app obviously:

curl --form "value=0.4" https://electricimpssecreturlgoeshere.com/12949332/

The Arduino then reads this PWM and creates and sends signals via the DMX output. This is also very straightforward (psuedocode ish stuff below):

// Before all of this is the awesome code setting up DMX from Triniculo's Attic. It allows us to use the DMXinit, etc. 
// functions.
void setup()
  DMXinit(1,512); // Initializes DMX output with all 512 slots and starting with 1
  pinMode(13,OUTPUT); // LED for status
void loop()
  float duration = pulseIn(4, HIGH);
  if (duration < 200) {  // We've received a low signal (0.1 from the Imp)
  for(x = 0; x < 256; x++)
    red = (int) (sin(frequency*x + 0) * 127 + 128);
    green = (int) (sin(frequency*x + 2) * 127 + 128);
    blue = (int) (sin(frequency*x + 4) * 127 + 128);
    DMXput(1,red);  // Fade channel 1 from 0-255
    DMXput(2,green);  // DMXput takes the channel number and the value 
    delay(20); // Take 2.55 seconds (2550 milliseconds) to execute fade 
  // Fill in the rest of the code here for the triggers you'd like. Cut for brevity here.

The electronic layout is very simple, thanks to the DMX shield from Triniculo’s Attic. It consists of a single connection from the Electric Imp to the Arduino, using pulse width modulation to let the Arduino know what DMX states should be generated.

The DMX data from the Arduino is then sent to a DMX driver, which decodes and powers a strip of RGB LEDs.

The exciting thing about this build is that it’s 100% expandable. We only controlled a single orb, but with DMX we could control and light an entire room with multiple effects. DMX 512 allows up to 70 individually controlled lights! (!!!)

This project will be displayed and demoed in Jacksonville for the BeOneSpark event. You’ll be able to try meditating and changing the lights yourself.

We hope to see everyone there.

If you want to sign up to buy this Orb on indiegogo, to find out when the Android version of the app will be released, or to just hear more about what I’m working on, I’d appreciate it if you signed up for my mailing list.

I won’t spam ya, promise!

Fill out my online form.

Events Don’t Exist

In my life, I try to imagine events don’t exist at all. That there will never be some major “thing” that happens which changes anything dramatically in my life.

See, I’ve noticed a lot of people go through life waiting for events. Waiting on external validation to let them know their efforts haven’t been for naught.

And I see this destroy 99% of would be entrepreneurs or creatives. They get started, get worked up and start building, produce something, and then bam.

There is no event they were looking for.

The major media they expected for their project never arises, the customers don’t magically show up, and the idea doesn’t go viral.

Back to square one? Or quit?

But there are no events, see? You don’t just have things happen overnight. You don’t just sit down, and write the great american novel, or build the greatest company.

Instead, you build a process, and you start a practice.

A few weeks ago I decided to teach myself guitar. So I started researching, and found a way to make sure I practiced.

In two week’s worth of daily practice with the help of Rocksmith and a great beginner guitar, I’ve began the path of playing the my first instrument. Now here I am, a few weeks later, starting to play along with my favorite music.

With that daily practice I know mastery is coming. The only thing I have to do is show up for practice consistently. No matter what, put in the time daily, and you will get results.

Life works in the same way. We don’t have these cosmic shifts, except by daily practice, and by things we see way down the road.

There is very high latency in our results as humans.

Some tiny little adjustment we make now, and reinforce daily might not be seen for years. And it’s specifically the type of people willing to commit to trim tabs, daily micro improvements, who end up with monster companies and published books and great health.

A great life doesn’t happen alongside any event. A great life is a series of practices. Practicing being a friend, practicing being a cook, practicing being a coder, practicing being a writer.

In every piece of life, we can only make these daily practices. There are no events which propel us into something radically different.

When people talk about breakthroughs, what they’re really talking about is accumulated results adding up to something more.

And I see this daily, with people sabotaging their long term interests for short term gains. And sacrificing a lot for events. Always looking to buy into an event.

An education, a partner, wealth, health.

In fact, this is the way almost all of the world is hypnotized into doing things they hate. The daydream of the event, of the product which changes everything.

But that event changes nothing. Buying that car or that house, or having that cash in the bank doesn’t change the things that matter most. I think the hypnosis of imaginary events is what keeps 90% of the economy rolling.

How much different is a purchase vs mastery at a chosen field? Which would you rather have, a 5% chance of a Porsche in 5 years, or the ability to play guitar, paint, or write like mad?

We’ve been hypnotized to chase the wrong goals. What matters is what we can create, independent of external circumstances. The way we become creators is through practices. External circumstances never arrive when we want them to.

We practice being a good partner daily, we practice creating wealth daily, and we practice creating health daily. It is the accumulation of our previous results that determines where we stand today.

And in that is something completely radical.

We are all starting over today.

We’re all given the day to do with it what we will. What practices will you implement? What trim tabs will you create for you future self?