B4A Library Heart Rate Monitor

This is a shortcut wrap for this Github project. It uses the back camera and flash/torch of your device to determine your heart rate from the pulses in your finger. Just thought that it is something unique and would post it. I guess it can be converted into a fully fledged B4A project by "translating" the Java code and making use of the CameraX....library/libraries...?

Download commons-collections4-4.0.jar from here:

....and copy it to your additional library folder.

Download and extract the jars/xml's in the attached OtherB4AlibFiles.zip and copy them to your additional libs folder.
Download and extract folder DemoRes from the attached DemoRes.zip and copy the extracted folder and its contents to be on the same folder level as that of the b4a project's /Files and /Objects folders

Extract the B4A sample project from the attached b4aHeartRateMonitor.zip

Take note of the manifest file of the B4A project:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

            android:screenOrientation="portrait" >

B4A project's sample code:
#Region  Project Attributes
    #ApplicationLabel: b4aHeartRateMonitor
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\DemoRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim hrm As HeartRateMonitor

    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
End Sub

Once all in place, compile the B4A project and click on button "Start Heart Rate Monitor". Then place your index finger (left or right) on the back camera....this is from the Github posting:

Open the HeartRateMonitor App and hold the tip of your index finger over the camera lens of your phone. The entire camera preview image should be red with a lighter area where the tip of your finger is touching. Do not press too hard or you will cut off circulation which will result in an inaccurate reading.

After ten seconds it will compute your heart rate. It'll take between ten and thirty seconds to get an accurate heart rate.

This is what you should see when in operation.....



  • b4aHeartRateMonitor.zip
    8.1 KB · Views: 368
  • DemoRes.zip
    35.1 KB · Views: 340
  • OtherB4AlibFiles.zip
    393.3 KB · Views: 376
Last edited: