Calmer breathing, stress reduction can be improved with inhale and exhale exercise. How about playing a game that will teach proper breathing technique.
This project will show you how I interfaced Infineon Sensor HUB Nano with Bluetooth as a wireless air pressure controller for Unity gaming and VR application.
Using pressures sensors housed inside a ventilated tube to detect breath of air flow, duration, strength, and frequency of inhale and exhale can be measured.
I created game prototype based on breath pressure data where player can match the expanding shrinking balloon. Or fill the virtual balloons to strengthen the lungs.
Building Breath Controller
Affix Infineon Nano Hub Pressure Sensor into end of short flex tube,
Adjust the hole size to calibrate air pressure with amount of air flow. You can try covering the hole with fingers to find the right pressure.
Seal the end of the tube with tape. leave an opening to let the air out.
You can also use any small medicine bottle with hole drilled in. Stacking two bottles with half pie shaped cut out at the end. You can make a adjustable air flow by twisting. With sensor placed between two bottles.
Note: you may want to seal up sensor components to avoid moisture build up that might interfere with electronics.
Download the Android Breath Game Prototype
Download completed build BreathGame.apk to try out on Android devices with NanoHub Sensor Bluetooth evaluation kit.
Install the Apk ( may need to enable install from unknown source option)
Power on the sensor.
Enable Bluetooth on Android device. Pair with IFX_NANOHUB
Launch the game App "Breathing Game Demo"
Status on upper left screen will show connected with successful connection. The pressure UI indicator on right side will update the pressure value. Slider move up with blowing, move down when sucking on the breath tube.
Game 1- A synchronized breathing to visual cue. Player has to match the rhythm of breathing to the size of the inflating and shrinking balloon. With pause between breath. This will simulate pre-programmed breathing interval and techniques.
Game 2 - Player blow on the mouthpiece to inflate balloons. This is for breath training where harder breath will inflate balloons faster and score more points.
Bonus Game - Shoot the inflated balloon with darts with quick burst of air. Harder the breath, faster and longer the darts travels. This will exercise quickness of breath while having fun.
Project build instructions
If you're interested to interface Sensor Hub Evaluation kit to build other Unity based games prototypes, try out my sample Unity projects and source on Github.
Here are the steps on how I built the plugins:
Building the Andorid plugin for Unity
- Apply for a nano DSP evaluation kit. Register to obtain download link to Sensorhub_android_lib zip file from Infineon.
- Extract sensorhub_android_lib_v0_1.aar from zip
- Download and install Android Studio.
- Check out BreathingGame source from GITHUB.
- In Android Studio File>New>import Project. Navigate to BreathingGame/AndroidStudio/BreathGameUnityPlugin
- Click OK to use Gradle wrapper.
- Unzip and Insert sensorhub_android_lib_v0_1.aar library into the lib directory of the sample plugin project . AndroidStudio\BreathGameUnityPlugin\sensorhub_android_lib_v0_1
- Run Gradle build task in sensorhublib directory to create the plugin for Unity.
- Library archive "sensorhublib-release.aar" should be created in the build directory under AndroidStudio\BreathGameUnityPlugin\sensorhublib\build\outputs\aar
Build the Unity Game for Android
- Download latest Unity 2017. http://unity3d.com
- Clone the Breathing game Unity Project from git hub.
- Add sensorhub_android_lib_v0_1.aar into BreathingGame/Assets/lib/Android directory. ( You need to obtain this file from Infineon by registering )
- If rebuilding the Android plug in from scratch add recompiled sensor plugin "sensorhublib-release.aar" into Breath Game Unity project Assets/lib/Android
- Configure build setting for Android and run build