This project uses an Adafruit Circuit Playground Classic board along with a Pulse Sensor Amped to measure changes in heart rate variability (HRV).  Because fewer changes in heart rate variability are associated with healthy, relaxed states, these measurements can be used as a way to reduce anxiety and increase meditative calm.

What is HRV?

We normally think about our pulse as being a relatively constant value measured in beats per minute, but in reality, the interval between beats (inter-beat interval or IBI) usually fluctuates quite a bit.  This variance between heart beat intervals is known as heart rate variability (HRV).

When breathing is slowed to a rate of ~12 cycles per minute (1 cycle = 1 inhale + 1 exhale), respiratory & cardiac rhythms tend to fall in sync with one another and HRV fluctuations become less erratic and more amplified resembling a sine wave.  This synchronization is considered indicative of a relaxed, healthy state of being where anxiety is reduced and clear, calm thinking is enhanced. 

So, if we measured and graphed the time between heartbeats of a stressed person, it might look something like this:

And the same type of measurement made on a zen master might look something like this:

The goal of this project is to create a device which will help someone achieve a smoother, sinusoidal HRV pattern like the one above.

You can read more about HRV, coherence, and related topics here:

Disclaimer: This is not a medical device and should not be used for any official diagnostic or otherwise life-dependent medical purposes!

What you'll need:

To build the relaxation trainer you'll only need the following:

Wiring for this project is simple, there are only three connections which need to be made between the Pulse Sensor and Circuit Playground board:

  • Pulse Sensor Black wire to Circuit Playground GND
  • Pulse Sensor Red wire to Circuit Playground VBATT
  • Pulse Sensor Purple wire to Circuit Playground #6

The Circuit Playground can be powered by either USB or the JST battery connector.

Making connections

If you'd just like to experiment with or test this project, you can easily make the necessary connections using three alligator clips. 

For a more permanent approach, you can securely solder the connections.  Clip the male header pins from the pulse sensor leads and then strip and tin each lead before soldering to the terminals on the Circuit Playground board.

This project was written for use with Circuit Playground Classic boards. The code does not support Circuit Playground Express at this time.
This project's code has been confirmed working with Arduino IDE version 1.8.5. Some users have reported issues compiling with later versions.


If this is the first time you're programming a Circuit Playground board, you'll need to set up the Arduino IDE with support for it.  Follow the instructions found here, and come back once you have everything working.


The code we'll be using is based on the example sketch written for the Pulse Sensor Amped.  Code has been added to control the Circuit Playground's built-in Neopixel LEDs and record changes in interbeat interval values (IBI), and calculate a relaxation rating based on how often the IBI plots change direction.

Download the code from the project's GitHib repository here:

Unzip the downloaded archive and rename the folder named "Meditation_Trainer-master" to "Meditation_Trainer".  

Inside that folder, you'll find a file named "Meditation_Trainer.ino" - open it in the Arduino IDE and upload it to your Circuit Playground board.

The pulse sensor can be attached to either the ear lobe or fingertip.  In my experience, attaching the sensor to the fingertip with the included velcro strip provides the most reliable reading.

Once the sensor is secured, connect the Circuit Playground board to power via the USB or battery connector and you should see the two LEDs near the USB jack begin to flash in time with your pulse.

If the LEDs don't light up, try readjusting the sensor until you have a secure fit.

Using the LED Display

Breath Pacer: Eight of the neopixel LEDs on the Circuit Playground are used to display a breath pacer which is helpful for ideal timing of inhale/exhale cycles.  Breath in as the LEDs pulse toward one side, and breath out as they move back to the other side.


Pulse/Relaxation: The remaining two LEDs flash with each pulse detected and their color indicates a basic HRV rating which roughly translates to the user's level of relaxation:


red = low relaxation

blue = moderate relaxation

green = high relaxation


Sit in a comfortable position and use the breath pacer to guide your breathing - breath in as it moves toward one side, and begin to breath out when it changes direction.

As you continue to breathe at this slow deliberate rate, you should notice the pulse LEDs change color to indicate smoother changes in heart rate variability and hopefully help you achieve a more deeply relaxed state.

Though the relaxation indicator is helpful, the most useful functionality here is actually the breath pacer.  One of the most common techniques for achieving a meditative state is focussed breathing. Paying conscious attention to your own breathing is a simple but highly effective way to increase mindfulness.

This guide was first published on Sep 20, 2016. It was last updated on Sep 20, 2016.