Monday, 8 April 2013


Chillout with The Relaxino Heart App

Copyright Craig Turner (Gampa Geek) April 2013. 

 A few weeks back I posted some Arduino code designed to work with the Grove Heart Rate monitor (arduino-meets-yogic-arts). Since then I have developed an Android Application that works with Arduino over Blue-tooth to display your heart rate in a tablet user interface. It also provides simple biofeedback via the screen which flashes at 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 practice breathing techniques, reduce heart-rate and so achieve a better level of relaxation, through biofeedback training.

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.

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:
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

Video of Relaxino

Grove Heart Rate Monitor - Ear Clip

Arduino and Android Code and App here:  Google Drive
App only is now on Google Play Relaxino
and FileDir.com 
Download Relaxino for Arduino-Android / Android
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/
 */


13 comments:

  1. this project looks promising and great but I cant download the source code from the link "error:500" hoping to downloading this soon. thanks

    ReplyDelete
    Replies
    1. Hi Emmanuel, sorry for the problem. I packaged all the files into a .zip file which I anyone can access. The file access permissions were not being inherited by the folder's children. It should work now. Please let me know if you have further problems and I can email you the .zip file direct.

      Delete
    2. Relaxino App now on Google play

      Delete
  2. Hi Craig.
    Thanks for posting all the info. I intend building this when I finish my current project. BTW, what template have you used for your blog.

    ReplyDelete
  3. Excellent work, greetings from El Salvador

    ReplyDelete
  4. Replies
    1. Thanks Cesar. Nice to hear from you in El Salvador.

      Delete
  5. thanks craig! I finally was able to download the source code and other related project files. I'm goin to design around PIC microcontroller and RN-41 Bluetooth module. thanks a lot for sharing!

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. hi craig why my relaxino cannot connect with the bluetooth... it just happened once than i tried it again and still no connection

    ReplyDelete
  8. Thanks, but i don't known function attachInterrupt(0, interrupt, RISING);my program error by this function
    Can you help me? your mail: hthungst@gmail.com

    ReplyDelete
  9. iron titanium | titanium-arts
    iron titanium by titanium white octane blueprint titanium-arts.com - microtouch titanium trim walmart All the titanium white fennec best iron titanium mug tin, iron, iron and pure titanium earrings other iron pieces on a classic online website. Get more details about titanium-arts.com.

    ReplyDelete