Chillout with The Relaxino Heart App
Why did I bother? Well I had a heart attack about 8 months ago so this type of thing came uppermost in my mind. I now use the prototype Relaxino hardware and app to chillout and relax the heart.
Explanation of how it works.
It works by measuring your heart rate and taking an average over 20 beats. An LED on Arduino pin 13 flashes each time your heart beats, because each beat triggers an external interrupt. The average heart rate is sent every 20 beats over Bluetooth to the Android device.
It works by measuring your heart rate and taking an average over 20 beats. An LED on Arduino pin 13 flashes each time your heart beats, because each beat triggers an external interrupt. The average heart rate is sent every 20 beats over Bluetooth to the Android device.
You set a target rate on the Android, so a purple screen
flashes when you are above target and a green one when you are at, or below the
target heart rate. This allows you to try to relax and get feedback on how you
are doing. Lie or sit down and try to relax, taking long deep breaths in and
out, empty your mind and gently focus on the screen light (being in the dark helps
so you can see the pulses through semi-closed eyelids).
Geekery Recipe:
Geekery Recipe:
Arduino
- The
device uses a RISING interrupt on pin 2, so attach the output wire
(yellow) of the heart monitor to pin 2 of the Arduino.
- Black
wire goes to ground and red to +5v.
- Connect the Rx and Tx, power and ground of the Bluetooth module (mine is a BlueSmirf Gold) to the Arduino pins 4 and 5 respectively.
- Attach the ear clip to your left ear. Beware some peoples ear lobes are too thick (mine are) so play around with the position. I had to put it on a thin flattish part of my ear.
- Upload
the code to the board.
- LED on
pin 13 will pulse at same rate as your heart. You can check by feeling the
pulse in your neck. Both should be approx in sync.
- Open the serial monitor (for debug if required)
Android
- Install the App - you can do this directly using Relaxino.apk, or create a project in Eclipse Juno, and cutting and pasting the .java and .xml files. NB the manifest and layout files are in the same .xml file. You might need the app icon too so I included it on the Google drive.
- Check the Arduino BT module is paired with your Android device (in Android settings). It may require a PIN but they are usually trivial numbers such as 0000 or 1234.
- Start the app and enter the name of your BT device eg FireFly-008A and click Open Connection.
- A connection should happen and a success message “Connection Opened: device_name ” appears. The message in the purple bar will say “Waiting...” If it fails just keep trying.
- Press reset on the Arduino – and the message should change from “Waiting” to “Sensing Heart Rate”.
- After 20 beats the message should read “Your Heart Rate is: something bpm”
- This is your actual average heart rate sent every 20 beats from the Arduino.
- Set the target heart rate for your relaxation. When you reach the target the screen will change from flashing-purple to flashing-green.
- Lie or sit down and try to relax, taking long deep breaths in and out, empty your mind and gently focus on the screen light (being in the dark helps so you can see the pulses through semi-closed eyelids).
- Gradually increase the length of the breaths, counting if you need to: 6-8 seconds for in, 6-8 seconds for out (or do whatever you can manage). Build up to longer and longer ins and outs. Don't rush it and get out of breath - your heart will beat faster!
- With practice it can help you relax by providing simple biofeedback.
Screen
Shot
Arduino and Android Code and App here: Google Drive
App only is now on Google Play Relaxino
and FileDir.com
App Icon: blueglassheart.png
Check out this awesome Arduino-Android accessory dev tool.
https://play.google.com/store/apps/details?id=com.nettoraid.droidei
http://www.droidei.com/
/**
* Communicate with Arduino over Blue-tooth to display your
* heart rate in a tablet user interface. It also provides simple biofeedback
* via a flashing screen which flashes with your heart rate. The user can choose
* a target rate from 30 to 100 bpm, using a sliding seek-bar. The screen changes
* from purple to green when the target is achieved, enabling the user to use breathing
* techniques to reduce heart-rate and so achieve a better level of relaxation,
* through biofeedback training.
*
***Disclaimer***
* Please note this code is provided for free and AS IS. There is no support and no guarantee
* from the Author.As a non-expert I happy to answer constructive comments and questions.
*****************
*Subject to GNU licence version 3 and copyright of Craig Turner April 2013:
* please use it, modify it, and enjoy it.
* If you find it useful please link to my website:
* http://gampageek.blogspot.co.uk/2013/04/chillout-with-relaxino-heart-app-few.html
*
* Bluetooth coding based on Matt Bell's Blog here:
* http://bellcode.wordpress.com/2012/01/02/android-and-arduino-bluetooth-communication/
*/